You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It just so happens that my triple-quoted string itself contains a single-quoted string with newline characters. I would have expected textwrap.dedent to ignore these newline characters inside single or double quoted strings contained in the larger triple-quoted string.
The semantics of this bug may be slightly different than https://bugs.python.org/issue19479 "textwrap.dedent doesn't work properly with strings containing CRLF", so I'm raising a new issue.
I am seeing this in a module I'm writing that emits synthetic python code that is subsequently passed back into the interpreter via "exec".
Python 3.4.1 (default, Nov 12 2014, 13:34:29)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from textwrap import dedent
>>> s ='''
... 'my_key' : r'my value which contains \n character'
... '''
>>> s
"\n 'my_key' : r'my value which contains \n character'\n"
>>> dedent(s)
"\n 'my_key' : r'my value which contains \ncharacter'\n"
>>>
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: