GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-86493: Modernize modules initialization code by serhiy-storchaka · Pull Request #106858 · python/cpython Conversation
|
| if (o == NULL) { | ||
| Tkinter_TclError = PyErr_NewException("_tkinter.TclError", NULL, NULL); | ||
| if (PyModule_AddObjectRef(m, "TclError", Tkinter_TclError)) { | ||
| Py_DECREF(m); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Note for later: i prefer "exec" functions which returns -1 on error, and the caller is responsible to manage the module refcount.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| if (PyModule_AddObject(m, name, o) == 0) { | ||
| return 0; | ||
| } | ||
| Py_DECREF(o); | ||
| return -1; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It is very confusing code with inverse logic. I thought there was a bug.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| return -1; | ||
| } | ||
| res = PyModule_AddObject( | ||
| res = PyModule_AddObjectRef( |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think there was a bug.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| Py_INCREF(ErrorObject); | ||
| if (PyModule_AddObject(m, "error", ErrorObject) < 0) { | ||
| Py_DECREF(ErrorObject); | ||
| if (PyModule_AddObjectRef(m, "error", ErrorObject) < 0) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It is interesting, that the compiler complains about PyModule_Add, but not about PyModule_AddObjectRef. There is a bug in PyModule_AddObjectRef declaration.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
lgtm too
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I didn't check individual refcount, I rely on Refleaks buildbots for that and other reviewers 😁 Overall the change LGTM and makes the code shorter and more regular. The old code was really hard to understand with INCREF/DECREF dance.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
That's a big change, thanks. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Use PyModule_Add() or PyModule_AddObjectRef() instead of soft deprecated PyModule_AddObject().
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.