msg154949 - (view) |
Author: Erik Johansson (erijo) |
Date: 2012-03-05 14:23 |
I would expect that the following code would give True as result: >>> from ctypes import * >>> libc = CDLL("libc.so.6") >>> libc.time == libc['time'] False Is it by design that libc['time'] always returns a different _FuncPtr object? It is a bit confusing when doing things like: libc['time'].restype = ... libc['time'].argtypes = [...] # python --version Python 2.7.2+ Ubunutu version 2.7.2-5ubuntu1. |
|
|
msg154957 - (view) |
Author: Martin v. Löwis (loewis) *  |
Date: 2012-03-05 16:13 |
This is intentional; the caching was removed in 214b28d7a999. Thomas, can you remember the rationale for this change? |
|
|
msg155089 - (view) |
Author: Thomas Heller (theller) *  |
Date: 2012-03-07 14:02 |
The rationale was to allow different packages (for example) in the same process to have their own private instance of a foreign function, with possibly different definitions of restype, argtypes and/or errcheck. |
|
|
msg155091 - (view) |
Author: Erik Johansson (erijo) |
Date: 2012-03-07 14:56 |
Perhaps this behaviour should be documented somewhere (unless it already is)? |
|
|
msg155092 - (view) |
Author: Éric Araujo (eric.araujo) *  |
Date: 2012-03-07 15:08 |
Item access is documented in this section: http://docs.python.org/library/ctypes#loading-shared-libraries (scroll a bit down looking for __getitem__); the wording about caching is ambiguous with respect to the current behavior. |
|
|
msg155094 - (view) |
Author: Erik Johansson (erijo) |
Date: 2012-03-07 15:34 |
Ah, I see. I modified the title to reflect this. Perhaps adding this simple example as well can help people (e.g. me) see it? >>> libc.time == libc.time True >>> libc['time'] == libc['time'] False |
|
|
msg165646 - (view) |
Author: Erik Johansson (erijo) |
Date: 2012-07-16 19:13 |
Document the difference between __getattr__ and __getitem__. |
|
|
msg165898 - (view) |
Author: Meador Inge (meador.inge) *  |
Date: 2012-07-20 03:42 |
The general wording and example look good; thanks. I reworded things a little. Updated patch attached. |
|
|
msg166455 - (view) |
Author: Meador Inge (meador.inge) *  |
Date: 2012-07-26 04:02 |
Any comments on this one? I plan on committing the changes tomorrow unless I hear something otherwise. |
|
|
msg171302 - (view) |
Author: Erik Johansson (erijo) |
Date: 2012-09-25 18:03 |
The -v2.patch patch looks good to me at least. |
|
|
msg228505 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2014-10-04 22:26 |
New changeset ae64614b66b7 by R David Murray in branch '2.7': #14201: Update ctypes docs to match behavior changed from 214b28d7a999. https://hg.python.org/cpython/rev/ae64614b66b7 New changeset 5518aa0fbc06 by R David Murray in branch '3.4': #14201: Update ctypes docs to match behavior changed from 214b28d7a999. https://hg.python.org/cpython/rev/5518aa0fbc06 New changeset dfdcc3fad3aa by R David Murray in branch 'default': Merge: #14201: Update ctypes docs to match behavior changed from 214b28d7a999. https://hg.python.org/cpython/rev/dfdcc3fad3aa |
|
|
msg228507 - (view) |
Author: R. David Murray (r.david.murray) *  |
Date: 2014-10-04 22:27 |
Committed. See also issue 22552. |
|
|