Issue 14201: Documented caching for shared library's getattr and getitem is incorrect (original) (raw)

process

Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: amaury.forgeotdarc, belopolsky, docs@python, eric.araujo, erijo, loewis, meador.inge, python-dev, r.david.murray, theller
Priority: normal Keywords: easy, patch

Created on 2012-03-05 14:23 by erijo, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue14201.patch erijo,2012-07-16 19:13 Patch to documentation review
issue14201-v2.patch meador.inge,2012-07-20 03:42
Messages (12)
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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) (Python triager) 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) * (Python committer) Date: 2014-10-04 22:27
Committed. See also issue 22552.
History
Date User Action Args
2022-04-11 14:57:27 admin set github: 58409
2014-10-04 22:27:59 r.david.murray set status: open -> closednosy: + r.david.murraymessages: + resolution: fixedstage: commit review -> resolved
2014-10-04 22:26:51 python-dev set nosy: + python-devmessages: +
2012-09-25 18:03:15 erijo set messages: +
2012-07-26 04:02:02 meador.inge set messages: +
2012-07-20 03:42:11 meador.inge set files: + issue14201-v2.patchmessages: + stage: needs patch -> commit review
2012-07-16 19:13:33 erijo set files: + issue14201.patchkeywords: + patchmessages: +
2012-03-07 15:34:01 erijo set messages: + title: libc.time != libc['time'] -> Documented caching for shared library's __getattr__ and __getitem__ is incorrect
2012-03-07 15:08:30 eric.araujo set assignee: docs@pythoncomponents: + Documentationkeywords: + easynosy: + docs@python, eric.araujomessages: + stage: needs patch
2012-03-07 14:56:40 erijo set messages: +
2012-03-07 14:02:17 theller set messages: +
2012-03-05 16:13:24 loewis set nosy: + theller, loewismessages: +
2012-03-05 15:11:49 pitrou set nosy: + amaury.forgeotdarc, belopolsky, meador.ingeversions: + Python 3.2, Python 3.3
2012-03-05 14:23:40 erijo create