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

Support Python 3.11 #95

Closed
devinrsmith opened this issue Oct 31, 2022 · 4 comments · Fixed by #96
Closed

Support Python 3.11 #95

devinrsmith opened this issue Oct 31, 2022 · 4 comments · Fixed by #96
Assignees
Labels
enhancement New feature or request

Comments

@devinrsmith
Copy link
Member

devinrsmith commented Oct 31, 2022

https://docs.python.org/3.11/whatsnew/3.11.html#whatsnew311-c-api-porting

At a minimum, will need to update for PyFrameObject changes.

@devinrsmith devinrsmith added the enhancement New feature or request label Oct 31, 2022
@devinrsmith devinrsmith self-assigned this Oct 31, 2022
@devinrsmith
Copy link
Member Author

Current compile error:

2022-10-31T20:58:35.2083924Z src/main/c/jni/org_jpy_PyLib.c: In function ‘format_python_traceback’:
2022-10-31T20:58:35.2084495Z src/main/c/jni/org_jpy_PyLib.c:2743:25: error: dereferencing pointer to incomplete type ‘PyFrameObject’ {aka ‘struct _frame’}
2022-10-31T20:58:35.2084988Z  2743 |             tb->tb_frame->f_code->co_filename != last_file ||
2022-10-31T20:58:35.2085253Z       |                         ^~

@devinrsmith
Copy link
Member Author

devinrsmith commented Oct 31, 2022

Looks like there is a change wrt Py_TYPE(obj) = new_type not working - we'll want to fix and add the suggested macro for backwards compatibility:

#if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_TYPE)
static inline void _Py_SET_TYPE(PyObject *ob, PyTypeObject *type)
{ ob->ob_type = type; }
#define Py_SET_TYPE(ob, type) _Py_SET_TYPE((PyObject*)(ob), type)
#endif

@devinrsmith
Copy link
Member Author

Py_SIZE(obj) = new_size won't work - we'll want to fix and add the suggested macro for backwards compatibility:

#if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_SIZE)
static inline void _Py_SET_SIZE(PyVarObject *ob, Py_ssize_t size)
{ ob->ob_size = size; }
#define Py_SET_SIZE(ob, size) _Py_SET_SIZE((PyVarObject*)(ob), size)
#endif

@devinrsmith
Copy link
Member Author

https://github.com/python/pythoncapi-compat looks potentially interesting; that said, it is pretty easy to maintain our own macros.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant