jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1096384?usp=email )
Change subject: cleanup: sys.maxunicode is 0x10ffff since Python 3.3 due to
PEP393
......................................................................
cleanup: sys.maxunicode is 0x10ffff since Python 3.3 due to PEP393
Change-Id: I1a7b2dd299a2f0a591dfca965a827eedd3c87719
---
M pywikibot/tools/chars.py
1 file changed, 2 insertions(+), 10 deletions(-)
Approvals:
Matěj Suchánek: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/tools/chars.py b/pywikibot/tools/chars.py
index a9aef1b..de011c0 100644
--- a/pywikibot/tools/chars.py
+++ b/pywikibot/tools/chars.py
@@ -1,13 +1,12 @@
"""Character based helper functions (not wiki-dependent)."""
#
-# (C) Pywikibot team, 2015-2023
+# (C) Pywikibot team, 2015-2024
#
# Distributed under the terms of the MIT license.
#
from __future__ import annotations
import re
-import sys
from contextlib import suppress
from urllib.parse import unquote
@@ -30,14 +29,7 @@
def replace_invisible(text):
"""Replace invisible characters by '<codepoint>'."""
def replace(match) -> str:
- match = match.group()
- if sys.maxunicode < 0x10ffff and len(match) == 2:
- mask = (1 << 10) - 1
- assert ord(match[0]) & ~mask == 0xd800
- assert ord(match[1]) & ~mask == 0xdc00
- codepoint = (ord(match[0]) & mask) << 10 | (ord(match[1]) & mask)
- else:
- codepoint = ord(match)
+ codepoint = ord(match.group())
return f'<{codepoint:x}>'
return INVISIBLE_REGEX.sub(replace, text)
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1096384?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I1a7b2dd299a2f0a591dfca965a827eedd3c87719
Gerrit-Change-Number: 1096384
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Matěj Suchánek <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]