◐ Shell
clean mode source ↗

Issue 5666: Py_BuildValue("c") should return bytes?

Created on 2009-04-02 09:04 by ocean-city, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
py3k_build_value.patch ocean-city, 2009-04-02 09:04
py3k_build_value-2.patch vstinner, 2009-04-02 11:31
Messages (4)
msg85184 - (view) Author: Hirokazu Yamamoto (ocean-city) * (Python committer) Date: 2009-04-02 09:04
This is related to #5499. PyArg_ParseTuple treats "c" as bytes of 1
length now, but Py_BuildValue still treats "c" as unicode of 1 length.
msg85195 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2009-04-02 11:17
Let's try grep on py3k:
 grep 'Py_BuildValue("[^"]*c' $(find -name "*.c")

Py_BuildValue("c") is used for:
 - mmap.read_byte() result
 - <curses window>.getkey() result: this method returns also unicode 
string => your patch breaks getkey()!
 - array.__reduce__(): i don't understand if the patch breaks anything

I think that curses and array should use "C" format, but... it doesn't 
exist for Py_BuildValue. It was maybe forgotten.
msg85196 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2009-04-02 11:31
> "C" format, but... it doesn't exist for Py_BuildValue

Ooops, it does exist but it looks that nobody uses it. It's also not 
documented :-( I wrote a new patch:
 - document "C" format for Py_BuildValue (fix also a typo)
 - use "C" format in array and _curses
 - (and leave ocean-city's changes unchanged)
msg85339 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-04-03 22:19
Applied the patch in r71107. The issues these depend on can be fixed now.
History
Date User Action Args
2022-04-11 14:56:47adminsetgithub: 49916
2009-04-03 22:19:17benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg85339

resolution: fixed

2009-04-02 11:31:32vstinnersetfiles: + py3k_build_value-2.patch

messages: + msg85196

2009-04-02 11:17:40vstinnersetmessages: + msg85195
2009-04-02 09:48:42vstinnersetnosy: + vstinner
2009-04-02 09:07:05ocean-citylinkissue5391 dependencies
2009-04-02 09:04:53ocean-citycreate