Skip to content

Commit 20f1fb4

Browse files
committed
store __module__ into a variable and restore after __new__ method creation is done
1 parent ddd9599 commit 20f1fb4

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Lib/warnings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ def __call__(self, arg, /):
585585
import functools
586586
from types import MethodType
587587

588+
wrapper_module = arg.__module__
588589
original_new = arg.__new__
589590

590591
@functools.wraps(original_new)
@@ -600,6 +601,7 @@ def __new__(cls, *args, **kwargs):
600601
return original_new(cls)
601602

602603
arg.__new__ = staticmethod(__new__)
604+
arg.__module__ = wrapper_module
603605

604606
original_init_subclass = arg.__init_subclass__
605607
# We need slightly different behavior if __init_subclass__

0 commit comments

Comments
 (0)