Skip to content

Commit 48b6cb1

Browse files
Commit
1 parent 7dfa048 commit 48b6cb1

File tree

7 files changed

+47
-7
lines changed

7 files changed

+47
-7
lines changed

Doc/deprecations/pending-removal-in-3.17.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@ Pending removal in Python 3.17
88
but it has been retained for backward compatibility, with removal scheduled for Python
99
3.17. Users should use documented introspection helpers like :func:`typing.get_origin`
1010
and :func:`typing.get_args` instead of relying on private implementation details.
11+
12+
* :mod:`token`:
13+
14+
- The :func:`token.ISTERMINAL`, :func:`token.ISNONTERMINAL` and
15+
:func:`token.ISEOF` tokens.

Doc/library/token.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,22 @@ a ``"match"`` token may be either :data:`NAME` or :data:`SOFT_KEYWORD`.
3535

3636
Return ``True`` for terminal token values.
3737

38+
.. deprecated-removed:: next 3.17
39+
3840

3941
.. function:: ISNONTERMINAL(x)
4042

4143
Return ``True`` for non-terminal token values.
4244

45+
.. deprecated-removed:: next 3.17
46+
4347

4448
.. function:: ISEOF(x)
4549

4650
Return ``True`` if *x* is the marker indicating the end of input.
4751

52+
.. deprecated-removed:: next 3.17
53+
4854

4955
The token constants are:
5056

Doc/whatsnew/3.15.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,15 @@ hashlib
440440
(Contributed by Bénédikt Tran in :gh:`134978`.)
441441

442442

443+
token
444+
-----
445+
446+
* The :func:`token.ISTERMINAL`, :func:`token.ISNONTERMINAL` and
447+
:func:`token.ISEOF` tokens are now deprecated, and will be removed
448+
in Python 3.17.
449+
(Contributed by Stan Ulbrych in :gh:`86353`)
450+
451+
443452
.. Add deprecations above alphabetically, not here at the end.
444453
445454
Removed

Include/internal/pycore_token.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ extern "C" {
8282
#define NL 66
8383
#define ERRORTOKEN 67
8484
#define N_TOKENS 69
85-
#define NT_OFFSET 256
85+
#define NT_OFFSET 256 /* Deprecated and will be removed in 3.17 */
8686

8787
/* Special definitions for cooperation with parser */
8888

89-
#define ISTERMINAL(x) ((x) < NT_OFFSET)
90-
#define ISNONTERMINAL(x) ((x) >= NT_OFFSET)
91-
#define ISEOF(x) ((x) == ENDMARKER)
89+
#define ISTERMINAL(x) ((x) < NT_OFFSET) /* Deprecated and will be removed in 3.17 */
90+
#define ISNONTERMINAL(x) ((x) >= NT_OFFSET) /* Deprecated and will be removed in 3.17 */
91+
#define ISEOF(x) ((x) == ENDMARKER) /* Deprecated and will be removed in 3.17 */
9292
#define ISWHITESPACE(x) ((x) == ENDMARKER || \
9393
(x) == NEWLINE || \
9494
(x) == INDENT || \

Lib/token.py

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Deprecate and schedule for removal in 3.17, :func:`token.ISTERMINAL`,
2+
:func:`token.ISNONTERMINAL` and :func:`token.ISEOF`.

Tools/build/generate_token.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ def update_file(file, content):
7979
8080
/* Special definitions for cooperation with parser */
8181
82-
#define ISTERMINAL(x) ((x) < NT_OFFSET)
83-
#define ISNONTERMINAL(x) ((x) >= NT_OFFSET)
84-
#define ISEOF(x) ((x) == ENDMARKER)
82+
#define ISTERMINAL(x) ((x) < NT_OFFSET) /* Deprecated and will be removed in 3.17 */
83+
#define ISNONTERMINAL(x) ((x) >= NT_OFFSET) /* Deprecated and will be removed in 3.17 */
84+
#define ISEOF(x) ((x) == ENDMARKER) /* Deprecated and will be removed in 3.17 */
8585
#define ISWHITESPACE(x) ((x) == ENDMARKER || \\
8686
(x) == NEWLINE || \\
8787
(x) == INDENT || \\
@@ -279,12 +279,21 @@ def make_rst(infile, outfile='Doc/library/token-list.inc',
279279
}
280280
281281
def ISTERMINAL(x: int) -> bool:
282+
import warnings
283+
warnings.warn('token.ISTERMINAL is deprecated and will be removed in 3.17',
284+
DeprecationWarning, stacklevel=2)
282285
return x < NT_OFFSET
283286
284287
def ISNONTERMINAL(x: int) -> bool:
288+
import warnings
289+
warnings.warn('token.ISNONTERMINAL is deprecated and will be removed in 3.17',
290+
DeprecationWarning, stacklevel=2)
285291
return x >= NT_OFFSET
286292
287293
def ISEOF(x: int) -> bool:
294+
import warnings
295+
warnings.warn('token.ISEOF is deprecated and will be removed in 3.17',
296+
DeprecationWarning, stacklevel=2)
288297
return x == ENDMARKER
289298
'''
290299

0 commit comments

Comments
 (0)