From 8b58339eb2939da4df822f7ea457b44e120fad45 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 11 Dec 2016 14:39:01 +0200 Subject: Issue #28512: Fixed setting the offset attribute of SyntaxError by PyErr_SyntaxLocationEx() and PyErr_SyntaxLocationObject(). --- Lib/test/test_symtable.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'Lib/test/test_symtable.py') diff --git a/Lib/test/test_symtable.py b/Lib/test/test_symtable.py index c5d7facfdb..fbb1bdc9de 100644 --- a/Lib/test/test_symtable.py +++ b/Lib/test/test_symtable.py @@ -148,15 +148,17 @@ class SymtableTest(unittest.TestCase): def test_filename_correct(self): ### Bug tickler: SyntaxError file name correct whether error raised ### while parsing or building symbol table. - def checkfilename(brokencode): + def checkfilename(brokencode, offset): try: symtable.symtable(brokencode, "spam", "exec") except SyntaxError as e: self.assertEqual(e.filename, "spam") + self.assertEqual(e.lineno, 1) + self.assertEqual(e.offset, offset) else: self.fail("no SyntaxError for %r" % (brokencode,)) - checkfilename("def f(x): foo)(") # parse-time - checkfilename("def f(x): global x") # symtable-build-time + checkfilename("def f(x): foo)(", 14) # parse-time + checkfilename("def f(x): global x", 10) # symtable-build-time symtable.symtable("pass", b"spam", "exec") with self.assertRaises(TypeError): symtable.symtable("pass", bytearray(b"spam"), "exec") -- cgit v1.2.1