Simplfy - TODO fix unicode in docstrings

This commit is contained in:
rocky
2019-05-24 11:03:44 -04:00
parent 47ed0795b2
commit 792ef5b5b8
3 changed files with 16 additions and 10 deletions

Binary file not shown.

View File

@@ -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()

View File

@@ -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')