Skip to content

Commit 325dd58

Browse files
committed
Update string convertion
1 parent 5ab196a commit 325dd58

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

requirements_dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Sphinx==8.0.2
88
numpydoc==1.8.0
99
pytest>=3.7.2
1010
pytest-runner>=4.2
11-
Cython==3.0.12
11+
Cython=3.0.11
1212
pluggy>=0.7.1
1313
mypy==1.4.1
1414
types-pyinstaller==6.10.0.20240812

selectolax/lexbor/node.pxi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ _TAG_TO_NAME = {
66
0x0004: "-comment",
77
}
88
ctypedef fused str_or_LexborNode:
9-
basestring
9+
str
1010
bytes
1111
LexborNode
1212

1313
cdef inline bytes to_bytes(str_or_LexborNode value):
1414
cdef bytes bytes_val
15-
if isinstance(value, (str, unicode)):
16-
bytes_val = value.encode(_ENCODING)
15+
if isinstance(value, unicode):
16+
bytes_val = <bytes>value.encode("utf-8")
1717
elif isinstance(value, bytes):
18-
bytes_val = <char*> value
18+
bytes_val = <bytes>value
1919
return bytes_val
2020

2121
@cython.final
@@ -431,7 +431,7 @@ cdef class LexborNode:
431431
>>> tree.css_first('i').unwrap()
432432
>>> tree.html
433433
'<html><head></head><body><div>Hello world!</div></body></html>'
434-
434+
435435
Note: by default, empty tags are ignored, use "delete_empty" to change this.
436436
"""
437437
if self.node.first_child == NULL:
@@ -472,7 +472,7 @@ cdef class LexborNode:
472472
>>> tree.body.unwrap_tags(['i','a'])
473473
>>> tree.body.html
474474
'<body><div>Hello world!</div></body>'
475-
475+
476476
Note: by default, empty tags are ignored, use "delete_empty" to change this.
477477
"""
478478

selectolax/modest/node.pxi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ cdef class _Attributes:
133133

134134

135135
ctypedef fused str_or_Node:
136-
basestring
136+
str
137137
bytes
138138
Node
139139

@@ -980,8 +980,8 @@ cdef inline str append_text(str text, str node_text, str separator='', bint stri
980980

981981
cdef inline bytes to_bytes(str_or_Node value):
982982
cdef bytes bytes_val
983-
if isinstance(value, (str, unicode)):
984-
bytes_val = value.encode(_ENCODING)
983+
if isinstance(value, unicode):
984+
bytes_val = <bytes>value.encode("utf-8")
985985
elif isinstance(value, bytes):
986-
bytes_val = <char*> value
986+
bytes_val = <bytes>value
987987
return bytes_val

0 commit comments

Comments
 (0)