Skip to content

Commit fb7a1f8

Browse files
trotterdylanwhitequark
authored and
whitequark
committedJan 25, 2017
Accept 1- and 2-digit octal sequences in string literals.
Fixes #9.
1 parent a82d05d commit fb7a1f8

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed
 

Diff for: ‎pythonparser/lexer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def __init__(self, source_buffer, version, diagnostic_engine, interactive=False)
187187
_lex_escape_re = re.compile(r"""
188188
\\(?:
189189
([\n\\'"abfnrtv]) # 1 single-char
190-
| ([0-7]{3}) # 2 oct
190+
| ([0-7]{1,3}) # 2 oct
191191
| x([0-9A-Fa-f]{2}) # 3 hex
192192
)
193193
""", re.VERBOSE)

Diff for: ‎pythonparser/test/test_lexer.py

+5
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,11 @@ def test_string_literal(self):
184184
"strdata", "\n",
185185
"strend", None)
186186

187+
self.assertLexes(r"'\0 \10 \010'",
188+
"strbegin", "",
189+
"strdata", "\x00 \x08 \x08",
190+
"strend", None)
191+
187192
self.assertDiagnoses(
188193
"'",
189194
[("fatal", "unterminated string", (0, 1))])

0 commit comments

Comments
 (0)