Skip to content
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

typing tests: test_overload_on_compiled_functions() may not work on alternative Python implementations #98713

Closed
AlexWaygood opened this issue Oct 26, 2022 · 2 comments
Assignees
Labels
tests Tests in the Lib/test dir topic-typing type-bug An unexpected behavior, bug, or error

Comments

@AlexWaygood
Copy link
Member

Bug report

A few weeks ago, the typing_extensions backport library received a bug report that test_overload_on_compiled_functions(), a recently added test, failed when run on PyPy: python/typing_extensions#83. This is due to the fact that builtins.sum() and builtins.print() are not compiled functions on PyPy.

The same test exists in the CPython test suite (the test was ported over to typing_extensions in python/typing_extensions#73 after being added to the CPython test suite in #96479):

def test_overload_on_compiled_functions(self):
with patch("typing._overload_registry",
defaultdict(lambda: defaultdict(dict))):
# The registry starts out empty:
self.assertEqual(typing._overload_registry, {})
# This should just not fail:
overload(sum)
overload(print)
# No overloads are recorded (but, it still has a side-effect):
self.assertEqual(typing.get_overloads(sum), [])
self.assertEqual(typing.get_overloads(print), [])
.

I think the test should probably be marked with the @test.support.cpython_only decorator in the CPython test suite.

(Cc. @sobolevn, who added the test.)

@AlexWaygood AlexWaygood added type-bug An unexpected behavior, bug, or error tests Tests in the Lib/test dir topic-typing labels Oct 26, 2022
@sobolevn
Copy link
Member

Yes, I will send a PR for that!

@sobolevn sobolevn self-assigned this Oct 26, 2022
sobolevn added a commit to sobolevn/cpython that referenced this issue Oct 26, 2022
AlexWaygood added a commit that referenced this issue Oct 26, 2022
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Oct 26, 2022
…thonGH-98714)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit 9495360)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
miss-islington added a commit that referenced this issue Oct 26, 2022
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit 9495360)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
@AlexWaygood
Copy link
Member Author

Thanks for the fix @sobolevn!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir topic-typing type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants