Message289514
I am sorry, but I guess I am missing something about startswith() and
endswith().
ISTM that PyTuple_Check() is already called by unicode_startswith,
unicode_endswith and _Py_bytes_tailmatch, which already raise a TypeError
with an appropriate error message
(e.g. "%s first arg must be bytes or a tuple of bytes, not %s").
I searched the codebase, and found that in most places, if PyIndex_Check(obj)
is true, then obj is described as 'integer' in error messages. rarely, obj
would be described as 'int'.
I found only two relevant TypeError messages of functions that accept an
integer type or None (BTW, I took the term 'integer type' from
https://docs.python.org/3.7/reference/atamodel.html?highlight=__index__#object.__index__.):
- in Modules/posixmodule.c in dir_fd_converter():
PyErr_Format(PyExc_TypeError,
"argument should be integer or None, not %.200s",
Py_TYPE(o)->tp_name);
- in Modules/_functoolsmodule.c in lru_cache_new():
PyErr_SetString(PyExc_TypeError, "maxsize should be integer or None");
so I changed the error messages in my patch to the form of
'argument should be ...' (which is, IMHO, much clearer).
also, now that the new PR was created, should I close the old one? |
|
Date |
User |
Action |
Args |
2017-03-12 22:01:23 | Oren Milman | set | recipients:
+ Oren Milman, rhettinger, mark.dickinson, serhiy.storchaka |
2017-03-12 22:01:23 | Oren Milman | set | messageid: <1489356083.81.0.109087763533.issue29730@psf.upfronthosting.co.za> |
2017-03-12 22:01:23 | Oren Milman | link | issue29730 messages |
2017-03-12 22:01:23 | Oren Milman | create | |
|