mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 03:04:38 +08:00
Extract the Python 3.14-compatible ordering fix from #8954. An existing Warning instance determines its own category, regardless of the category argument. Keep canonical invalid-category coverage and add only the missing instance case to the existing warnings snippet. Assisted-by: OpenAI Codex:model identifier unavailable
21 lines
452 B
Python
21 lines
452 B
Python
import _warnings
|
|
|
|
_warnings.warn("Test")
|
|
|
|
|
|
import warnings
|
|
|
|
|
|
class CustomWarning(UserWarning):
|
|
pass
|
|
|
|
|
|
for category in (None, DeprecationWarning, int, 42):
|
|
message = CustomWarning("sentinel")
|
|
with warnings.catch_warnings(record=True) as caught:
|
|
warnings.simplefilter("always")
|
|
warnings.warn(message, category)
|
|
assert len(caught) == 1
|
|
assert caught[0].message is message
|
|
assert caught[0].category is CustomWarning
|