Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-131927: Prevent emitting optimizer warnings twice in the REPL #131993

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 12 commits into from
Apr 12, 2025
Prev Previous commit
Next Next commit
Add more tests
  • Loading branch information
tomasr8 committed Apr 12, 2025
commit 97d028e239a44f5c9d9c9a6da80661bd41c79c63
18 changes: 18 additions & 0 deletions 18 Lib/test/test_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1636,6 +1636,24 @@ async def name_4():
pass
[[]]

def test_compile_warnings(self):
# See gh-131927
# Compile warnings originating from the same file and
# line are now only emitted once.
with warnings.catch_warnings(record=True) as caught:
warnings.simplefilter("default")
compile('1 is 1', '<stdin>', 'eval')
compile('1 is 1', '<stdin>', 'eval')

self.assertEqual(len(caught), 1)

with warnings.catch_warnings(record=True) as caught:
warnings.simplefilter("always")
compile('1 is 1', '<stdin>', 'eval')
compile('1 is 1', '<stdin>', 'eval')

self.assertEqual(len(caught), 2)

class TestBooleanExpression(unittest.TestCase):
class Value:
def __init__(self):
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.