This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author JelleZijlstra
Recipients JelleZijlstra, nedbat
Date 2016-06-02.18:43:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
This doesn't work in Python 3.6 (current dev version) either. Using Ned's example, I get (snipping some of the ipython stack trace):

/home/jelle/cpython-dev/cpython/Lib/ in __init__(self, name, kind, default, annotation)
   2399         if not name.isidentifier():
-> 2400             raise ValueError('{!r} is not a valid parameter name'.format(name))

ValueError: '.0' is not a valid parameter name

fails with the same error.

However, both work if I take out the isidentifier check.

In Python 2.7, the bug is actually in inspect.getargs:

In [7]: inspect.getargs(setcomp_func.func_code)
Out[7]: Arguments(args=[['z']], varargs=None, keywords=None)

which assumes that any ".0" argument is a tuple.

I'm not sure the bug in 2.7 is worth fixing, since it will require fragile bytecode manipulation to distinguish tuple arguments from set comprehensions, and you can get to this case only by manually creating function objects. 

I think the Python 3 level bug is worth fixing though, since it's an easy fix (just make the .isidentifier call accept names of the form .0). I'm attaching a patch against master with tests. I have signed the contributor agreement.
Date User Action Args
2016-06-02 18:43:32JelleZijlstrasetrecipients: + JelleZijlstra, nedbat
2016-06-02 18:43:32JelleZijlstrasetmessageid: <>
2016-06-02 18:43:32JelleZijlstralinkissue19611 messages
2016-06-02 18:43:32JelleZijlstracreate