gh-111495: Add tests for PyNumber C API#111996
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
serhiy-storchaka
left a comment
There was a problem hiding this comment.
The wrapper code is similar for most 1- and 2-argumet functions. What do you think about using macros to generate them? It would be easier to review and extend.
Sorry, something went wrong.
dd182df to
daf4b6f
Compare
November 15, 2023 06:38
daf4b6f to
8cf4429
Compare
November 15, 2023 06:40
serhiy-storchaka
left a comment
There was a problem hiding this comment.
For now LGTM. But please move changes in abstract.c to a separate PR. This PR should contain tests only.
Also, there is an existing PyNumber test in test_abstract. Please move it to other tests, and the corresponding wrapper too.
Sorry, something went wrong.
15f8a7b to
2bc6bc7
Compare
November 15, 2023 11:38
That was the plan. But please could you first take look on these changes? This part seems to be finished and I would know, for example, if this can go in one PR or in several. For now, almost every line for PyNumber_* C API is covered. Exceptions are like this: Line 1593 in d4f83e1
Indeed. Should I remove number_check() from the abstract.c or from the number.c instead? Edit:
|
Sorry, something went wrong.
* Add test for [1, 2] and PY_SSIZE_T_MAX//2 + 1 (test_multiply) * test with floats for unary * test_float/index with strings * 42 is too large. What about 3? // tobase * test with float & string // tobase * complex test for absolute
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot AMD64 Debian root 3.x has failed when building commit 2f20f5a. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/#/builders/345/builds/8794 Failed tests:
Failed subtests:
Summary of the results of the build (if available): == Click to see traceback logsTraceback (most recent call last):
File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/test/test_capi/test_number.py", line 227, in test_rshift_print
self.assertIn('Did you mean "print(<message>, '
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'file=<output_stream>)"?', str(context.exception))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'Did you mean "print(<message>, file=<output_stream>)"?' not found in "unsupported operand type(s) for >>: 'builtin_function_or_method' and 'int'"
|
Sorry, something went wrong.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot x86-64 MacOS Intel NoGIL 3.x has failed when building commit 2f20f5a. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/#/builders/1258/builds/2654 Failed tests:
Failed subtests:
Summary of the results of the build (if available): == Click to see traceback logsTraceback (most recent call last):
File "<string>", line 10, in <module>
File "<frozen importlib._bootstrap>", line 813, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 1046, in create_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
ImportError: module _test_module_state_shared does not support loading in subinterpreters
xpected failure
Traceback (most recent call last):
File "/Users/ec2-user/buildbot/buildarea/3.x.itamaro-macos-intel-aws.nogil/build/Lib/test/test_capi/test_number.py", line 227, in test_rshift_print
self.assertIn('Did you mean "print(<message>, '
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'file=<output_stream>)"?', str(context.exception))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'Did you mean "print(<message>, file=<output_stream>)"?' not found in "unsupported operand type(s) for >>: 'builtin_function_or_method' and 'int'"
|
Sorry, something went wrong.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot s390x Fedora Clang 3.x has failed when building commit 2f20f5a. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/#/builders/3/builds/6639 Failed tests:
Failed subtests:
Summary of the results of the build (if available): == Click to see traceback logsTraceback (most recent call last):
File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.clang/build/Lib/test/test_capi/test_number.py", line 227, in test_rshift_print
self.assertIn('Did you mean "print(<message>, '
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'file=<output_stream>)"?', str(context.exception))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'Did you mean "print(<message>, file=<output_stream>)"?' not found in "unsupported operand type(s) for >>: 'builtin_function_or_method' and 'int'"
|
Sorry, something went wrong.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot AMD64 Windows10 3.x has failed when building commit 2f20f5a. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/#/builders/146/builds/9358 Failed tests:
Failed subtests:
Summary of the results of the build (if available): == Click to see traceback logsTraceback (most recent call last):
File "D:\buildarea\3.x.bolen-windows10\build\Lib\test\test_capi\test_number.py", line 227, in test_rshift_print
self.assertIn('Did you mean "print(<message>, '
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'file=<output_stream>)"?', str(context.exception))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'Did you mean "print(<message>, file=<output_stream>)"?' not found in "unsupported operand type(s) for >>: 'builtin_function_or_method' and 'int'"
|
Sorry, something went wrong.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot AMD64 RHEL8 LTO + PGO 3.x has failed when building commit 2f20f5a. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/#/builders/568/builds/7186 Failed tests:
Failed subtests:
Summary of the results of the build (if available): == Click to see traceback logsTraceback (most recent call last):
File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-x86_64.lto-pgo/build/Lib/test/test_capi/test_number.py", line 227, in test_rshift_print
self.assertIn('Did you mean "print(<message>, '
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'file=<output_stream>)"?', str(context.exception))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'Did you mean "print(<message>, file=<output_stream>)"?' not found in "unsupported operand type(s) for >>: 'builtin_function_or_method' and 'int'"
|
Sorry, something went wrong.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot s390x RHEL8 LTO 3.x has failed when building commit 2f20f5a. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/#/builders/567/builds/7197 Failed tests:
Failed subtests:
Summary of the results of the build (if available): == Click to see traceback logsTraceback (most recent call last):
File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel8-z.lto/build/Lib/test/test_capi/test_number.py", line 227, in test_rshift_print
self.assertIn('Did you mean "print(<message>, '
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'file=<output_stream>)"?', str(context.exception))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'Did you mean "print(<message>, file=<output_stream>)"?' not found in "unsupported operand type(s) for >>: 'builtin_function_or_method' and 'int'"
|
Sorry, something went wrong.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot s390x Fedora Clang Installed 3.x has failed when building commit 2f20f5a. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/#/builders/531/builds/6470 Failed tests:
Failed subtests:
Summary of the results of the build (if available): == Click to see traceback logsTraceback (most recent call last):
File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.clang-installed/build/target/lib/python3.14/test/test_capi/test_number.py", line 227, in test_rshift_print
self.assertIn('Did you mean "print(<message>, '
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'file=<output_stream>)"?', str(context.exception))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'Did you mean "print(<message>, file=<output_stream>)"?' not found in "unsupported operand type(s) for >>: 'builtin_function_or_method' and 'int'"
|
Sorry, something went wrong.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot AMD64 RHEL8 FIPS Only Blake2 Builtin Hash 3.x has failed when building commit 2f20f5a. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/#/builders/469/builds/8845 Failed tests:
Failed subtests:
Summary of the results of the build (if available): == Click to see traceback logsTraceback (most recent call last):
File "/home/buildbot/buildarea/3.x.cstratak-RHEL8-fips-x86_64.no-builtin-hashes-except-blake2/build/Lib/test/test_capi/test_number.py", line 227, in test_rshift_print
self.assertIn('Did you mean "print(<message>, '
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'file=<output_stream>)"?', str(context.exception))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'Did you mean "print(<message>, file=<output_stream>)"?' not found in "unsupported operand type(s) for >>: 'builtin_function_or_method' and 'int'"
|
Sorry, something went wrong.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot s390x RHEL9 LTO 3.x has failed when building commit 2f20f5a. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/#/builders/1587/builds/177 Failed tests:
Failed subtests:
Summary of the results of the build (if available): == Click to see traceback logsTraceback (most recent call last):
File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z.lto/build/Lib/test/test_capi/test_number.py", line 227, in test_rshift_print
self.assertIn('Did you mean "print(<message>, '
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'file=<output_stream>)"?', str(context.exception))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'Did you mean "print(<message>, file=<output_stream>)"?' not found in "unsupported operand type(s) for >>: 'builtin_function_or_method' and 'int'"
|
Sorry, something went wrong.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot AMD64 Ubuntu Shared 3.x has failed when building commit 2f20f5a. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/#/builders/506/builds/8613 Failed tests:
Failed subtests:
Summary of the results of the build (if available): == Click to see traceback logsTraceback (most recent call last):
File "/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/test_capi/test_number.py", line 227, in test_rshift_print
self.assertIn('Did you mean "print(<message>, '
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'file=<output_stream>)"?', str(context.exception))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'Did you mean "print(<message>, file=<output_stream>)"?' not found in "unsupported operand type(s) for >>: 'builtin_function_or_method' and 'int'"
|
Sorry, something went wrong.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot x86-64 macOS 3.x has failed when building commit 2f20f5a. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/#/builders/366/builds/7532 Failed tests:
Failed subtests:
Summary of the results of the build (if available): == Click to see traceback logsTraceback (most recent call last):
File "/Users/buildbot/buildarea/3.x.billenstein-macos/build/Lib/test/test_capi/test_number.py", line 227, in test_rshift_print
self.assertIn('Did you mean "print(<message>, '
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'file=<output_stream>)"?', str(context.exception))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'Did you mean "print(<message>, file=<output_stream>)"?' not found in "unsupported operand type(s) for >>: 'builtin_function_or_method' and 'int'"
|
Sorry, something went wrong.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot ARM64 Windows 3.x has failed when building commit 2f20f5a. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/#/builders/729/builds/6685 Failed tests:
Failed subtests:
Summary of the results of the build (if available): == Click to see traceback logsTraceback (most recent call last):
File "C:\Workspace\buildarea\3.x.linaro-win-arm64\build\Lib\test\test_capi\test_number.py", line 227, in test_rshift_print
self.assertIn('Did you mean "print(<message>, '
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'file=<output_stream>)"?', str(context.exception))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'Did you mean "print(<message>, file=<output_stream>)"?' not found in "unsupported operand type(s) for >>: 'builtin_function_or_method' and 'int'"
|
Sorry, something went wrong.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot s390x Fedora LTO + PGO 3.x has failed when building commit 2f20f5a. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/#/builders/545/builds/6412 Failed tests:
Failed subtests:
Summary of the results of the build (if available): == Click to see traceback logsTraceback (most recent call last):
File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.lto-pgo/build/Lib/test/test_capi/test_number.py", line 227, in test_rshift_print
self.assertIn('Did you mean "print(<message>, '
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'file=<output_stream>)"?', str(context.exception))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'Did you mean "print(<message>, file=<output_stream>)"?' not found in "unsupported operand type(s) for >>: 'builtin_function_or_method' and 'int'"
|
Sorry, something went wrong.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot ARM64 Windows Non-Debug 3.x has failed when building commit 2f20f5a. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/#/builders/730/builds/10142 Failed tests:
Failed subtests:
Summary of the results of the build (if available): == Click to see traceback logsTraceback (most recent call last):
File "C:\Workspace\buildarea\3.x.linaro-win-arm64.nondebug\build\Lib\test\test_capi\test_number.py", line 227, in test_rshift_print
self.assertIn('Did you mean "print(<message>, '
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'file=<output_stream>)"?', str(context.exception))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'Did you mean "print(<message>, file=<output_stream>)"?' not found in "unsupported operand type(s) for >>: 'builtin_function_or_method' and 'int'"
|
Sorry, something went wrong.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot s390x Fedora LTO 3.x has failed when building commit 2f20f5a. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/#/builders/55/builds/5519 Failed tests:
Failed subtests:
Summary of the results of the build (if available): == Click to see traceback logsTraceback (most recent call last):
File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.lto/build/Lib/test/test_capi/test_number.py", line 227, in test_rshift_print
self.assertIn('Did you mean "print(<message>, '
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'file=<output_stream>)"?', str(context.exception))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'Did you mean "print(<message>, file=<output_stream>)"?' not found in "unsupported operand type(s) for >>: 'builtin_function_or_method' and 'int'"
|
Sorry, something went wrong.
|
Thanks @skirpichev for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Sorry, something went wrong.
|
Thanks @skirpichev for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12. |
Sorry, something went wrong.
(cherry picked from commit 2f20f5a) Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
|
Sorry, @skirpichev and @vstinner, I could not cleanly backport this to |
Sorry, something went wrong.
(cherry picked from commit 2f20f5a) Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
edited by bedevere-app
Bot
LoadingUh oh!
There was an error while loading. Please reload this page.
Copy link Copy MarkdownSorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.