reject non-docs strings between future imports (closes #17434) · python/cpython@2d6acd2 · GitHub
Skip to content

Commit 2d6acd2

Browse files
committed
reject non-docs strings between future imports (closes #17434)
1 parent 694bafa commit 2d6acd2

4 files changed

Lines changed: 28 additions & 11 deletions

File tree

‎Lib/test/badsyntax_future10.py‎

Lines changed: 3 additions & 0 deletions

‎Lib/test/test_future.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ def test_badfuture9(self):
8282
else:
8383
self.fail("expected exception didn't occur")
8484

85+
def test_badfuture10(self):
86+
try:
87+
from test import badsyntax_future10
88+
except SyntaxError as msg:
89+
self.assertEqual(get_error_location(msg), ("badsyntax_future10", '3'))
90+
else:
91+
self.fail("expected exception didn't occur")
92+
8593
def test_parserhack(self):
8694
# test that the parser.c::future_hack function works as expected
8795
# Note: although this test must pass, it's not testing the original

‎Misc/NEWS‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ What's New in Python 3.4.0 Alpha 1?
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #17434: Properly raise a SyntaxError when a string occurs between future
14+
imports.
15+
1316
- Issue #17117: Import and @importlib.util.set_loader now set __loader__ when
1417
it has a value of None or the attribute doesn't exist.
1518

‎Python/future.c‎

Lines changed: 14 additions & 11 deletions

0 commit comments

Comments
 (0)