-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@overload
decorator on compiled functions is not tested
#96478
Comments
Moreover, this has a side-effect: overload(sum) creates a following entry in
|
This happens because only the last try:
_overload_registry[f.__module__][f.__qualname__][f.__code__.co_firstlineno] = func
except AttributeError:
# Not a normal function; ignore.
pass fails with |
The current code for f = getattr(func, "__func__", func)
try:
_overload_registry[f.__module__][f.__qualname__][f.__code__.co_firstlineno] = func
except AttributeError:
# Not a normal function; ignore.
pass
return _overload_dummy If we wanted to get rid of the side effect, we could maybe change the code to something like this: f = getattr(func, "__func__", func)
try:
mod, qualname, lineno = f.__module__, f.__qualname__, f.__code__.co_firstlineno
except AttributeError:
# Not a normal function; ignore.
pass
else:
_overload_registry[mod][qualname][lineno] = func
return _overload_dummy But we worked quite hard to make sure that the performance regression introduced by making overloads retrievable at runtime was as small as possible. So I'd want to make sure that this didn't make things any slower. |
I don't think that we want to remove this side-effect. Moreover, annotating C functions is not that common. It is more like an exceptional case. |
Yeah, the possibility of this side effect causing a memory leak is pretty minimal :) |
Co-authored-by: Alex Waygood <[email protected]>
Co-authored-by: Alex Waygood <[email protected]> (cherry picked from commit f177f6f) Co-authored-by: Nikita Sobolev <[email protected]>
./python.exe -m test -R : test.test_typing would fail, apparently because the dictionary used in the @patch decorator was modified.
Co-authored-by: Alex Waygood <[email protected]> (cherry picked from commit f177f6f) Co-authored-by: Nikita Sobolev <[email protected]>
./python.exe -m test -R : test.test_typing would fail, apparently because the dictionary used in the @patch decorator was modified. (cherry picked from commit f0d9136) Co-authored-by: Jelle Zijlstra <[email protected]>
./python.exe -m test -R : test.test_typing would fail, apparently because the dictionary used in the @patch decorator was modified. (cherry picked from commit f0d9136) Co-authored-by: Jelle Zijlstra <[email protected]>
Fixed by #96479 |
If I change this line
cpython/Lib/typing.py
Line 2584 in a91f255
to be
test_typing
continues to pass as expected. I think it is dangerous, because we can accidentally break something and not notice.I will send a simple test case to catch this: we should not fail.
The text was updated successfully, but these errors were encountered: