Opened 7 years ago
Closed 7 years ago
#5821 closed defect (fixed)
[with patch, positive review] preparser incorrectly handles backslash operator inside strings (sometimes)
Reported by: | cwitty | Owned by: | was |
---|---|---|---|
Priority: | major | Milestone: | sage-3.4.2 |
Component: | user interface | Keywords: | preparser |
Cc: | robertwb | Merged in: | |
Authors: | Reviewers: | ||
Report Upstream: | Work issues: | ||
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
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() * ".
Attachments (1)
Change History (5)
comment:1 Changed 7 years ago by robertwb
Changed 7 years ago by robertwb
comment:2 Changed 7 years ago by robertwb
- Summary changed from preparser incorrectly handles backslash operator inside strings (sometimes) to [with patch, needs review] preparser incorrectly handles backslash operator inside strings (sometimes)
comment:3 Changed 7 years ago by cwitty
- Summary changed from [with patch, needs review] preparser incorrectly handles backslash operator inside strings (sometimes) to [with patch, positive review] preparser incorrectly handles backslash operator inside strings (sometimes)
Code looks good (and fixes the problem); doctests pass.
Positive review.
comment:4 Changed 7 years ago by mabshoff
- Milestone changed from sage-4.0 to sage-3.4.2
- Resolution set to fixed
- Status changed from new to closed
Merged in Sage 3.4.2.alpha0.
Cheers,
Michael
Note: See
TracTickets for help on using
tickets.
It appears that even in raw strings the backslash escapes a potential end quote...
http://docs.python.org/reference/lexical_analysis.html