Skip to content

Commit 57002a7

Browse files
committed
Update Python inlined files: 3.12.8
1 parent e163032 commit 57002a7

File tree

1,309 files changed

+130392
-52660
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,309 files changed

+130392
-52660
lines changed

graalpython/com.oracle.graal.python.pegparser.generator/input_files/Tokens

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,20 @@ ATEQUAL '@='
5353
RARROW '->'
5454
ELLIPSIS '...'
5555
COLONEQUAL ':='
56+
EXCLAMATION '!'
5657

5758
OP
5859
AWAIT
5960
ASYNC
6061
TYPE_IGNORE
6162
TYPE_COMMENT
6263
SOFT_KEYWORD
64+
FSTRING_START
65+
FSTRING_MIDDLE
66+
FSTRING_END
67+
COMMENT
68+
NL
6369
ERRORTOKEN
6470

6571
# These aren't used by the C tokenizer but are needed for tokenize.py
66-
COMMENT
67-
NL
6872
ENCODING

graalpython/com.oracle.graal.python.pegparser.generator/input_files/python.gram

Lines changed: 116 additions & 28 deletions
Large diffs are not rendered by default.

graalpython/com.oracle.graal.python.pegparser.generator/pegen/build.py

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import itertools
2+
import os
23
import pathlib
34
import sys
45
import sysconfig
@@ -27,6 +28,46 @@ def get_extra_flags(compiler_flags: str, compiler_py_flags_nodist: str) -> List[
2728
return f"{flags} {py_flags_nodist}".split()
2829

2930

31+
def fixup_build_ext(cmd):
32+
"""Function needed to make build_ext tests pass.
33+
34+
When Python was built with --enable-shared on Unix, -L. is not enough to
35+
find libpython<blah>.so, because regrtest runs in a tempdir, not in the
36+
source directory where the .so lives.
37+
38+
When Python was built with in debug mode on Windows, build_ext commands
39+
need their debug attribute set, and it is not done automatically for
40+
some reason.
41+
42+
This function handles both of these things. Example use:
43+
44+
cmd = build_ext(dist)
45+
support.fixup_build_ext(cmd)
46+
cmd.ensure_finalized()
47+
48+
Unlike most other Unix platforms, Mac OS X embeds absolute paths
49+
to shared libraries into executables, so the fixup is not needed there.
50+
51+
Taken from distutils (was part of the CPython stdlib until Python 3.11)
52+
"""
53+
if os.name == 'nt':
54+
cmd.debug = sys.executable.endswith('_d.exe')
55+
elif sysconfig.get_config_var('Py_ENABLE_SHARED'):
56+
# To further add to the shared builds fun on Unix, we can't just add
57+
# library_dirs to the Extension() instance because that doesn't get
58+
# plumbed through to the final compiler command.
59+
runshared = sysconfig.get_config_var('RUNSHARED')
60+
if runshared is None:
61+
cmd.library_dirs = ['.']
62+
else:
63+
if sys.platform == 'darwin':
64+
cmd.library_dirs = []
65+
else:
66+
name, equals, value = runshared.partition('=')
67+
cmd.library_dirs = [d for d in value.split(os.pathsep) if d]
68+
69+
70+
3071
def compile_c_extension(
3172
generated_source_path: str,
3273
build_dir: Optional[str] = None,
@@ -49,16 +90,15 @@ def compile_c_extension(
4990
static library of the common parser sources (this is useful in case you are
5091
creating multiple extensions).
5192
"""
52-
import distutils.log
53-
from distutils.core import Distribution, Extension
54-
from distutils.tests.support import fixup_build_ext # type: ignore
93+
import setuptools.logging
5594

56-
from distutils.ccompiler import new_compiler
57-
from distutils.dep_util import newer_group
58-
from distutils.sysconfig import customize_compiler
95+
from setuptools import Extension, Distribution
96+
from setuptools._distutils.dep_util import newer_group
97+
from setuptools._distutils.ccompiler import new_compiler
98+
from setuptools._distutils.sysconfig import customize_compiler
5999

60100
if verbose:
61-
distutils.log.set_threshold(distutils.log.DEBUG)
101+
setuptools.logging.set_threshold(setuptools.logging.logging.DEBUG)
62102

63103
source_file_path = pathlib.Path(generated_source_path)
64104
extension_name = source_file_path.stem

graalpython/com.oracle.graal.python.pegparser.generator/pegen/c_generator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include "pegen.h"
3333
3434
#if defined(Py_DEBUG) && defined(Py_BUILD_CORE)
35-
# define D(x) if (Py_DebugFlag) x;
35+
# define D(x) if (p->debug) { x; }
3636
#else
3737
# define D(x)
3838
#endif
@@ -68,6 +68,7 @@ class NodeTypes(Enum):
6868
KEYWORD = 4
6969
SOFT_KEYWORD = 5
7070
CUT_OPERATOR = 6
71+
F_STRING_CHUNK = 7
7172

7273

7374
BASE_NODETYPES = {
@@ -374,8 +375,7 @@ def __init__(
374375
def add_level(self) -> None:
375376
self.print("if (p->level++ == MAXSTACK) {")
376377
with self.indent():
377-
self.print("p->error_indicator = 1;")
378-
self.print("PyErr_NoMemory();")
378+
self.print("_Pypegen_stack_overflow(p);")
379379
self.print("}")
380380

381381
def remove_level(self) -> None:

graalpython/com.oracle.graal.python.pegparser.generator/pegen/grammar.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
11
from __future__ import annotations
22

3-
from abc import abstractmethod
43
from typing import (
5-
TYPE_CHECKING,
64
AbstractSet,
75
Any,
8-
Dict,
96
Iterable,
107
Iterator,
118
List,
129
Optional,
13-
Set,
1410
Tuple,
1511
Union,
1612
)
1713

18-
if TYPE_CHECKING:
19-
from pegen.parser_generator import ParserGenerator
20-
2114

2215
class GrammarError(Exception):
2316
pass
@@ -42,7 +35,13 @@ def generic_visit(self, node: Iterable[Any], *args: Any, **kwargs: Any) -> Any:
4235

4336
class Grammar:
4437
def __init__(self, rules: Iterable[Rule], metas: Iterable[Tuple[str, Optional[str]]]):
45-
self.rules = {rule.name: rule for rule in rules}
38+
# Check if there are repeated rules in "rules"
39+
all_rules = {}
40+
for rule in rules:
41+
if rule.name in all_rules:
42+
raise GrammarError(f"Repeated rule {rule.name!r}")
43+
all_rules[rule.name] = rule
44+
self.rules = all_rules
4645
self.metas = dict(metas)
4746

4847
def __str__(self) -> str:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)