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

Use "utf-8" instead of "utf8" as the default encoding. #308

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions parsel/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def create_root_node(
base_url: Optional[str] = None,
huge_tree: bool = LXML_SUPPORTS_HUGE_TREE,
body: bytes = b"",
encoding: str = "utf8",
encoding: str = "utf-8",
) -> etree._Element:
"""Create root node for text using given parser class."""
if not text:
Expand Down Expand Up @@ -318,7 +318,7 @@ def _get_root_and_type_from_bytes(
) -> Tuple[Any, str]:
if input_type == "text":
return body.decode(encoding), input_type
if encoding == "utf8":
if encoding == "utf-8":
try:
data = json.load(BytesIO(body))
except ValueError:
Expand Down Expand Up @@ -445,7 +445,7 @@ def __init__(
text: Optional[str] = None,
type: Optional[str] = None,
body: bytes = b"",
encoding: str = "utf8",
encoding: str = "utf-8",
namespaces: Optional[Mapping[str, str]] = None,
root: Optional[Any] = _NOT_SET,
base_url: Optional[str] = None,
Expand Down Expand Up @@ -518,7 +518,7 @@ def _get_root(
huge_tree: bool = LXML_SUPPORTS_HUGE_TREE,
type: Optional[str] = None,
body: bytes = b"",
encoding: str = "utf8",
encoding: str = "utf-8",
) -> etree._Element:
return create_root_node(
text,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@ def __init__(
text: Optional[str] = None,
type: Optional[str] = None,
body: bytes = b"",
encoding: str = "utf8",
encoding: str = "utf-8",
namespaces: Optional[Mapping[str, str]] = None,
root: Optional[Any] = _NOT_SET,
base_url: Optional[str] = None,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_selector_csstranslator.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,4 @@ def test_pseudoclass_has(self) -> None:

class CSSSelectorTestBytes(CSSSelectorTest):
def setUp(self) -> None:
self.sel = self.sscls(body=bytes(HTMLBODY, encoding="utf8"))
self.sel = self.sscls(body=bytes(HTMLBODY, encoding="utf-8"))
Loading