STINNER Victor added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28959>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to