Code review comment for lp:~jamesodhunt/python-apt/test-for-size_to_str

Revision history for this message
Barry Warsaw (barry) wrote :

Note that if you wanted to be strict about it (generally not a bad idea when dealing with the Python C API), setattr() in progress.cc should really be checking the return value of Py_BuildValue() too; if that returns NULL, then setattr() should return 0 before calling PyObject_SetAttrString().

As for checking the return value of setattr(), that's probably a good idea to do. The alternative is to be optimistic, don't check the return values, and then do a blanket check of PyErr_Occurred() to see if any of them failed. In some sense, it's not as safe, but practically speaking it's probably good enough, especially since if any of them fail, you're probably in trouble. It's probably not a good idea to just let exceptions pass unchecked - that was one of the fundamental problems with LP: #1030278.

« Back to merge proposal