[issue13840] create_string_buffer rejects str init_or_size parameter
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset be9d02536a81 by Meador Inge in branch '3.2': - Issue #13840: Fix ctypes.create_string_buffer exception message and docs. http://hg.python.org/cpython/rev/be9d02536a81 New changeset 52f68c95e025 by Meador Inge in branch 'default': - Issue #13840: Fix ctypes.create_string_buffer exception message and docs. http://hg.python.org/cpython/rev/52f68c95e025 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13840 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13840] create_string_buffer rejects str init_or_size parameter
Meador Inge mead...@gmail.com added the comment: I just fixed the docs and error message for now. I might revisit the ASCII decoding later. Thanks for the bug report Vincent. -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13840 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13840] create_string_buffer rejects str init_or_size parameter
Changes by Meador Inge mead...@gmail.com: -- nosy: +meador.inge ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13840 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13840] create_string_buffer rejects str init_or_size parameter
Meador Inge mead...@gmail.com added the comment: The 'create_unicode_buffer' docs are currently wrong too: If the first parameter is a bytes object, it is converted into an unicode string according to ctypes conversion rules. ctypes.create_unicode_buffer(b'foo') Traceback (most recent call last): File stdin, line 1, in module File /home/meadori/src/python/cpython/Lib/ctypes/__init__.py, line 294, in create_unicode_buffer buf.value = init TypeError: unicode string expected instead of bytes instance The attached patch fixes the documentation and exception messages. Although, it might be more friendly to implement things according to the current docs (i.e. do the conversions). -- components: +ctypes keywords: +patch stage: - patch review versions: +Python 3.3 Added file: http://bugs.python.org/file24319/issue13840.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13840 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13840] create_string_buffer rejects str init_or_size parameter
Vincent Pelletier plr.vinc...@gmail.com added the comment: Thanks for the quick reply. FWIW, in 2.7 doc ctype.create_string_buffer is said to accept unicode objects as parameter. I don't use this personally, so I don't mind 3.x only working on bytes - and already fixed my code accordingly. It's just that I noticed this after your answer. Also, I didn't try to confirm if it actually works. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13840 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13840] create_string_buffer rejects str init_or_size parameter
New submission from Vincent Pelletier plr.vinc...@gmail.com: ctypes.create_string_buffer documentation[1] says init_or_size parameter should accept a string. As of 3.2, it raises: import ctypes ctypes.create_string_buffer('foo') Traceback (most recent call last): File stdin, line 1, in module File /usr/lib/python3.2/ctypes/__init__.py, line 59, in create_string_buffer buf.value = init TypeError: str/bytes expected instead of str instance It works fine as of 2.7 (and very probably any 2.x up to ctypes introduction): import ctypes ctypes.create_string_buffer('foo') ctypes.c_char_Array_4 object at 0x7fbdcb8b95f0 [1] http://docs.python.org/py3k/library/ctypes.html#ctypes.create_string_buffer Regards, Vincent Pelletier -- components: ctypes messages: 151800 nosy: vpelletier priority: normal severity: normal status: open title: create_string_buffer rejects str init_or_size parameter type: behavior versions: Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13840 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13840] create_string_buffer rejects str init_or_size parameter
Georg Brandl ge...@python.org added the comment: It should only take bytes; str is Unicode in 3.x. So the docs and the error message are wrong, the behavior is correct. Reclassifying as a docs issue. -- assignee: - docs@python components: +Documentation -ctypes nosy: +docs@python, georg.brandl ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13840 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com