[issue26871] Change weird behavior of PyModule_AddObject()

2021-08-17 Thread Petr Viktorin
Petr Viktorin added the comment: Since https://github.com/python/cpython/pull/23122, there is PyModule_AddObjectRef doesn't steal a reference. PyModule_AddObject is discouraged in the docs, but not formally deprecated. (As Stefan notes, the leaks are single references in case of a module ini

[issue26871] Change weird behavior of PyModule_AddObject()

2016-04-29 Thread Stefan Krah
Stefan Krah added the comment: Serhiy, I'm sorry that I overreacted here. You're doing great work for Python -- we just happen to disagree on this one particular issue. I think there were some proponents on python-dev, perhaps they'll show up and discuss the details. -- ___

[issue26871] Change weird behavior of PyModule_AddObject()

2016-04-28 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Removed changes in _decimal.c and deprecation. Used Py_XDECREF in _PyModule_AddObject(). -- Added file: http://bugs.python.org/file42639/pymodule_addobject_2.patch ___ Python tracker

[issue26871] Change weird behavior of PyModule_AddObject()

2016-04-28 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > It seems that the patch also introduces a segfault if PyLong_FromSsize_t() > returns NULL. Good catch Stefan! Py_XDECREF ahould be used instead of Py_DECREF in _PyModule_AddObject(). -- ___ Python tracker

[issue26871] Change weird behavior of PyModule_AddObject()

2016-04-27 Thread Stefan Krah
Stefan Krah added the comment: It seems that the patch also introduces a segfault if PyLong_FromSsize_t() returns NULL. -- nosy: +skrah ___ Python tracker ___ __

[issue26871] Change weird behavior of PyModule_AddObject()

2016-04-27 Thread Stefan Krah
Changes by Stefan Krah : -- nosy: -skrah ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.o

[issue26871] Change weird behavior of PyModule_AddObject()

2016-04-27 Thread Stefan Krah
Stefan Krah added the comment: Your definition of correctness is very odd. The "leaks" you are talking about are single references in case of a module initialization failure, in which case you are likely to have much bigger problems. Please take _decimal out of this patch, it's a waste of time.

[issue26871] Change weird behavior of PyModule_AddObject()

2016-04-27 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Idiomatic code is if (PyModule_AddObject(module, "name", create_new_object()) < 0) goto error; If you already have a reference and need to use it later: obj = create_new_object(); ... /* use obj */ Py_INCREF(); if (PyModule_AddObj

[issue26871] Change weird behavior of PyModule_AddObject()

2016-04-27 Thread Stefan Krah
Stefan Krah added the comment: I think the current behavior is good for error handling by goto, which is common for module initialization. Please don't change this. -- nosy: +skrah ___ Python tracker _

[issue26871] Change weird behavior of PyModule_AddObject()

2016-04-27 Thread Serhiy Storchaka
New submission from Serhiy Storchaka: PyModule_AddObject() has weird and counterintuitive behavior. It steals a reference only on success. The caller is responsible to decref it on error. This behavior was not documented and inconsistent with the behavior of other functions stealing a referenc