[issue23934] inspect.signature reporting () for all builtin extension types

2015-05-30 Thread Yury Selivanov

Changes by Yury Selivanov yseliva...@gmail.com:


--
resolution:  - fixed
stage: test needed - resolved
status: open - closed

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



[issue23934] inspect.signature reporting () for all builtin extension types

2015-05-30 Thread Roundup Robot

Roundup Robot added the comment:

New changeset e59966bb6de5 by Yury Selivanov in branch '3.5':
Issue #23934: Fix inspect.signature to fail correctly for builtin types.
https://hg.python.org/cpython/rev/e59966bb6de5

New changeset 19e0ffdd1daa by Yury Selivanov in branch 'default':
Issue #23934: Fix inspect.signature to fail correctly for builtin types.
https://hg.python.org/cpython/rev/19e0ffdd1daa

--
nosy: +python-dev

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



[issue23934] inspect.signature reporting () for all builtin extension types

2015-04-13 Thread Nick Coghlan

Nick Coghlan added the comment:

The main missing piece now is test fodder for this error. The simplest 
near-term option would be to use one of the actual builtins, such as 'str'.

In Python 3.5+ we could borrow the matmulType that was added to _testcapi to 
test the @ operator, future-proofing the test against eventual conversion of 
the builtin types to support Argument Clinic.

--

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



[issue23934] inspect.signature reporting () for all builtin extension types

2015-04-13 Thread James Powell

James Powell added the comment:

See attached patch for unittest.

For 3.4, test that inspect.signature(str) raises TypeError.

For 3.5, this can be improved to use _testcapi.matmulType

--
Added file: http://bugs.python.org/file38949/issue_23934-test.patch

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



[issue23934] inspect.signature reporting () for all builtin extension types

2015-04-13 Thread Yury Selivanov

Yury Selivanov added the comment:

The patch looks good.

--

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



[issue23934] inspect.signature reporting () for all builtin extension types

2015-04-13 Thread James Powell

James Powell added the comment:

Discussed with Nick Coghlan.

See attached patch to return `signature(object)` only if both `__new__` and 
`__init__` are shared with `object`.

Otherwise, raise TypeError indicating built-in types not supported. 

https://docs.python.org/3/library/inspect.html#inspect.signature
Raises ValueError if no signature can be provided, and TypeError if that type 
of object is not supported.

--
keywords: +patch
Added file: http://bugs.python.org/file38936/issue_23934.patch

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



[issue23934] inspect.signature reporting () for all builtin extension types

2015-04-13 Thread Nick Coghlan

New submission from Nick Coghlan:

inspect.signature isn't currently handling builtin  extension types correctly 
- these show up as having neither __new__ *nor* __init__ as pure Python 
callables, so the inspect.signature logic falls through into a currently 
unhandled case.

_testcapi isn't currently exporting an extension type as docstring 
introspection fodder, only callables, so test_inspect didn't pick up the 
problem. The problem can be seen with builtin types like str:

 import inspect
 inspect.signature(str)
inspect.Signature object at 0x7fb81d44e518
 print(inspect.signature(str))
()

Expected behaviour would be to throw a ValueError as with builtin callables 
without a signature:

 import _testcapi
 import inspect
 inspect.signature(_testcapi.docstring_no_signature)
Traceback (most recent call last):
  File stdin, line 1, in module
  File /home/ncoghlan/devel/py3k/Lib/inspect.py, line 2830, in signature
return Signature.from_callable(obj)
  File /home/ncoghlan/devel/py3k/Lib/inspect.py, line 2586, in from_callable
return _signature_from_callable(obj, sigcls=cls)
  File /home/ncoghlan/devel/py3k/Lib/inspect.py, line 2064, in 
_signature_from_callable
skip_bound_arg=skip_bound_arg)
  File /home/ncoghlan/devel/py3k/Lib/inspect.py, line 1984, in 
_signature_from_builtin
raise ValueError(no signature found for builtin {!r}.format(func))
ValueError: no signature found for builtin built-in function 
docstring_no_signature

--
messages: 240649
nosy: james, larry, ncoghlan, yselivanov
priority: normal
severity: normal
stage: test needed
status: open
title: inspect.signature reporting () for all builtin  extension types
type: behavior
versions: Python 3.4, Python 3.5

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



[issue23934] inspect.signature reporting () for all builtin extension types

2015-04-13 Thread Larry Hastings

Larry Hastings added the comment:

Would this qualify as an easy bug we could throw to a sprinter?

--

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



[issue23934] inspect.signature reporting () for all builtin extension types

2015-04-13 Thread Nick Coghlan

Nick Coghlan added the comment:

James Powell is currently looking into this at the PyCon sprints.

The key problem appears to be the check that assumes obj.__init__ is 
object.__init__ indicates that there's no user defined init or new method, 
when in fact a builtin or extension type that only overrides __new__ would also 
pass that check (since the earlier check for __new__ returns None if the method 
implementation isn't a pure Python callable)

--

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