62 lines
2.7 KiB
Diff
62 lines
2.7 KiB
Diff
From 2129f5fb1ec2d06000f10c96510874c5303d9f8c Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Ville=20Skytt=C3=A4?= <ville.skytta@iki.fi>
|
|
Date: Sun, 5 Mar 2017 04:52:22 +0200
|
|
Subject: [PATCH] Python 3.6 invalid escape sequence deprecation fixes (#177)
|
|
|
|
https://docs.python.org/3/whatsnew/3.6.html#deprecated-python-behavior
|
|
---
|
|
pycparser/c_lexer.py | 4 ++--
|
|
tests/test_c_lexer.py | 8 ++++----
|
|
tests/test_c_parser.py | 2 +-
|
|
4 files changed, 8 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/pycparser/c_lexer.py b/pycparser/c_lexer.py
|
|
index 00dcd97..d9941c1 100644
|
|
--- a/pycparser/c_lexer.py
|
|
+++ b/pycparser/c_lexer.py
|
|
@@ -52,8 +52,8 @@ def __init__(self, error_func, on_lbrace_func, on_rbrace_func,
|
|
# Allow either "# line" or "# <num>" to support GCC's
|
|
# cpp output
|
|
#
|
|
- self.line_pattern = re.compile('([ \t]*line\W)|([ \t]*\d+)')
|
|
- self.pragma_pattern = re.compile('[ \t]*pragma\W')
|
|
+ self.line_pattern = re.compile(r'([ \t]*line\W)|([ \t]*\d+)')
|
|
+ self.pragma_pattern = re.compile(r'[ \t]*pragma\W')
|
|
|
|
def build(self, **kwargs):
|
|
""" Builds the lexer from the specification. Must be
|
|
diff --git a/tests/test_c_lexer.py b/tests/test_c_lexer.py
|
|
index f965b24..11c7b26 100644
|
|
--- a/tests/test_c_lexer.py
|
|
+++ b/tests/test_c_lexer.py
|
|
@@ -430,12 +430,12 @@ def test_char_constants(self):
|
|
self.assertLexerError("'b\n", ERR_UNMATCHED_QUOTE)
|
|
|
|
self.assertLexerError("'jx'", ERR_INVALID_CCONST)
|
|
- self.assertLexerError("'\*'", ERR_INVALID_CCONST)
|
|
+ self.assertLexerError(r"'\*'", ERR_INVALID_CCONST)
|
|
|
|
def test_string_literals(self):
|
|
- self.assertLexerError('"jx\9"', ERR_STRING_ESCAPE)
|
|
- self.assertLexerError('"hekllo\* on ix"', ERR_STRING_ESCAPE)
|
|
- self.assertLexerError('L"hekllo\* on ix"', ERR_STRING_ESCAPE)
|
|
+ self.assertLexerError(r'"jx\9"', ERR_STRING_ESCAPE)
|
|
+ self.assertLexerError(r'"hekllo\* on ix"', ERR_STRING_ESCAPE)
|
|
+ self.assertLexerError(r'L"hekllo\* on ix"', ERR_STRING_ESCAPE)
|
|
|
|
def test_preprocessor(self):
|
|
self.assertLexerError('#line "ka"', ERR_FILENAME_BEFORE_LINE)
|
|
diff --git a/tests/test_c_parser.py b/tests/test_c_parser.py
|
|
index 95ae865..0835013 100755
|
|
--- a/tests/test_c_parser.py
|
|
+++ b/tests/test_c_parser.py
|
|
@@ -1718,7 +1718,7 @@ def test_whole_file_with_stdio(self):
|
|
|
|
self.assertTrue(isinstance(p.ext[0], Typedef))
|
|
self.assertEqual(p.ext[0].coord.line, 213)
|
|
- self.assertEqual(p.ext[0].coord.file, "D:\eli\cpp_stuff\libc_include/stddef.h")
|
|
+ self.assertEqual(p.ext[0].coord.file, r"D:\eli\cpp_stuff\libc_include/stddef.h")
|
|
|
|
self.assertTrue(isinstance(p.ext[-1], FuncDef))
|
|
self.assertEqual(p.ext[-1].coord.line, 15)
|