Vinay Sajip <vinay_sa...@yahoo.co.uk> added the comment:

I can confirm that the same behaviour occur in Python 3.3, and this appears to 
be by design. There's a specific line in the cast() function in in 
Modules/_ctypes.c:

rc = PyDict_SetItem(result->b_objects, index, src);

This adds the source object to the _objects of the cast object being returned. 
However, earlier in the function, the code

CDataObject *obj = (CDataObject *)src;

...

result->b_objects = obj->b_objects;

ensures that result and src are using a single dictionary. Possibly, the 
result's b_objects needs to be a copy of the src's b_objects; but I don't know 
enough about ctypes internals to say whether the present code is intentional, 
or whether an attempt to minimise resource usage (by not copying the 
dictionary) has led to unwanted consequences.

----------
nosy: +vinay.sajip
versions: +Python 3.3

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

Reply via email to