Issue 13665: TypeError: string or integer address expected instead of str instance (original) (raw)

Issue13665

Created on 2011-12-26 17:50 by jaraco, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue13665.diff ezio.melotti,2012-01-16 06:00 Patch against 3.2
Messages (4)
msg150271 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2011-12-26 17:50
When constructing a ctypes.c_char_p with a unicode string, a confusing error message is reported: > python -c "import ctypes; ctypes.c_char_p('foo')" Traceback (most recent call last): File "", line 1, in TypeError: string or integer address expected instead of str instance Since "string" and "str" seem like essentially the same thing, the error message doesn't make sense. This message is obviously due to the change to unicode as the default string instance in Python 3. The error message should probably be updated to read "bytes or integer address expected instead of a str instance". It's probably also worth scanning through the ctypes codebase for similar messages.
msg151324 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-01-16 06:00
Here's a patch. I found a similar instance that says "unicode string or integer address expected instead of %s instance", but it's inside an "if (!PyUnicode_Check(value)) {}" so it should be ok ("unicode string" could be replaced to 'str' though).
msg151372 - (view) Author: Meador Inge (meador.inge) * (Python committer) Date: 2012-01-16 15:14
LGTM. Thanks for fixing this.
msg151514 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-01-18 03:43
New changeset b4d9243d16c9 by Ezio Melotti in branch '3.2': #13665: s/string/bytes/ in error message. http://hg.python.org/cpython/rev/b4d9243d16c9 New changeset 0c0ffebfccb0 by Ezio Melotti in branch 'default': #13665: merge with 3.2. http://hg.python.org/cpython/rev/0c0ffebfccb0
History
Date User Action Args
2022-04-11 14:57:25 admin set github: 57874
2012-01-18 03:44:15 ezio.melotti set status: open -> closedassignee: ezio.melottiresolution: fixedstage: commit review -> resolved
2012-01-18 03:43:37 python-dev set nosy: + python-devmessages: +
2012-01-16 15:14:36 meador.inge set messages: +
2012-01-16 06:00:52 ezio.melotti set files: + issue13665.diffkeywords: + patchmessages: + stage: needs patch -> commit review
2012-01-02 17:36:15 ezio.melotti set nosy: + ezio.melottitype: enhancementstage: needs patch
2011-12-30 21:13:18 terry.reedy set nosy: + amaury.forgeotdarc, meador.inge
2011-12-26 17:50:34 jaraco create