PyErr_SyntaxLocationEx() and PyErr_SyntaxLocationObject().
import unittest
from test import support
+ import os
import re
-rx = re.compile('\((\S+).py, line (\d+)')
+rx = re.compile(r'\((\S+).py, line (\d+)')
def get_error_location(msg):
mo = rx.search(str(msg))
global a
global b
"""
-- check_syntax_error(self, prog_text_1)
++ check_syntax_error(self, prog_text_1, lineno=4, offset=4)
def test2(self):
prog_text_2 = """\
print(x)
global x
"""
-- check_syntax_error(self, prog_text_2)
++ check_syntax_error(self, prog_text_2, lineno=3, offset=4)
def test3(self):
prog_text_3 = """\
x = 2
global x
"""
-- check_syntax_error(self, prog_text_3)
++ check_syntax_error(self, prog_text_3, lineno=4, offset=4)
def test4(self):
prog_text_4 = """\
self.assertEqual(cm.exception.errno, errno.EBADF)
def test_check_syntax_error(self):
- support.check_syntax_error(self, "def class")
+ support.check_syntax_error(self, "def class", lineno=1, offset=9)
- self.assertRaises(AssertionError, support.check_syntax_error, self, "1")
- #with self.assertRaises(AssertionError):
- #support.check_syntax_error(self, "x=1")
+ with self.assertRaises(AssertionError):
+ support.check_syntax_error(self, "x=1")
def test_CleanImport(self):
import importlib
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):
+ with self.assertWarns(DeprecationWarning), \
+ self.assertRaises(TypeError):
symtable.symtable("pass", bytearray(b"spam"), "exec")
- symtable.symtable("pass", memoryview(b"spam"), "exec")
+ with self.assertWarns(DeprecationWarning):
+ symtable.symtable("pass", memoryview(b"spam"), "exec")
with self.assertRaises(TypeError):
symtable.symtable("pass", list(b"spam"), "exec")
Core and Builtins
-----------------
+ - Issue #28512: Fixed setting the offset attribute of SyntaxError by
+ PyErr_SyntaxLocationEx() and PyErr_SyntaxLocationObject().
+
+- Issue #28918: Fix the cross compilation of xxlimited when Python has been
+ built with Py_DEBUG defined.
+
+- Issue #28731: Optimize _PyDict_NewPresized() to create correct size dict.
+ Improve speed of dict literal with constant keys up to 30%.
+
- Issue #5322: Fixed setting __new__ to a PyCFunction inside Python code.
Original patch by Andreas Stührk.