gh-58211: Add tests for __self__ attribute of builtins functions#113575
gh-58211: Add tests for __self__ attribute of builtins functions#113575picnixz merged 13 commits into
Conversation
The check about the f argument type was removed in this commit: python@2c94aa5 Thanks for Pedro Arthur Duarte (pedroarthur.jedi at gmail.com) by the help with this bug.
…#106335) Remove private _PyThreadState and _PyInterpreterState C API functions: move them to the internal C API (pycore_pystate.h and pycore_interp.h). Don't export most of these functions anymore, but still export functions used by tests. Remove _PyThreadState_Prealloc() and _PyThreadState_Init() from the C API, but keep it in the stable API.
There was a problem hiding this comment.
This appears to me to go in the opposite direction to the consensus in #58211 -- the consensus seems to me to be that this is a misfeature that could only be confusing. That doesn't mean that we should necessarily bother changing the current behaviour unless it's actually causing a bug for somebody. But we should only add tests for things which are working in a desirable way currently -- we shouldn't cement undesirable behaviour by adding tests for it.
I'm therefore doubtful that this PR is a good idea. Instead, as I suggested in #113574 (comment), I think we should fix the documentation so that it is more vague about what the value of this attribute might be for builtin functions.
Sorry, something went wrong.
Yes, I agree. (Although I'm the PR author). The big problem is where desirable behaviour is defined. Furthermore, ignoring other necessary knowledge, I think of the
I don't know if this is a good idea. I guess not. Maybe it is better to remove this attribute from the documentation. Seeing the Terry's comment, the bug is not only the |
Sorry, something went wrong.
|
There is a code in |
Sorry, something went wrong.
Do you mean:
? |
Sorry, something went wrong.
|
I meant considering this PR. |
Sorry, something went wrong.
AlexWaygood
left a comment
There was a problem hiding this comment.
@adorilson, if you make @serhiy-storchaka's suggested changes, then we can consider merging this:
We can make these tests running only on CPython, and add comments explaining this.
We have a test.support.cpython_only decorator for tests that are only meant to run if the implementation is CPython.
Sorry, something went wrong.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Sorry, something went wrong.
|
I have made the requested changes; please review again I've added the Regarding the comment explaining it, I put a 'See gh-58211' only. Is it enough? |
Sorry, something went wrong.
|
Thanks for making the requested changes! @AlexWaygood: please review the changes made to this pull request. |
Sorry, something went wrong.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
|
I have made the requested changes; please review again |
Sorry, something went wrong.
|
Thanks for making the requested changes! @AlexWaygood: please review the changes made to this pull request. |
Sorry, something went wrong.
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka
left a comment
There was a problem hiding this comment.
LGTM.
Sorry, something went wrong.
|
Thanks @adorilson for the PR, and @picnixz for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Sorry, something went wrong.
…nctions (pythonGH-113575) --------- (cherry picked from commit 891465f) Co-authored-by: Adorilson Bezerra <adorilson@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…unctions (GH-113575) (#132437) gh-58211: Add tests for the `__self__` attribute of builtins functions (GH-113575) --------- (cherry picked from commit 891465f) Co-authored-by: Adorilson Bezerra <adorilson@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot aarch64 Fedora Stable Refleaks 3.13 (tier-2) has failed when building commit 70c4bd6. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/#/builders/1512/builds/501 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.13.cstratak-fedora-stable-aarch64.refleak/build/Lib/test/test_perf_profiler.py", line 356, in test_python_calls_appear_in_the_stack_if_perf_activated
self.assertIn(f"py::foo:{script}", stdout)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'py::foo:/tmp/test_python_bpnjkkps/tmp0s3c50qt/perftest.py' not found in 'python 2200791 1629299.198245: 1 cycles:Pu: \n\t ffffbe78fac0 _start+0x0 (/usr/lib/ld-linux-aarch64.so.1)\n\npython 2200791 1629299.198284: 1 cycles:Pu: \n\tffffaa282d37fc78 [unknown] ([unknown])\n\tffffaa282d38049c [unknown] ([unknown])\n\tffffaa282bf215e4 [unknown] ([unknown])\n\t ffffbe78fac0 _start+0x0 (/usr/lib/ld-linux-aarch64.so.1)\n\npython 2200791 1629299.199087: 1 cycles:Pu: \n\t ffffbe77d7a8 _dl_lookup_symbol_x+0x88 (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffbe7816ff resolve_map+0x79f (inlined)\n\t ffffbe7816ff elf_machine_rela+0x79f (inlined)\n\t ffffbe7816ff elf_dynamic_do_Rela+0x79f (inlined)\n\t ffffbe7816ff _dl_relocate_object+0x79f (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffbe78d3d3 dl_main+0x15d3 (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffbe78a5ff _dl_sysdep_start+0x1df (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffbe78bb17 _dl_start_final+0x5ab (inlined)\n\t ffffbe78bb17 _dl_start+0x5ab (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffbe78fad3 _start+0x13 (/usr/lib/ld-linux-aarch64.so.1)\n\npython 2200791 1629299.199112: 310 cycles:Pu: \n\t ffffbe77cd7c do_lookup_x+0xfc (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffbe77d833 _dl_lookup_symbol_x+0x113 (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffbe7816ff resolve_map+0x79f (inlined)\n\t ffffbe7816ff elf_machine_rela+0x79f (inlined)\n\t ffffbe7816ff elf_dynamic_do_Rela+0x79f (inlined)\n\t ffffbe7816ff _dl_relocate_object+0x79f (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffbe78d3d3 dl_main+0x15d3 (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffbe78a5ff _dl_sysdep_start+0x1df (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffbe78bb17 _dl_start_final+0x5ab (inlined)\n\t ffffbe78bb17 _dl_start+0x5ab (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffbe78fad3 _start+0x13 (/usr/lib/ld-linux-aarch64.so.1)\n\n
ld/python)\n\t 68b597 pymain_init+0x57 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 68b703 pymain_main+0xf (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 68b797 Py_BytesMain+0x27 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 41ddb7 main+0xb (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t ffffbe52625b __libc_start_call_main+0x7b (/usr/lib64/libc.so.6)\n\t ffffbe52633b __libc_start_main@@GLIBC_2.34+0x9b (/usr/lib64/libc.so.6)\n\t 41dcaf _start+0x2f (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\npython 2200791 1629299.201163: 73859 cycles:Pu: \n\t ffffbe7829c8 _dl_fixup+0x68 (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffbe784ef7 _dl_runtime_resolve+0x47 (/usr/lib/ld-linux-aarch64.so.1)\n\t 678a5b _PyThread_cond_init+0x17 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 678a5b _PyThread_cond_init+0x17 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 629673 create_gil+0x37 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 629727 init_own_gil+0x27 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 62a7bb _PyEval_InitGIL+0xe3 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 6531a7 init_interp_create_gil+0x33 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 653443 pycore_create_interpreter+0x28f (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 653cf3 pyinit_config+0x6f (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 65b3ab pyinit_core+0xdb (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 65b483 Py_InitializeFromConfig+0x97 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 68b63f pymain_init+0xff (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 68b703 pymain_main+0xf (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 68b797 Py_BytesMain+0x27 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 41ddb7 main+0xb (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t ffffbe52625b __libc_start_call_main+0x7b (/usr/lib64/libc.so.6)\n\t ffffbe52633b __libc_start_main@@GLIBC_2.34+0x9b (/usr/lib64/libc.so.6)\n\t 41dcaf _start+0x2f (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\npython 2200791 1629299.201572: 590235 cycles:Pu: \n\t 57eb40 _PyUnicode_InitStaticStrings+0x85c0 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 58e39f init_global_interned_strings+0x77 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 58e5e7 _PyUnicode_InitGlobalObjects+0x63 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 6534af pycore_init_global_objects+0x23 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 653a57 pycore_interp_init+0x2b (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 653d33 pyinit_config+0xaf (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 65b3ab pyinit_core+0xdb (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 65b483 Py_InitializeFromConfig+0x97 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 68
Traceback (most recent call last):
File "/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/Lib/test/test_perf_profiler.py", line 356, in test_python_calls_appear_in_the_stack_if_perf_activated
self.assertIn(f"py::foo:{script}", stdout)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'py::foo:/tmp/test_python_gwnie6fm/tmpqdze5_a5/perftest.py' not found in 'python 2289302 1630209.314755: 1 cycles:Pu: \n\t ffffa9cbfac0 _start+0x0 (/usr/lib/ld-linux-aarch64.so.1)\n\npython 2289302 1630209.314787: 1 cycles:Pu: \n\tffffaa282d37fc78 [unknown] ([unknown])\n\tffffaa282d38049c [unknown] ([unknown])\n\tffffaa282bf215e4 [unknown] ([unknown])\n\t ffffa9cbfac0 _start+0x0 (/usr/lib/ld-linux-aarch64.so.1)\n\npython 2289302 1630209.315112: 1 cycles:Pu: \n\t ffffa9cc0f40 __fstat+0x0 (inlined)\n\t ffffa9cae70f _dl_sysdep_read_whole_file+0x4f (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffa9cb6a0f _dl_load_cache_lookup+0x127 (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffa9cac2c3 _dl_map_object+0x377 (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffa9ca75bf openaux+0x3f (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffa9ca6303 _dl_catch_exception+0x63 (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffa9ca7b33 _dl_map_object_deps+0x553 (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffa9cbd19f dl_main+0x139f (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffa9cba5ff _dl_sysdep_start+0x1df (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffa9cbbb17 _dl_start_final+0x5ab (inlined)\n\t ffffa9cbbb17 _dl_start+0x5ab (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffa9cbfad3 _start+0x13 (/usr/lib/ld-linux-aarch64.so.1)\n\npython 2289302 1630209.315140: 292 cycles:Pu: \n\tffffaa282d37ff10 [unknown] ([unknown])\n\tffffaa282d3804cc [unknown] ([unknown])\n\tffffaa282bf215e4 [unknown] ([unknown])\n\t ffffa9cc1628 __mmap64+0x28 (inlined)\n\t ffffa9cc1628 mmap64+0x28 (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffa9cae75b _dl_sysdep_read_whole_file+0x9b (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffa9cb6a0f _dl_load_cache_lookup+0x127 (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffa9cac2c3 _dl_map_object+0x377 (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffa9ca75bf openaux+0x3f (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffa9ca6303 _dl_catch_exception+0x63 (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffa9ca7b33 _dl_map_object_deps+0x553 (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffa9cbd19f dl_main+0x139f (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffa9cba5ff _dl_sysdep_start+0x1df (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffa9cbbb17 _dl_start_final+0x5ab (inlined)\n\t ffffa9cbbb17 _dl_start+0x5ab (/usr/lib/ld-linux-aarch64.so.1)\n\t ffffa9cbfad3 _start+0x13 (/usr/lib/ld-linux-aarch64.so.1)\n\npython 2289302 1630209.316158: 1391 cycles:Pu: \n\t 50c52c mi_prim_open+0xc (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 50c573 unix_detect_overcommit+0x17 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 51420b _mi_prim_mem_init+0x33 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 51423f _mi_os_init+0x17 (/home/buildbot/buil
-aarch64.refleak/build/python)\n\t 68b55b pymain_init+0x1b (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 68b703 pymain_main+0xf (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 68b797 Py_BytesMain+0x27 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 41ddb7 main+0xb (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t ffffa9a5625b __libc_start_call_main+0x7b (/usr/lib64/libc.so.6)\n\t ffffa9a5633b __libc_start_main@@GLIBC_2.34+0x9b (/usr/lib64/libc.so.6)\n\t 41dcaf _start+0x2f (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\npython 2289302 1630209.317230: 117970 cycles:Pu: \n\t ffffa9ac080c __GI___pthread_mutex_unlock_usercnt+0x0 (/usr/lib64/libc.so.6)\n\t 629ee3 take_gil+0x237 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 62a97f _PyEval_AcquireLock+0xf (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 65f323 _PyThreadState_Attach+0x3f (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 62a72f _PyEval_InitGIL+0x57 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 6531a7 init_interp_create_gil+0x33 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 653443 pycore_create_interpreter+0x28f (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 653cf3 pyinit_config+0x6f (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 65b3ab pyinit_core+0xdb (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 65b483 Py_InitializeFromConfig+0x97 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 68b63f pymain_init+0xff (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 68b703 pymain_main+0xf (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 68b797 Py_BytesMain+0x27 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 41ddb7 main+0xb (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t ffffa9a5625b __libc_start_call_main+0x7b (/usr/lib64/libc.so.6)\n\t ffffa9a5633b __libc_start_main@@GLIBC_2.34+0x9b (/usr/lib64/libc.so.6)\n\t 41dcaf _start+0x2f (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\npython 2289302 1630209.318139: 1136025 cycles:Pu: \n\t 4ee8b8 _PyObject_GC_MAY_BE_TRACKED+0x0 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 4f4f47 insert_to_emptydict+0x193 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 4f5c9b setitem_take2_lock_held+0x133 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 4f6223 _PyDict_SetItem_Take2+0xb (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 4f6283 PyDict_SetItem+0x57 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 53a3db add_tp_new_wrapper+0x67 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 53a467 type_ready_set_new+0x4b (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 5476ef type_ready+0x87 (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 54788f init_static_type+0xab (/home/buildbot/buildarea/3.13.cstratak-fedora-stable-aarch64.refleak/build/python)\n\t 547a6f _PyStaticType_InitBuiltin+0x23 (/home/buildbot/buildarea/3.13
|
Sorry, something went wrong.
Although there was an inconclusive discussion in #58211, this PR adds tests to
__self__in built-in callables as it work currently.If was accepted, after PR #113574 is merged we can fix the documentation too (just avoid conflict).