Skip to content

Conversation

@guitargeek
Copy link
Contributor

@guitargeek guitargeek commented Dec 17, 2024

With Python 3.13, some lookup methods like PyMapping_GetItemString and PyObject_GetAttrString became more strict. They are now always throwing an exception in case the attribute is not found.

To make these optional lookups work again, the GetOptional family of functions needs to be used.

See:

This is the upstream version of the following ROOT commit:

Related to the following cppyy issue, although it might be better to close that issue by fixing the underlying problem:

With Python 3.13, some lookup methods like `PyMapping_GetItemString` and
`PyObject_GetAttrString` became more strict. They are now always
throwing an exception in case the attribute is not found.

To make these optional lookups work again, the `GetOptional` family of
functions needs to be used.

See:
  * https://docs.python.org/3/c-api/object.html#c.PyObject_GetOptionalAttrString
  * https://docs.python.org/3/c-api/mapping.html#c.PyMapping_GetOptionalItemString

This is the upstream version of the following ROOT commit:

  * root-project/root@e78450dc45ed868b7a52a0
@wlav
Copy link
Owner

wlav commented Dec 17, 2024

Interesting, since even with py13, wlav/cppyy#273 doesn't fail for me.

@guitargeek
Copy link
Contributor Author

Yes, I've read that. Maybe my reproducer in the issue is not complete. I'll investigate this further.

@wlav
Copy link
Owner

wlav commented Dec 17, 2024

As for the PR, I'm much rather use a more descriptive name and put a compatibility function in CPyCppyy.h. I'll do that later: I'm going to remove all Python2 stuff, finally. My last place to test it was an old Mac, but that one has other issues now, so the most recent release didn't have code verified on it.

This graph shows that py3.7 is the oldest I need to care about.

@guitargeek
Copy link
Contributor Author

I'm not sure at this point if the PR is covered by a unit test in ROOT or not.

Let's see: root-project/root#19401

@guitargeek
Copy link
Contributor Author

The crossinheritance tests fail on Python 3.14 debug without this PR. Unfortunately, not with a clear error message...

2025-12-03T22:31:24.0936637Z ============================= test session starts ==============================
2025-12-03T22:31:24.0987517Z platform linux -- Python 3.14.0, pytest-8.4.2, pluggy-1.6.0
2025-12-03T22:31:24.1007008Z rootdir: /github/home/ROOT-CI/src/bindings/pyroot/cppyy/cppyy
2025-12-03T22:31:24.1007512Z configfile: pyproject.toml
2025-12-03T22:31:24.1008194Z collected 40 items
2025-12-03T22:31:24.1008343Z 
2025-12-03T22:31:24.1008588Z ../../../../../../src/bindings/pyroot/cppyy/cppyy/test/test_crossinheritance.py x [  2%]
2025-12-03T22:31:24.1009072Z .............x.....sss.sss..s.x.x....CMake Error at /github/home/ROOT-CI/src/cmake/modules/RootTestDriver.cmake:232 (message):
2025-12-03T22:31:24.1009441Z   error code: Subprocess aborted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants