8000 gh-125331: Allow the parser to activate future imports on the fly by pablogsal · Pull Request #125482 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-125331: Allow the parser to activate future imports on the fly #125482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Feb 14, 2025
Prev Previous commit
fixup! Update Misc/NEWS.d/next/Core_and_Builtins/2024-10-29-23-30-35.…
…gh-issue-125331.quKQ7V.rst
  • Loading branch information
pablogsal committed Feb 13, 2025
commit 76d8c9f56382f13b13bce59b2c0c5416bef2bac0
13 changes: 13 additions & 0 deletions Lib/test/test_flufl.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@ def test_barry_as_bdfl_look_ma_with_no_compiler_flags(self):
self.assertEqual(cm.exception.lineno, 1)
self.assertEqual(cm.exception.offset, len(code) - 4)

def test_barry_as_bdfl_relative_import(self):
code = "from .__future__ import barry_as_FLUFL;2 {0} 3"
compile(code.format('!='), '<FLUFL test>', 'exec')
with self.assertRaises(SyntaxError) as cm:
compile(code.format('<>'), '<BDFL test>', 'exec')
self.assertRegex(str(cm.exception), "<BDFL test>")
self.assertIn('2 <> 3', cm.exception.text)
self.assertEqual(cm.exception.filename, '<BDFL test>')
self.assertEqual(cm.exception.lineno, 1)
self.assertEqual(cm.exception.offset, len(code) - 4)




if __name__ == '__main__':
unittest.main()
Loading
0