diff -r b110dd3d6cea Lib/inspect.py --- a/Lib/inspect.py Thu Jun 02 10:20:16 2016 -0700 +++ b/Lib/inspect.py Thu Jun 02 11:42:38 2016 -0700 @@ -2396,7 +2396,8 @@ if not isinstance(name, str): raise TypeError("name must be a str, not a {!r}".format(name)) - if not name.isidentifier(): + # handle implicit arguments to set comprehensions + if not name.isidentifier() and not (name[0] == '.' and name[1:].isdigit()): raise ValueError('{!r} is not a valid parameter name'.format(name)) self._name = name diff -r b110dd3d6cea Lib/test/test_inspect.py --- a/Lib/test/test_inspect.py Thu Jun 02 10:20:16 2016 -0700 +++ b/Lib/test/test_inspect.py Thu Jun 02 11:42:38 2016 -0700 @@ -2903,6 +2903,10 @@ 'is not a valid parameter name'): inspect.Parameter('$', kind=inspect.Parameter.VAR_KEYWORD) + with self.assertRaisesRegex(ValueError, + 'is not a valid parameter name'): + inspect.Parameter('.a', kind=inspect.Parameter.VAR_KEYWORD) + with self.assertRaisesRegex(ValueError, 'cannot have default values'): inspect.Parameter('a', default=42, kind=inspect.Parameter.VAR_KEYWORD) @@ -2919,6 +2923,9 @@ self.assertTrue(repr(p).startswith('