You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
towards supporting unicode: docstring
This commit is contained in:
@@ -105,8 +105,21 @@ def print_docstring(self, indent, docstring):
|
||||
self.write(indent)
|
||||
if not PYTHON3 and not isinstance(docstring, str):
|
||||
# Must be unicode in Python2
|
||||
self.write('u')
|
||||
docstring = repr(docstring.expandtabs())[2:-1]
|
||||
if self.version >= 2.4:
|
||||
if self.version > 2.7:
|
||||
docstring = repr(docstring.expandtabs())[2:-1].decode("unicode-escape")
|
||||
else:
|
||||
self.write('u')
|
||||
docstring = repr(docstring.expandtabs())[2:-1].decode("string-escape").decode("utf-8")
|
||||
else:
|
||||
docstring = repr(docstring.expandtabs())[2:-1]
|
||||
elif PYTHON3 and 2.4 <= self.version <= 2.7:
|
||||
# TODO: check for unicode string
|
||||
try:
|
||||
docstring = repr(docstring.expandtabs())[1:-1].encode("latin-1").decode("utf-8")
|
||||
except UnicodeEncodeError:
|
||||
self.write('u')
|
||||
docstring = repr(docstring.expandtabs())[1:-1]
|
||||
else:
|
||||
docstring = repr(docstring.expandtabs())[1:-1]
|
||||
|
||||
|
Reference in New Issue
Block a user