[Python-Dev] Patch review & request

Michiel Jan Laurens de Hoon mdehoon at ims.u-tokyo.ac.jp
Sun Feb 27 16:09:35 CET 2005

This is my last patch review in a series of five; next time I'll send them in a 
bunch of five as requested. I reviewed the following patches:

[ 684500 ] extending readline functionality
[ 723201 ] PyArg_ParseTuple problem with 'L' format
[ 981773 ] crach link c++ extension by mingw
[ 985713 ] bug skipping optional keyword arguments of type "w#"
[ 1093585 ] sanity check for readline remove/replace

I'd like to ask your attention for patch #1121234, which is a bug fix for a 
reference count problem in Tkinter. Nothing complicated, don't worry.



Patch [ 985713 ] bug skipping optional keyword arguments of type "w#"

The convertsimple function in Python/getargs.c converts arguments for 
PyArg_Parse, PyArg_ParseTuple etc. The function skipitem takes care of skipping 
optional keyword arguments. Some of the valid formats are included in 
convertsimple but missing in skipitem. The patch shows the example of the "w#" 
format. If the argument format is "s|w#H" with corresponding keywords "string", 
"buffer", "ushort", you can skip the "ushort" keyword but not the "buffer" 
keyword. So this works:
 >>> my_dummy_func("text", buffer=my_buffer)
but this doesn't:
 >>> my_dummy_func("text", ushort=my_ushort)
It results in the error message

Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: argument 2 impossible<bad format char>

The patch fixes this by adding the appropriate formats to the skipitem function. 
The patch was written for the "w#" format; other formats that are missing are 
listed in the patch description.
It seems that the missing formats in the skipitem function are simply due to an 
oversight. Running the test suite revealed no problems with this patch. So I 
think it can be applied.

Michiel de Hoon, Assistant Professor
University of Tokyo, Institute of Medical Science
Human Genome Center
4-6-1 Shirokane-dai, Minato-ku
Tokyo 108-8639

More information about the Python-Dev mailing list