Skip to content

Commit

Permalink
Use "utf-8" instead of "utf8" as the default encoding.
Browse files Browse the repository at this point in the history
  • Loading branch information
wRAR committed Dec 11, 2024
1 parent 05f0435 commit 63c6244
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
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"))

0 comments on commit 63c6244

Please sign in to comment.