Commit 66b71f8c authored by Carl Friedrich Bolz-Tereick's avatar Carl Friedrich Bolz-Tereick
Browse files

fix bug in 1138b6754bdd: the "if" of an elif chain was moved, attaching the

elif to the previous if and breaking "once" in the process, under some
circumstances

--HG--
branch : release-pypy3.7-v7.x
parent fb22c554358b
Pipeline #27859 passed with stage
in 28 minutes and 50 seconds
......@@ -323,7 +323,8 @@ def do_warn_explicit(space, w_category, w_message, context_w,
if action != 'always':
if not space.is_w(w_registry, space.w_None):
space.setitem(w_registry, w_key, space.w_True)
elif action == 'once':
if action == 'once':
if space.is_w(w_registry, space.w_None):
w_registry = get_once_registry(space)
warned = update_registry(space, w_registry, w_text, w_category)
......
......@@ -173,3 +173,17 @@ def test_issue31285():
'eggs', UserWarning, 'bar', 1,
module_globals={'__loader__': get_bad_loader(42),
'__name__': 'foobar'})
def test_once_is_not_broken():
def f():
warnings.warn("deprecated", DeprecationWarning, 2)
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("once")
assert len(w) == 0
f()
assert len(w) == 1
f()
assert len(w) == 1
f()
assert len(w) == 1
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment