Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c19a283

Browse files
committed
Minor patch
1 parent 7accba4 commit c19a283

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

lib/request/basic.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,14 @@ def decodePage(page, contentEncoding, contentType):
254254

255255
# e.g. ’…™
256256
if "&#" in page:
257-
page = re.sub(r"&#(\d+);", lambda _: unichr(int(_.group(1))), page)
257+
def _(match):
258+
retVal = match.group(0)
259+
try:
260+
retVal = unichr(int(match.group(1)))
261+
except ValueError:
262+
pass
263+
return retVal
264+
page = re.sub(r"&#(\d+);", _, page)
258265

259266
# e.g. ζ
260267
page = re.sub(r"&([^;]+);", lambda _: unichr(htmlEntities[_.group(1)]) if htmlEntities.get(_.group(1), 0) > 255 else _.group(0), page)

0 commit comments

Comments
 (0)