-
-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trac #27971: py3 failures in sage/misc/sageinspect.py and sagedoc.py
The Python 3 doctest failures in `sage/misc/sageinspect.py` and `sage/misc/sagedoc.py` all arise because of the second line here (from `sageinspect.py`): {{{ spec = sage_getargspec(obj) s = str(inspect.formatargspec(*spec)) }}} The problem is that `inspect.formatargspec` is deprecated in Python 3.5, so it prints warning messages. From Sage's point of view, this is annoying, because there is no direct replacement (as far as I can tell) for `inspect.formatargspec`. The [https://docs.python.org/3/library/inspect.html#inspect.formatargspec documentation] says to use `signature` and `Signature`, but we have already obtained the signature information using `sage_getargspec` and just want to format it. Also, `inspect.signature` doesn't seem to work on Cython functions — see cython [cython/cython#1864 issue 1864], or for a Sage-specific example: {{{ sage: import inspect sage: from sage.misc.sageinspect import sage_getargspec sage: from sage.rings.integer import int_to_Z sage: sage_getargspec(int_to_Z) ArgSpec(args=['self', 'x'], varargs='args', keywords='kwds', defaults=None) }}} At this point, with Python 2: {{{ sage: inspect.getargspec(long_to_Z) ... TypeError: <type 'sage.rings.integer.long_to_Z'> is not a Python function }}} With Python 3: {{{ sage: inspect.signature(int_to_Z) ... ValueError: no signature found for builtin type <class 'sage.rings.integer.int_to_Z'> }}} Fixing this may also fix #27578. URL: https://trac.sagemath.org/27971 Reported by: jhpalmieri Ticket author(s): John Palmieri Reviewer(s): Vincent Klein
- Loading branch information
Showing
2 changed files
with
129 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters