Title: unable to comment out r'\u' string with triple quote marks
Type: compile error Stage:
Components: Interpreter Core Versions: Python 3.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Elmar Bucher, eric.smith, veky
Priority: normal Keywords:

Created on 2020-04-10 23:03 by Elmar Bucher, last changed 2020-04-11 01:33 by veky.

Messages (3)
msg366166 - (view) Author: Elmar Bucher (Elmar Bucher) Date: 2020-04-10 23:03
When I try to comment out this little code by triple quotation, 
I run into
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 29-30: truncated \uXXXX escape

ls_tex = []

Basically it is not possible to use r'\u' and comment it out with ''' or """. I think this should not be the case, this is an interpreter error.
msg366169 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2020-04-10 23:44
This basically comes down to """\u""" not being a valid string.

I'm not sure why you'd expect this to work: triple quoted strings are not designed as a general purpose "comment out" facility, and as you've discovered, they don't work that way. What's inside a triple quoted string must be interpretable as a python string, which in this case it is not.
msg366175 - (view) Author: Vedran Čačić (veky) * Date: 2020-04-11 01:33
This "bug" is reported at least once a year, by different people. Maybe we should put something in the documentation, to the effect that

a) as Eric said, triple-quoted strings are not (meant to be used as) comments

b) if you nonetheless really want to use them that way, in most cases you _can_ get away with using r'''...'''.
Date User Action Args
2020-04-11 01:33:04vekysetnosy: + veky
messages: + msg366175
2020-04-10 23:44:37eric.smithsetnosy: + eric.smith
messages: + msg366169
2020-04-10 23:24:41Elmar Buchersettype: compile error
2020-04-10 23:03:11Elmar Buchercreate