You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Simplfy - TODO fix unicode in docstrings
This commit is contained in:
BIN
test/bytecode_2.4_run/00_docstring.pyc
Normal file
BIN
test/bytecode_2.4_run/00_docstring.pyc
Normal file
Binary file not shown.
@@ -1,7 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# uncompyle2 bug was not escaping """ properly
|
||||
|
||||
# RUNNABLE!
|
||||
r'''func placeholder - with ("""\nstring\n""")'''
|
||||
|
||||
def uni(word):
|
||||
u""" <----- SEE 'u' HERE
|
||||
>>> mylen(u"áéíóú")
|
||||
5
|
||||
"""
|
||||
|
||||
|
||||
def foo():
|
||||
r'''func placeholder - ' and with ("""\nstring\n""")'''
|
||||
|
||||
@@ -39,5 +48,9 @@ def baz():
|
||||
>>> t.rundict(m1.__dict__, 'rundict_test_pvt') # None are skipped.
|
||||
TestResults(failed=0, attempted=8)
|
||||
"""
|
||||
assert uni.__doc__ == u""" <----- SEE 'u' HERE
|
||||
>>> mylen(u"áéíóú")
|
||||
5
|
||||
"""
|
||||
|
||||
baz()
|
||||
|
@@ -137,19 +137,12 @@ def print_docstring(self, indent, docstring):
|
||||
|
||||
# Escape triple quote when needed
|
||||
if quote == '"""':
|
||||
if self.version > 2.7:
|
||||
replace_str = '\\"""'
|
||||
else:
|
||||
replace_str = '\\"\\"\\"'
|
||||
docstring = docstring.replace(quote, replace_str)
|
||||
replace_str = '\\"""'
|
||||
else:
|
||||
assert quote == "'''"
|
||||
if self.version > 2.7:
|
||||
replace_str = "\\'''"
|
||||
else:
|
||||
replace_str = "\\'\\'\\'"
|
||||
docstring = docstring.replace(quote, replace_str)
|
||||
replace_str = "\\'''"
|
||||
|
||||
docstring = docstring.replace(quote, replace_str)
|
||||
docstring = docstring.replace('\t', '\\\\')
|
||||
|
||||
lines = docstring.split('\n')
|
||||
|
Reference in New Issue
Block a user