Skip to content

Commit 8a4fb30

Browse files
committed
chore: update news and add comment
1 parent c5b53dc commit 8a4fb30

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Lib/inspect.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,10 +1917,14 @@ def _signature_get_user_defined_method(cls, method_name, *, follow_wrapper_chain
19171917
if meth is None:
19181918
return None
19191919

1920+
# NOTE: The meth may wraps a non-user-defined callable.
1921+
# In this case, we treat the meth as non-user-defined callable too.
1922+
# (e.g. cls.__new__ generated by @warnings.deprecated)
19201923
unwrapped_meth = None
19211924
if follow_wrapper_chains:
19221925
unwrapped_meth = unwrap(meth, stop=(lambda m: hasattr(m, "__signature__")
19231926
or _signature_is_builtin(m)))
1927+
19241928
if (isinstance(meth, _NonUserDefinedCallables)
19251929
or isinstance(unwrapped_meth, _NonUserDefinedCallables)):
19261930
# Once '__signature__' will be added to 'C'-level
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Fix the behavior when using :func:`inspect.signature` to get the signature
2-
for a class that uses descriptor on a wrapped :meth:`!__init__` methods.
1+
:func:`inspect.signature` now correctly handles classes that use a descriptor
2+
on a wrapped :meth:`!__init__` or :meth:`!__new__` method.

0 commit comments

Comments
 (0)