diff --git a/test/bytecode_2.4_run/00_docstring.pyc b/test/bytecode_2.4_run/00_docstring.pyc new file mode 100644 index 00000000..2eb5e8ef Binary files /dev/null and b/test/bytecode_2.4_run/00_docstring.pyc differ diff --git a/test/simple_source/stmts/00_docstring.py b/test/simple_source/stmts/00_docstring.py index d8f2a077..c8e83309 100644 --- a/test/simple_source/stmts/00_docstring.py +++ b/test/simple_source/stmts/00_docstring.py @@ -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() diff --git a/uncompyle6/semantics/helper.py b/uncompyle6/semantics/helper.py index f941831e..31bb7be0 100644 --- a/uncompyle6/semantics/helper.py +++ b/uncompyle6/semantics/helper.py @@ -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')