Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore and deprecate _unicode_safe_getattr. #133

Merged
merged 3 commits into from Oct 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions cssselect/xpath.py
Expand Up @@ -14,6 +14,7 @@

import re
import typing
import warnings
from typing import Optional

from cssselect.parser import (
Expand All @@ -37,6 +38,17 @@
)


@typing.no_type_check
def _unicode_safe_getattr(obj, name, default=None):
warnings.warn(
"_unicode_safe_getattr is deprecated and will be removed in the"
" next release, use getattr() instead",
DeprecationWarning,
stacklevel=2,
)
return getattr(obj, name, default)


class ExpressionError(SelectorError, RuntimeError):
"""Unknown or unsupported selector (eg. pseudo-class)."""

Expand Down