Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to comment out r'\u' string with triple quote marks #84431

Closed
ElmarBucher mannequin opened this issue Apr 10, 2020 · 3 comments
Closed

unable to comment out r'\u' string with triple quote marks #84431

ElmarBucher mannequin opened this issue Apr 10, 2020 · 3 comments
Labels
3.7 (EOL) end of life build The build process and cross-build interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@ElmarBucher
Copy link
Mannequin

ElmarBucher mannequin commented Apr 10, 2020

BPO 40250
Nosy @ericvsmith, @vedgar

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:

assignee = None
closed_at = <Date 2022-01-23.19:13:47.139>
created_at = <Date 2020-04-10.23:03:11.676>
labels = ['interpreter-core', 'invalid', 'build', '3.7']
title = "unable to comment out r'\\u' string with triple quote marks"
updated_at = <Date 2022-01-23.19:13:47.139>
user = 'https://bugs.python.org/ElmarBucher'

bugs.python.org fields:

activity = <Date 2022-01-23.19:13:47.139>
actor = 'iritkatriel'
assignee = 'none'
closed = True
closed_date = <Date 2022-01-23.19:13:47.139>
closer = 'iritkatriel'
components = ['Interpreter Core']
creation = <Date 2020-04-10.23:03:11.676>
creator = 'Elmar Bucher'
dependencies = []
files = []
hgrepos = []
issue_num = 40250
keywords = []
message_count = 3.0
messages = ['366166', '366169', '366175']
nosy_count = 3.0
nosy_names = ['eric.smith', 'veky', 'Elmar Bucher']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'compile error'
url = 'https://bugs.python.org/issue40250'
versions = ['Python 3.7']

@ElmarBucher
Copy link
Mannequin Author

ElmarBucher mannequin commented Apr 10, 2020

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 = []
ls_tex.append(r'\usepackage{mathtools}')
print(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.

@ElmarBucher ElmarBucher mannequin added 3.7 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs) build The build process and cross-build labels Apr 10, 2020
@ericvsmith
Copy link
Member

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.

@vedgar
Copy link
Mannequin

vedgar mannequin commented Apr 11, 2020

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'''...'''.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.7 (EOL) end of life build The build process and cross-build interpreter-core (Objects, Python, Grammar, and Parser dirs)
Projects
None yet
Development

No branches or pull requests

2 participants