[issue20144] Argument Clinic doesn't support named constants as default values

Larry Hastings report at bugs.python.org
Mon Jan 6 17:38:52 CET 2014


Larry Hastings added the comment:

"sys.maxsize" won't work.  inspect.Signature parses the __text_signature__ using ast.parse, and it only recognizes constant values and named constants (True/False/None) for the default value for parameters.  Playing with ast, it looks like we'd have to support a tree of Attribute nodes, then look up sys (or whatever) and recursively getattr on it.  Which would be new code.

Anyway it seems like a bad idea:

    import inspect
    import re
    import sys

    sys.maxsize = 3
    inspect.signature(re.compile(".*").match)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20144>
_______________________________________


More information about the Python-bugs-list mailing list