Larry Hastings added the comment:

As an example, consider pattern_match() in _sre.c.  This implements the match 
method on a pattern object; in other words, re.compile().match().  The third 
parameter, endpos, defaults to PY_SSIZE_T_MAX in C.  What should 
inspect.Signature() report as the default value for endpos?  We can't look up 
the proper value for PY_SSIZE_T_MAX, because the default value 
inspect.Signature() uses was written out as text when Argument Clinic processed 
the function.

As a hint, the documentation for match() dodges this problem by outright lying. 
 It claims that the prototype for the function is:

    match(string[, pos[, endpos]])

which is a lie.  pattern_match() parses its arguments by calling 
PyArg_ParseTupleAndKeywords() with a format string of "O|nn".  which means, for 
example, you could call:

    match("abc", endpos=5)

The documentation claims this is invalid but it works fine.

In other words, it's a sticky problem, and the people who had it before us 
didn't try to solve it properly.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue20144>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to