-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Description
Bug report
Bug description:
Hi, I'm working on a Python testing project, and our tool detected the following issue:
from token import ISNONTERMINAL, ISTERMINAL
ISNONTERMINAL(0.5)
ISTERMINAL(0.5)As it turned out, CPython had no complaints and executed smoothly.
However, the CPython source file token.py indicates that the input for ISNONTERMINAL and ISTERMINAL should be integer-type enumeration values, or more strictly, should only accept values defined within token.py.
Coincidentally, I ran the same test on the same version of PyPy and found that PyPy produced a different but more reasonable error:
TypeError: expected integer, got float objectThis indicates that PyPy performs the relevant checks, even if not in the strictest form.
This may be considered an implementation bug in CPython. Type checking for input values should be supplemented to produce behavior similar to PyPy.
By the way, in my view, the approach suggested for issue 86353 is also a workable solution.
CPython versions tested on:
3.13
Operating systems tested on:
Linux