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

preparser incorrectly handles backslash operator inside strings (sometimes) #5821

Closed
sagetrac-cwitty mannequin opened this issue Apr 19, 2009 · 4 comments
Closed

preparser incorrectly handles backslash operator inside strings (sometimes) #5821

sagetrac-cwitty mannequin opened this issue Apr 19, 2009 · 4 comments

Comments

@sagetrac-cwitty
Copy link
Mannequin

sagetrac-cwitty mannequin commented Apr 19, 2009

When reviewing #5595, I tried typing this:

sage: import re
sage: dep_regex = re.compile(r'^ *(?:(?:cimport +([\w\. ,]+))|(?:from +(\w+) +cimport)|(?:include *[\'"]([^\'"]+)[\'"])|(?:cdef *extern *from *[\'"]([^\'"]+)[\'"]))', re.M)
------------------------------------------------------------
   File "<ipython console>", line 1
     dep_regex = re.compile(r'^ *(?:(?:cimport +([\w\. ,]+))|(?:from +(\w+) +cimport)|(?:include *[\'"]([^\'"]+)[ * BackslashOperator() * '"])|(?:cdef *extern *from *[\'"]([^\'"]+)[\'"]))', re.M)
                                                                                                                                                                          ^
SyntaxError: invalid syntax

Note that the preparser has turned a backslash from the middle of the regular expression into " * BackslashOperator() * ".

CC: @robertwb

Component: user interface

Keywords: preparser

Issue created by migration from https://trac.sagemath.org/ticket/5821

@sagetrac-cwitty sagetrac-cwitty mannequin added this to the sage-4.0 milestone Apr 19, 2009
@robertwb
Copy link
Contributor

comment:1

It appears that even in raw strings the backslash escapes a potential end quote...

http://docs.python.org/reference/lexical_analysis.html

@robertwb
Copy link
Contributor

comment:2

Attachment: 5821-preparse-raw.patch.gz

@sagetrac-cwitty
Copy link
Mannequin Author

sagetrac-cwitty mannequin commented Apr 19, 2009

comment:3

Code looks good (and fixes the problem); doctests pass.

Positive review.

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Apr 23, 2009

comment:4

Merged in Sage 3.4.2.alpha0.

Cheers,

Michael

@sagetrac-mabshoff sagetrac-mabshoff mannequin closed this as completed Apr 23, 2009
@sagetrac-mabshoff sagetrac-mabshoff mannequin modified the milestones: sage-4.0, sage-3.4.2 Apr 23, 2009
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants