[Python-bugs-list] [ python-Bugs-418392 ] METH_OLDARGS allows bogus keywords

noreply@sourceforge.net noreply@sourceforge.net
Mon, 23 Apr 2001 16:02:32 -0700


Bugs item #418392, was updated on 2001-04-23 16:02
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=418392&group_id=5470

Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Barry Warsaw (bwarsaw)
Assigned to: Barry Warsaw (bwarsaw)
Summary: METH_OLDARGS allows bogus keywords

Initial Comment:
fileobj.close() is a method that's implemented using
PyArg_NoArgs() and METH_OLDARGS.  It allows bogus
keyword arguments, which are ignored, e.g.:

>>> fp = open('/tmp/foo', 'w')
>>> fp.close(bogus=1)

Also,

>>> fp = open('/tmp/foo', 'w')
>>> fp.write('hello', bogus=1)
TypeError: argument must be string or read-only
character buffer, not int
>>> fp.write('hello', bogus='world')
>>> ^D
% cat /tmp/foo
hello

The fix is to convert these to use METH_VARARGS.  I'm
submitting this bug report so it doesn't get forgotten. 


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=418392&group_id=5470