From 792ef5b5b86edeec87bdc94bdca9aadae33517d6 Mon Sep 17 00:00:00 2001 From: rocky Date: Fri, 24 May 2019 11:03:44 -0400 Subject: [PATCH] Simplfy - TODO fix unicode in docstrings --- test/bytecode_2.4_run/00_docstring.pyc | Bin 0 -> 1352 bytes test/simple_source/stmts/00_docstring.py | 13 +++++++++++++ uncompyle6/semantics/helper.py | 13 +++---------- 3 files changed, 16 insertions(+), 10 deletions(-) create mode 100644 test/bytecode_2.4_run/00_docstring.pyc 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 0000000000000000000000000000000000000000..2eb5e8ef5c01d97910b262277e2e9d854da4972b GIT binary patch literal 1352 zcmb_c&5qMR44!EU3q{KbX|GoH&=i$yyC<|#3kV@`Ks^Lbs3^*2rfrt|DdX@fF2IAp z+i~Uzu%}Vm4Mi&u8O5<3`j?yvwoQ?{DiSV_^BuUAs01vbJF_|A47ja_3QXgLKm($EH2NR~%^1 z@S-Ei10hk0&ypS;k&wG1T5iX>owmDc-J<2*e&=u0Cp~B`-}kLXrA?<(h>Xz{!WbqK z81D-zYMF_?Dg^tN6YBY(`#1EoM6Y)5$l~!k)oOWsGS9Q*X zcsqoK&~LnJ*K)h>}#R$!G`>qRvVr>> 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')