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

Clean up uses of deprecated CPython APIs #731

Merged
merged 1 commit into from
Dec 10, 2020
Merged

Conversation

zrax
Copy link
Member

@zrax zrax commented Nov 6, 2020

No description provided.

@zrax zrax requested a review from Hoikas November 6, 2020 22:19
Copy link
Member

@Hoikas Hoikas left a 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");
Copy link
Member

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 😢

Copy link
Member Author

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 :)

Comment on lines -206 to +211
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);

Copy link
Member

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?

Comment on lines -242 to +250
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);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

@Hoikas
Copy link
Member

Hoikas commented Dec 10, 2020

Let's go ahead and merge this and deal with leaks later.

@Hoikas Hoikas merged commit dab152f into H-uru:master Dec 10, 2020
@zrax zrax deleted the python_depr branch December 18, 2020 20:53
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.

None yet

2 participants