[issue11256] inspect.getcallargs raises TypeError on valid arguments

2011-03-28 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset 57e99f5f5e8f by Benjamin Peterson in branch '3.2':
Correct handling of functions with only kwarg args in getcallargs (closes 
#11256)
http://hg.python.org/cpython/rev/57e99f5f5e8f

New changeset b19d76d9d2a7 by Benjamin Peterson in branch '2.7':
Correct handling of functions with only kwarg args in getcallargs (closes 
#11256)
http://hg.python.org/cpython/rev/b19d76d9d2a7

--
nosy: +python-dev
resolution:  -> fixed
stage:  -> committed/rejected
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11256] inspect.getcallargs raises TypeError on valid arguments

2011-03-18 Thread Daniel Urban

Daniel Urban  added the comment:

Updated the patch for mercurial.

--
Added file: http://bugs.python.org/file21281/issue11256_4.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11256] inspect.getcallargs raises TypeError on valid arguments

2011-02-27 Thread Daniel Urban

Daniel Urban  added the comment:

I found another case, when this is a problem: if there are no **kwargs, but 
there are some keyword-only arguments:

>>> def f(*, a, b): pass
... 
>>> f(a=1, b=2)
>>> 
>>> getcallargs(f, a=1, b=2)
Traceback (most recent call last):
...
TypeError: f() takes no arguments (2 given)

The attached issue11256_3.diff patch also fixes this problem, and adds tests 
that would have detected this case.

--
Added file: http://bugs.python.org/file20930/issue11256_3.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11256] inspect.getcallargs raises TypeError on valid arguments

2011-02-26 Thread Andreas Stührk

Andreas Stührk  added the comment:

Confirmed under Python 2.7, 3.2 and 3.3. Patch looks good to me. Attached is a 
patch for 2.7.

--
nosy: +Trundle
Added file: http://bugs.python.org/file20927/issue11256_py27.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11256] inspect.getcallargs raises TypeError on valid arguments

2011-02-26 Thread Daniel Urban

Daniel Urban  added the comment:

Updated patch with extra tests.

--
Added file: http://bugs.python.org/file20911/issue11256_2.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11256] inspect.getcallargs raises TypeError on valid arguments

2011-02-20 Thread Daniel Urban

Daniel Urban  added the comment:

Here is a patch. It also includes tests that would have detected this bug. It 
also corrects a case when getcallargs raised an exception with a different 
message (there are tests also for this):

>>> def f(**kwargs): pass
... 
>>> f(1, a=2)
Traceback (most recent call last):
...
TypeError: f() takes exactly 0 positional arguments (2 given)
>>> 
>>> getcallargs(f, 1, a=2)
Traceback (most recent call last):
...
TypeError: f() takes no arguments (2 given)

There is a comment in the patch about this case: the message given by Python is 
also incorrect, because it says that 2 positional arguments are given, but 
there was only 1 positional argument (the other was a keyword argument).  The 
patch currently handles this case by producing the same (incorrect) message as 
Python.

--
keywords: +patch
Added file: http://bugs.python.org/file20805/issue11256.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11256] inspect.getcallargs raises TypeError on valid arguments

2011-02-20 Thread Daniel Urban

New submission from Daniel Urban :

inspect.getcallargs raises TypeError if given a function with only **kwargs, 
and some keyword arguments:

Python 3.3a0 (py3k:88451, Feb 20 2011, 12:37:22) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> from inspect import getcallargs
>>> 
>>> def f(**kwargs): pass
... 
>>> f(a=1, b=2)
>>> 
>>> getcallargs(f, a=1, b=2)
Traceback (most recent call last):
...
TypeError: f() takes no arguments (2 given)


In line 946 of inspect.py the "num_args == 0 and num_total" condition is true: 
the function expects 0 positional arguments and got more than zero arguments, 
but in this case these are keyword arguments, so it shouldn't raise TypeError.

--
components: Library (Lib)
messages: 128902
nosy: benjamin.peterson, durban, gsakkis
priority: normal
severity: normal
status: open
title: inspect.getcallargs raises TypeError on valid arguments
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com