Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Description
Bug report
Bug description:
Hi, I'm working on a Python testing project, and our tool detected the following issue:
fromtokenimportISNONTERMINAL,ISTERMINALISNONTERMINAL(0.5)ISTERMINAL(0.5)
As it turned out, CPython had no complaints and executed smoothly.
However, the CPython source filetoken.py indicates that the input forISNONTERMINAL andISTERMINAL should be integer-type enumeration values, or more strictly, should only accept values defined withintoken.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 object
This 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 forissue 86353 is also a workable solution.
CPython versions tested on:
3.13
Operating systems tested on:
Linux