| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
(#105274)
|
|
|
|
|
|
|
|
|
| |
(GH-104517) (#104557)
gh-75367: Fix data descriptor detection in inspect.getattr_static (GH-104517)
(cherry picked from commit 5e9f471e7db30893fb3f42681f17fdcdb70069ee)
Co-authored-by: Furkan Onder <furkanonder@protonmail.com>
Co-authored-by: Carl Meyer <carl@oddbird.net>
|
|
|
|
| |
default after pos-only with default (GH-103557) (#103675)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
handling (GH-98796) (#100392)
This makes a couple related changes to inspect.signature's behaviour
when parsing a signature from `__text_signature__`.
First, `inspect.signature` is documented as only raising ValueError or
TypeError. However, in some cases, we could raise RuntimeError. This PR
changes that, thereby fixing GH-83685.
(Note that the new ValueErrors in RewriteSymbolics are caught and then
reraised with a message)
Second, `inspect.signature` could randomly drop parameters that it
didn't understand (corresponding to `return None` in the `p` function).
This is the core issue in GH-85267. I think this is very surprising
behaviour and it seems better to fail outright.
Third, adding this new failure broke a couple tests. To fix them (and to
e.g. allow `inspect.signature(select.epoll.register)` as in GH-85267), I
add constant folding of a couple binary operations to RewriteSymbolics.
(There's some discussion of making signature expression evaluation
arbitrary powerful in GH-68155. I think that's out of scope. The
additional constant folding here is pretty straightforward, useful, and
not much of a slippery slope)
Fourth, while GH-85267 is incorrect about the cause of the issue, it turns
out if you had consecutive newlines in __text_signature__, you'd get
`tokenize.TokenError`.
Finally, the `if name is invalid:` code path was dead, since
`parse_name` never returned `invalid`..
(cherry picked from commit 79311cbfe718f17c89bab67d7f89da3931bfa2ac)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
|
|
|
|
|
| |
(cherry picked from commit 68e41295b8611a990de68f15c89f1eb3dea51867)
Co-authored-by: Carl Meyer <carl@oddbird.net>
|
|
|
|
|
| |
(cherry picked from commit dbf2faf579b4094387d65ee41f049456ca67c446)
Co-authored-by: Anton Ryzhov <anton@ryzhov.me>
|
|
|
|
|
|
| |
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
(cherry picked from commit d5fea01d9d439b1638cd8e5db19c33909841d86f)
Co-authored-by: Anh71me <iyumelive@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(GH-94460)
The inspect version was not working with unittest.mock.AsyncMock.
The fix introduces special-casing of AsyncMock in
`inspect.iscoroutinefunction` equivalent to the one
performed in `asyncio.iscoroutinefunction`.
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
(cherry picked from commit 4261b6bffc0b8bb5c6d4d80578a81b7520f4aefc)
Co-authored-by: Mehdi ABAAKOUK <sileht@sileht.net>
|
|
|
| |
Fixes #92062.
|
|
|
|
| |
information (GH-91531)
|
|
|
|
|
| |
cases where methodwrapper is given (GH-19261)
Automerge-Triggered-By: GH:isidentical
|
| |
|
| |
|
|
|
|
| |
(GH-30285)
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Add RETURN_GENERATOR and JUMP_NO_INTERRUPT opcodes.
* Trim frame and generator by word each.
* Minor refactor of frame.c
* Update test.test_sys to account for smaller frames.
* Treat generator functions as normal functions when evaluating and specializing.
|
| |
|
|
|
|
|
| |
(GH-30632)
This reverts commit acf7403f9baea3ae1119fc6b4a3298522188bf96.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Undo rejected PEP-663 changes:
- restore `repr()` to its 3.10 status
- restore `str()` to its 3.10 status
New changes:
- `IntEnum` and `IntFlag` now leave `__str__` as the original `int.__str__` so that str() and format() return the same result
- zero-valued flags without a name have a slightly changed repr(), e.g. `repr(Color(0)) == '<Color: 0>'`
- update `dir()` for mixed-in types to return all the methods and attributes of the mixed-in type
- added `_numeric_repr_` to `Flag` to control display of unnamed values
- enums without doc strings have a more comprehensive doc string added
- `ReprEnum` added -- inheriting from this makes it so only `__repr__` is replaced, not `__str__` nor `__format__`; `IntEnum`, `IntFlag`, and `StrEnum` all inherit from `ReprEnum`
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
properties or dynamic properties. (#20911)
* Add function inspect.getmembers_static that does not call properties or dynamic
properties.
* update _getmembers args
* Update Misc/NEWS.d/next/Library/2020-06-16-18-00-56.bpo-30533.StL57t.rst
Co-authored-by: Itamar Ostricher <itamarost@gmail.com>
* Update Lib/inspect.py
Co-authored-by: Itamar Ostricher <itamarost@gmail.com>
* Removes the copy pasted doc string
Co-authored-by: Itamar Ostricher <itamarost@gmail.com>
Co-authored-by: Dino Viehland <dinoviehland@gmail.com>
|
|
|
|
| |
FileNotFoundError (GH-28824)
|
|
|
|
|
|
|
| |
Use types.GenericAlias in inspect.formatannotation to correctly add
type arguments of builtin types to the string representation of
Signatures.
Co-authored-by: Martin Rückl <martin.rueckl@codecentric.de>
|
| |
|
| |
|
|
|
|
| |
(GH-27171)
|
|
|
|
|
| |
`inspect.signature` (#27177)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
|
| |
|
| |
|
|
|
|
|
| |
Add inspect.get_annotations, which safely computes the annotations defined on an object. It works around the quirks of accessing the annotations from various types of objects, and makes very few assumptions about the object passed in. inspect.get_annotations can also correctly un-stringize stringized annotations.
inspect.signature, inspect.from_callable, and inspect.from_function now call inspect.get_annotations to retrieve annotations. This means inspect.signature and inspect.from_callable can now un-stringize stringized annotations, too.
|
|
|
|
|
|
| |
(GH-25490)
This reverts commits 044a1048ca93d466965afc027b91a5a9eb9ce23c and 1be456ae9d53bb1cba2b24fc86175c282d1c2169, adapting the code to changes that happened after it.
|
|
|
|
|
|
|
|
|
| |
* Enum: streamline repr() and str(); improve docs
- repr() is now ``enum_class.member_name``
- stdlib global enums are ``module_name.member_name``
- str() is now ``member_name``
- add HOW-TO section for ``Enum``
- change main documentation to be an API reference
|
|
|
|
|
|
|
|
|
|
|
| |
`type.__new__` calls `__set_name__` and `__init_subclass__`, which means
that any work metaclasses do after calling `super().__new__()` will not
be available to those two methods. In particular, `Enum` classes that
want to make use of `__init_subclass__` will not see any members.
Almost all customization is therefore moved to before the
`type.__new__()` call, including changing all members to a proto member
descriptor with a `__set_name__` that will do the final conversion of a
member to be an instance of the `Enum` class.
|
|
|
|
| |
Signature.from_callable (GH-22583)
|
|
|
|
|
| |
range (GH-23633)
This can happen when a file was edited after it was imported.
|
| |
|
|
|
|
| |
`__loader__` is missing (#22929)
|
|
|
|
|
| |
The hard part was making all the tests pass; there are some subtle issues here, because apparently the future import wasn't tested very thoroughly in previous Python versions.
For example, `inspect.signature()` returned type objects normally (except for forward references), but strings with the future import. We changed it to try and return type objects by calling `typing.get_type_hints()`, but fall back on returning strings if that function fails (which it may do if there are future references in the annotations that require passing in a specific namespace to resolve).
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(#10307)
* Use ast module to find class definition
* Add NEWS entry
* Fix class with multiple children and move decorator code to the method
* Fix PR comments
1. Use node.decorator_list to select decorators
2. Remove unwanted variables in ClassVisitor
3. Simplify stack management as per review
* Add test for nested functions and async calls
* Fix pydoc test since comments are returned now correctly
* Set event loop policy as None to fix environment related change
* Refactor visit_AsyncFunctionDef and tests
* Refactor to use local variables and fix tests
* Add patch attribution
* Use self.addCleanup for asyncio
* Rename ClassVisitor to ClassFinder and fix asyncio cleanup
* Return first class inside conditional in case of multiple definitions. Remove decorator for class source.
* Add docstring to make the test correct
* Modify NEWS entry regarding decorators
* Return decorators too for bpo-15856
* Move ast and the class source code to top. Use proper Exception.
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
(GH-18786)
`list(sys.modules.items())` was apparently not immune to "dictionary
changed size during iteration" errors.
Tested internally using an integration test that has run into this a couple of times in the past two years. With this patch applied, the test is no longer flaky.
|
| |
|
| |
|
| |
|
|
|
|
| |
positional-only parameter (GH-16800)
|
|
|
|
|
|
|
|
| |
https://bugs.python.org/issue34706
Specifically in the case of a class that does not override its
constructor signature inherited from object.
These are Buck Evan @bukzor's changes cherrypicked from GH-9344.
|
|
|
| |
Constants added by the site module like exit() "should not be used in programs"
|
|
|
|
|
| |
It should avoid dynamic lookup including `isinstance`.
This is a regression caused by GH-5351.
|