[issue26868] Incorrect check for return value of PyModule_AddObject in _csv.c

2016-04-27 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: As for Modules/_csv.c, I think it is better to change the behavior of PyModule_AddObject() (issue26871). This will fix similar issues in all modules. -- dependencies: +Change weird behavior of PyModule_AddObject()

[issue26868] Incorrect check for return value of PyModule_AddObject in _csv.c

2016-04-27 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Added comments on Rietveld. -- ___ Python tracker ___ ___

[issue26868] Incorrect check for return value of PyModule_AddObject in _csv.c

2016-04-27 Thread Berker Peksag
Berker Peksag added the comment: Thanks for the write-up, Serhiy. It looks like "... == -1" is more popular in the codebase (for PyModule_AddObject, "... < 0" is the most popular style). Here is a patch to document the current behavior of PyModule_AddObject. -- Added file:

[issue26868] Incorrect check for return value of PyModule_AddObject in _csv.c

2016-04-27 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Testing returned value of PyModule_AddObject() is correct. This is a matter of style what to use: `if (...)`, `if (... == -1)` or `if (... < 0)`. But the problem with a leak is more general. I have opened a discussion on Python-Dev:

[issue26868] Incorrect check for return value of PyModule_AddObject in _csv.c

2016-04-26 Thread Berker Peksag
New submission from Berker Peksag: This is probably harmless, but Modules/_csv.c has the following code: Py_INCREF(_Type); if (PyModule_AddObject(module, "Dialect", (PyObject *)_Type)) return NULL; However, PyModule_AddObject returns only -1 and 0. It also doesn't decref