Author vstinner
Recipients inada.naoki, rhettinger, serhiy.storchaka, vstinner
Date 2016-12-14.16:08:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1481731721.37.0.860145955607.issue28959@psf.upfronthosting.co.za>
In-reply-to
Content
Ignore my previous comment, PyDict_GET_SIZE-3.patch LGTM.


> I don't think the changes in _datetimemodule.c and typeobject.c change the behavior.

Oh wait, it seems like I misunderstood the new code.

Modules/_datetimemodule.c:

         dictptr = _PyObject_GetDictPtr(self);
-        if (dictptr && *dictptr && PyDict_Size(*dictptr)) {
+        if (dictptr && *dictptr &&
+            (!PyDict_Check(*dictptr) || PyDict_GET_SIZE(*dictptr))) {
             state = *dictptr;

If *dictptr is set and is not a dict, the test is true for the old and new code. Hum, I misunderstood the new code: I understood that (!PyDict_Check(*dictptr) || PyDict_GET_SIZE(*dictptr)) is false is *dictptr is not a dict, but it's true.

Hum, the only difference is that the old code raises an exception (SystemError), the new code doesn't raise an exception.

Since I'm not able to create an object with a __dict__ attribute which is not a dict, I don't really case of the small behaviour change.
History
Date User Action Args
2016-12-14 16:08:41vstinnersetrecipients: + vstinner, rhettinger, inada.naoki, serhiy.storchaka
2016-12-14 16:08:41vstinnersetmessageid: <1481731721.37.0.860145955607.issue28959@psf.upfronthosting.co.za>
2016-12-14 16:08:41vstinnerlinkissue28959 messages
2016-12-14 16:08:41vstinnercreate