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.
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.
|
please move changes in abstract.c to a separate PR 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 (result check here will require test code in C) Also, there is an existing PyNumber test in test_abstract. Indeed. Should I remove number_check() from the abstract.c or from the number.c instead? Edit:
|
Sorry, something went wrong.
| # Test PyNumber_Negative() | ||
| negative = _testcapi.number_negative | ||
|
|
||
| self.assertEqual(negative(42), -42) |
There was a problem hiding this comment.
For all tests currently with integers only, add also tests with floats and mixed.
Sorry, something went wrong.
There was a problem hiding this comment.
Did this with unary ops, then will extend to other tests as well.
Sorry, something went wrong.
There was a problem hiding this comment.
In fact, I think the old test layout was a bad idea. In the last commit I'm using just one method to test all four unary functions (PyNumber_Negative and friends).
This should be doable for binary and ternary functions as well, so I'll go that way, probably could do pr ready tomorrow. Special handling will be required for PyNumber_*Add/Multiply, which also utilize tp_as_sequence. Here almost all cases could be tested using built-in types. But not all. Thus, I think some C-coded test type must be used.
Sorry, something went wrong.
⚠️⚠️⚠️ 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.
|
Sorry, @skirpichev and @vstinner, I could not cleanly backport this to 3.12 due to a conflict. cherry_picker 2f20f5a9bc7dafdb3c2ae723da90eca1727a95f7 3.12
|
Sorry, something went wrong.
|
GH-123375 is a backport of this pull request to the 3.13 branch. |
Sorry, something went wrong.
|
GH-123376 is a backport of this pull request to the 3.12 branch. |
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.