]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #28512: Fixed setting the offset attribute of SyntaxError by
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 11 Dec 2016 12:43:18 +0000 (14:43 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Sun, 11 Dec 2016 12:43:18 +0000 (14:43 +0200)
PyErr_SyntaxLocationEx() and PyErr_SyntaxLocationObject().

1  2 
Lib/test/support/__init__.py
Lib/test/test_future.py
Lib/test/test_global.py
Lib/test/test_support.py
Lib/test/test_symtable.py
Lib/test/test_syntax.py
Misc/NEWS
Python/errors.c

Simple merge
index 213b2ba0755f93ed60f28fea886cb958ad433159,7b072ad897bb9f9d3bf703044b62be34fb617c8c..2f1c410b1bfa255dd6200d30a88a4a6fb3d58b8e
@@@ -2,9 -2,10 +2,10 @@@
  
  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))
index 37ec67255a559a8db6ce76ce3effea9d0d7260a2,37ec67255a559a8db6ce76ce3effea9d0d7260a2..9eeccf12506f359f1398e52e16bb08590662e4b7
@@@ -24,7 -24,7 +24,7 @@@ def wrong1()
      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 = """\
@@@ -32,7 -32,7 +32,7 @@@ def wrong2()
      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 = """\
@@@ -41,7 -41,7 +41,7 @@@ def wrong3()
      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 = """\
index 553822b5823e654aa60fab81117a96938ee11a39,5e0f990e400045369fe750beba410bfaa7e575ea..e83a4d6426a8b2d05517eb76c77bb4e5220afd73
@@@ -240,9 -240,10 +240,9 @@@ class TestSupport(unittest.TestCase)
          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
index 30471653c36c2c5cf98aa777116fd5e7f8ae4120,fbb1bdc9de4595ee35d57d5ea9516b0e5c8f201d..dfaee173ef725bf2372283010f34ac956212131f
@@@ -164,16 -153,16 +164,18 @@@ class SymtableTest(unittest.TestCase)
                  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")
  
Simple merge
diff --cc Misc/NEWS
index 5c323a1038d1e0ea00794bc5e2c62ea7e9d46c35,3d664efeb6712356db09b8da9390f8120203a459..8db9170158ba8f50a94afa33eafaa396b2f2093f
+++ b/Misc/NEWS
@@@ -10,12 -10,9 +10,15 @@@ What's New in Python 3.6.1 release cand
  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.
  
diff --cc Python/errors.c
Simple merge