-
Notifications
You must be signed in to change notification settings - Fork 80
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
Clean up uses of deprecated CPython APIs #731
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, we should remove all these *W bindings, but I think this is for the best. Many of these deprecated APIs will be removed in Python 3.10.
@@ -79,7 +79,7 @@ void PythonInterface::initPython(const plFileName& rootDir, const std::vector<pl | |||
config.optimization_level = 2; | |||
config.write_bytecode = 0; | |||
config.user_site_directory = 0; | |||
config.program_name = L"plasma"; | |||
PyConfig_SetString(&config, &config.program_name, L"plasma"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related: I learned later that PyConfig can leak memory and it needs to be freed with PyConfig_Clear
😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I was wondering how this didn't crash, since Python expects program_name
to be dynamically allocated... Not calling PyConfig_Clear
would certainly explain that :)
uint8_t* daBuffer = nil; | ||
Py_ssize_t length; | ||
PyObject_AsReadBuffer( buffer_object, (const void**)&daBuffer, &length); | ||
Py_buffer view; | ||
PyObject_GetBuffer(buffer_object, &view, PyBUF_SIMPLE); | ||
uint8_t* daBuffer = (uint8_t*)view.buf; | ||
Py_ssize_t length = view.len; | ||
PyBuffer_Release(&view); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As part of the scripts update, I think I completely removed all uses of buffers because of this deprecation. Maybe we should just remove this binding?
uint16_t* daBuffer = nil; | ||
Py_ssize_t length; | ||
PyObject_AsReadBuffer( buffer_object, (const void**)&daBuffer, &length); | ||
Py_buffer view; | ||
PyObject_GetBuffer(buffer_object, &view, PyBUF_SIMPLE); | ||
uint16_t* daBuffer = (uint16_t*)view.buf; | ||
Py_ssize_t length = view.len; | ||
PyBuffer_Release(&view); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
Let's go ahead and merge this and deal with leaks later. |
No description provided.