Commit Graph

76 Commits

Author SHA1 Message Date
Jacob Austin Lincoln
70748bdbea gh-131116: Fix inspect.getdoc() to work with cached_property objects (GH-131165) 2025-11-12 10:07:21 +00:00
Serhiy Storchaka
7906f4d96a gh-132686: Add parameters inherit_class_doc and fallback_to_class_doc for inspect.getdoc() (GH-132691) 2025-11-12 00:01:25 +02:00
Serhiy Storchaka
f4104f5d74 gh-139783: Fix inspect.getsourcelines() for the case when a decorator is followed by a comment or an empty line (GH-139836) 2025-10-10 10:51:24 +03:00
sobolevn
7c70cc5c23 gh-133210: Fix test_inspect without docstrings (#139651) 2025-10-06 19:48:50 +03:00
sobolevn
f5fa336579 gh-138729: Cover inspect.formatannotationrelativeto with tests (#138730) 2025-09-10 16:06:16 +03:00
Ju4tCode
025a2135ef gh-137317: Fix inspect.signature() for class with wrapped __init__ or __new__ (GH-137862)
Fixed several cases where __init__, __new__ or metaclass` __call__ is a descriptor
that returns a wrapped function.
2025-08-28 17:57:53 +03:00
Serhiy Storchaka
eae9d7de1c gh-137477: Fix inspect.getblock() for generator expressions (GH-137488)
This fixes also inspect.getsourcelines() and inspect.getsource().
2025-08-20 16:18:08 +03:00
Serhiy Storchaka
046a4e39b3 gh-136571: Convert more code in datetime to Argument Clinic (GH-136573)
This adds signatures for some classes and methods.

date.fromisocalendar() can now raise OverflowError for arguments that
don't fit in the C int.
2025-08-09 18:25:49 +00:00
Peter Bierma
8f59fbb082 gh-136492: Add FrameLocalsProxyType to types (GH-136546)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-07-20 20:49:00 +02:00
Serhiy Storchaka
be2c3d284e gh-136549: Fix signature of threading.excepthook() (GH-136559) 2025-07-12 18:54:26 +03:00
Jelle Zijlstra
797abd1f7f gh-134657: Remove newly added private names from asyncio.__all__ (#134665) 2025-07-09 13:25:46 +05:30
Hood Chatham
ce58afb400 gh-127146: Emscripten: Fix test failure due to missing os.link (#135626)
Check for existence of os.link, rather than assuming it exists.
2025-06-18 03:19:23 +00:00
Serhiy Storchaka
2602d8ae98 gh-71339: Use new assertion methods in tests (GH-129046) 2025-05-22 13:17:22 +03:00
Jelle Zijlstra
cb6596c6aa gh-132493: Remove __annotations__ usage in inspect._signature_is_functionlike (#133415)
This check is potentially problematic because it could force evaluation of
annotations unnecessarily. This doesn't trigger for builtin objects (functions,
classes, or modules) with annotations, but it could trigger for third-party objects.

The check was not particularly useful anyway, because it succeeds if ``__annotations__``
is a dict or None, so the only thing this did was guard against objects that have an
``__annotations__`` attribute that is of some other type. That doesn't seem particularly
useful, so I just removed the check.
2025-05-09 18:42:53 -07:00
Bénédikt Tran
5044e85265 gh-133644: Remove deprecated Python initialization getter functions (#133661)
Remove functions:

* Py_GetExecPrefix()
* Py_GetPath()
* Py_GetPrefix()
* Py_GetProgramFullPath()
* Py_GetProgramName()
* Py_GetPythonHome()
2025-05-09 11:39:23 +00:00
Serhiy Storchaka
5a57248b22 gh-81793: Always call linkat() from os.link(), if available (GH-132517)
This fixes os.link() on platforms (like Linux and OpenIndiana) where the
system link() function does not follow symlinks.

* On Linux, it now follows symlinks by default and if
  follow_symlinks=True is specified.
* On Windows, it now raises error if follow_symlinks=True is passed.
* On macOS, it now raises error if follow_symlinks=False is passed and
  the system linkat() function is not available at runtime.
* On other platforms, it now raises error if follow_symlinks is passed
  with a value that does not match the system link() function behavior
  if if the behavior is not known.

Co-authored-by: Joachim Henke <37883863+jo-he@users.noreply.github.com>
Co-authored-by: Thomas Kluyver <takowl@gmail.com>
2025-05-04 17:24:10 +03:00
Xuehai Pan
b8633f9aca gh-119605: Respect follow_wrapped for __init__ and __new__ when getting class signature with inspect.signature (#132055) 2025-05-01 15:41:44 -07:00
sobolevn
27e011455d gh-133210: Fix test_inspect in --without-doc-strings mode (#133250) 2025-05-01 19:08:35 +03:00
Peter Bierma
8dfa840773 gh-127604: Add C stack dumps to faulthandler (#128159) 2025-04-21 20:48:02 +01:00
Jelle Zijlstra
ac14d4a23f gh-129463, gh-128593: Simplify ForwardRef (#129465) 2025-04-05 04:36:34 +00:00
Jelle Zijlstra
dc6d66f44c gh-105499: Merge typing.Union and types.UnionType (#105511)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Ken Jin <kenjin@python.org>
Co-authored-by: Carl Meyer <carl@oddbird.net>
2025-03-04 11:44:19 -08:00
Jelle Zijlstra
1d251b8339 gh-128184: Fix display of signatures with ForwardRefs (#130815)
Co-authored-by: sobolevn <mail@sobolevn.me>
2025-03-04 06:58:37 -08:00
Serhiy Storchaka
10b32054ad gh-127750: Restore inspect and pydoc support of singledispatchmethod (GH-130309)
The code is still flawed, because it does not recognize class and static
methods, and the first argument is not removed from the signature of
bound methods, but at least it does not worse than in 3.13 and older.
2025-02-20 11:08:49 +02:00
Jacob Walls
dab456dcef gh-130164: Fix inspect.Signature.bind() handling of positional-only args without defaults (GH-130192)
Follow-up to 9c15202.
2025-02-18 17:19:04 +02:00
Hugo van Kemenade
05d12eecbd gh-127873: Only check sys.flags.ignore_environment for PYTHON* env vars (#127877) 2025-01-21 16:10:08 +00:00
sobolevn
65b484db97 gh-128694: Fix (env changed) error in test_inspect (#128702) 2025-01-10 13:25:02 +03:00
Thomas Grainger
aab51c3414 gh-128265: Support WASI/Emscripten on PDB tests, by removing asyncio from pdb tests (#128264)
A part of `Lib/test/test_pdb.py` was previously unable to run on WASI/Emscripten
platforms because it lacked support for `asyncio`.
In fact, these tests could be rewritten without the `asyncio` framework because 
`test_pdb` tests the behavior of coroutines, which are not part of `asyncio`.

Now reliance on the availability of `asyncio` has been removed and
part of `test_pdb` that deals with coroutines working on WASI/Emscripten platforms.
2024-12-28 16:59:49 +02:00
Thomas Grainger
3f6a618e49 gh-127949: fix DeprecationWarning in test_inspect.py (#128215) 2024-12-24 15:13:31 +05:30
Kumar Aditya
5892853fb7 gh-127949: deprecate asyncio.set_event_loop_policy (#128024)
First step towards deprecating the asyncio policy system.
This deprecates `asyncio.set_event_loop_policy` and will be removed in Python 3.16.
2024-12-18 11:35:29 +05:30
Apostol Fet
1503fc8f88 gh-127610: Added validation for more than one var-positional and var-keyword parameters in inspect.Signature (GH-127657) 2024-12-08 12:05:15 +02:00
blhsing
83ba8c2bba gh-70764: inspect.getclosurevars now identifies global variables with LOAD_GLOBAL (#120143) 2024-11-05 15:53:54 -08:00
Sergey B Kirpichev
51ef54abc4 gh-125916: Adapt functools.reduce() to Argument Clinic (#125999) 2024-11-01 21:15:39 +01:00
Xuanteng Huang
35df4eb959 gh-126072: do not add None to co_consts if there is no docstring (GH-126101) 2024-10-30 09:01:09 +00:00
Zhikang Yan
dad3453129 gh-125633: Add function ispackage to stdlib inspect (#125634)
---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2024-10-27 14:57:43 +10:00
Sam Gross
332356b880 gh-125900: Clean-up logic around immortalization in free-threading (#125901)
* Remove `@suppress_immortalization` decorator
* Make suppression flag per-thread instead of per-interpreter
* Suppress immortalization in `eval()` to avoid refleaks in three tests
  (test_datetime.test_roundtrip, test_logging.test_config8_ok, and
   test_random.test_after_fork).
* frozenset() is constant, but not a singleton. When run multiple times,
  the test could fail due to constant interning.
2024-10-24 18:09:59 -04:00
Jelle Zijlstra
78406382c9 gh-101552: Allow pydoc to display signatures in source format (#124669)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-10-09 05:03:53 +00:00
Sergey B Kirpichev
eafd14fbe0 gh-116110: remove extra processing for the __signature__ attribute (GH-116234)
This is an alternative to GH-100168.
2024-10-08 12:36:03 -07:00
Serhiy Storchaka
69a4063ca5 gh-123339: Fix cases of inconsistency of __module__ and __firstlineno__ in classes (GH-123613)
* Setting the __module__ attribute for a class now removes the
  __firstlineno__ item from the type's dict.
* The _collections_abc and _pydecimal modules now completely replace the
  collections.abc and decimal modules after importing them. This
  allows to get the source of classes and functions defined in these
  modules.
* inspect.findsource() now checks whether the first line number for a
  class is out of bound.
2024-09-28 20:51:49 +03:00
dgpb
d9296529eb gh-119127: functools.partial placeholders (gh-119827) 2024-09-26 01:04:38 +00:00
Serhiy Storchaka
f88c14d412 gh-122981: Fix inspect.getsource() for generated classes with Python base classes (GH-123001)
Look up __firstlineno__ only in the class' dict, without searching in
base classes.
2024-08-20 20:10:15 +03:00
sobolevn
c15bfa9a71 gh-116789: Add more tests for inspect.getmembers (#116802) 2024-08-18 18:42:56 +03:00
Serhiy Storchaka
bb108580de gh-122087: Add tests for ismethoddescriptor() and isroutine() with partial objects (GH-122219) 2024-07-25 10:12:26 +03:00
Jelle Zijlstra
7b7b90d1ce gh-119180: Add annotationlib module to support PEP 649 (#119891)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-07-23 21:16:50 +00:00
Serhiy Storchaka
ff5806c78e gh-121027: Make the functools.partial object a method descriptor (GH-121089)
Co-authored-by: d.grigonis <dgrigonis@users.noreply.github.com>
2024-07-03 09:02:15 +03:00
Serhiy Storchaka
db96edd6d1 gh-121027: Add a future warning in functools.partial.__get__ (#121086) 2024-06-27 11:47:20 +00:00
Victor Stinner
e9f4d80fa6 gh-120417: Add #noqa: F401 to tests (#120627)
Ignore linter "imported but unused" warnings in tests when the linter
doesn't understand how the import is used.
2024-06-18 15:51:47 +00:00
Jan Kaliszewski
dacc5ac71a gh-120381: Fix inspect.ismethoddescriptor() (#120383)
The `inspect.ismethoddescriptor()` function did not check for the lack of
`__delete__()` and, consequently, erroneously returned True when applied
to *data* descriptors with only `__get__()` and `__delete__()` defined.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
2024-06-18 12:19:43 +00:00
Victor Stinner
f916b77fea gh-120417: Remove unused imports in tests (part 3) (#120631) 2024-06-17 21:04:58 +02:00
Alex Waygood
99d62f902e Add some more edge-case tests for inspect.get_annotations with eval_str=True (#120550) 2024-06-15 12:51:58 +00:00
Alex Waygood
42351c3b9a gh-114053: Fix bad interaction of PEP 695, PEP 563 and inspect.get_annotations (#120270) 2024-06-13 21:16:40 +00:00