Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
20f1fb4
store __module__ into a variable and restore after __new__ method cre…
srinivasreddy Jan 13, 2025
75c1663
Merge branch 'main' into gh_128772
srinivasreddy Jan 15, 2025
9d0e70f
Preserve __module__
srinivasreddy Jan 15, 2025
86924f2
Reintroduce space
srinivasreddy Jan 15, 2025
a7b4e83
Merge branch 'main' into gh_128772
srinivasreddy Jan 16, 2025
aab2f5b
Merge branch 'main' into gh_128772
srinivasreddy Jan 16, 2025
382299e
Add test case for help(....) function
srinivasreddy Jan 16, 2025
5b879a3
Fix indentation
srinivasreddy Jan 16, 2025
5595a8e
Fix test failure
srinivasreddy Jan 16, 2025
4b3db9e
Update test cases
srinivasreddy Jan 16, 2025
35731f3
Update tests
srinivasreddy Jan 16, 2025
eb5cb3b
order imports
srinivasreddy Jan 16, 2025
7be5d8a
Improve test cases
srinivasreddy Jan 16, 2025
4752d38
Improve test case
srinivasreddy Jan 16, 2025
8b54982
Revert the code since it is in wrong place
srinivasreddy Jan 17, 2025
3c2c9d3
Move the test case to here from Lib/idlelib/idle_test/test_warning.py
srinivasreddy Jan 17, 2025
d48801e
Add blurb
srinivasreddy Jan 17, 2025
08228dc
Update description
srinivasreddy Jan 17, 2025
09d4fa1
Merge branch 'main' into gh_128772
srinivasreddy Jan 17, 2025
57e01d8
Update Misc/NEWS.d/next/Library/2025-01-17-13-38-12.gh-issue-128772.8…
srinivasreddy Jan 21, 2025
2c0b399
Address review comments
srinivasreddy Jan 21, 2025
0eaefef
Revert the change
srinivasreddy Jan 21, 2025
3edb9b1
Remove creating an instance B()
srinivasreddy Jan 21, 2025
96bab8d
Address review comments. Move the deprecated class to a separate data…
srinivasreddy Jan 21, 2025
84175fc
Fix failure
srinivasreddy Jan 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Preserve __module__
  • Loading branch information
srinivasreddy committed Jan 15, 2025
commit 9d0e70f78a132ee663e06ae6dfb733367c85e5ac
5 changes: 2 additions & 3 deletions Lib/warnings.py
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be that the existing __module__ is overridden on __new__ and __init_subclass__ here, if it already exists.

Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,6 @@ def __call__(self, arg, /):
import functools
from types import MethodType

wrapper_module = arg.__module__
original_new = arg.__new__

@functools.wraps(original_new)
Expand All @@ -611,9 +610,8 @@ def __new__(cls, *args, **kwargs):
raise TypeError(f"{cls.__name__}() takes no arguments")
else:
return original_new(cls)

__new__.__module__ = arg.__module__
arg.__new__ = staticmethod(__new__)
arg.__module__ = wrapper_module

original_init_subclass = arg.__init_subclass__
# We need slightly different behavior if __init_subclass__
Expand All @@ -637,6 +635,7 @@ def __init_subclass__(*args, **kwargs):

arg.__init_subclass__ = __init_subclass__

__init_subclass__.__module__ = arg.__module__
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move this one below, to be next to the other __init_subclass__ change

arg.__deprecated__ = __new__.__deprecated__ = msg
__init_subclass__.__deprecated__ = msg
return arg
Expand Down