Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support python3.9 by using unescape() from html_parser (python3 only) #937

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion itchat/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@

emojiRegex = re.compile(r'<span class="emoji emoji(.{1,10})"></span>')
htmlParser = HTMLParser()

try:
unescape = htmlParser.unescape
except:
from html.parser import unescape


try:
b = u'\u2588'
sys.stdout.write(b + '\r')
Expand Down Expand Up @@ -71,7 +78,7 @@ def _emoji_formatter(m):
def msg_formatter(d, k):
emoji_formatter(d, k)
d[k] = d[k].replace('<br/>', '\n')
d[k] = htmlParser.unescape(d[k])
d[k] = unescape(d[k])

def check_file(fileDir):
try:
Expand Down