Skip to content

Commit 6cf5810

Browse files
committed
Improve __repr__
self.root can be None
1 parent 4392cf1 commit 6cf5810

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

selectolax/lexbor.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ cdef class LexborHTMLParser:
204204
str
205205
A string showing the number of characters in the parsed HTML.
206206
"""
207-
return f"<LexborHTMLParser chars='{len(self.root.html)}'>"
207+
html = len(self.root.html if self.root is not None else "")
208+
return f"<LexborHTMLParser chars='{html_len}'>"
208209

209210
@property
210211
def selector(self):

0 commit comments

Comments
 (0)