File size: 4,848 Bytes
d0faac4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -13,6 +13,7 @@ on:
     - '**/*.rst'
   pull_request:
     branches:
+    - pegen
     - master
     - 3.8
     - 3.7
@@ -50,6 +51,22 @@ jobs:
   build_macos:
     name: 'macOS'
     runs-on: macos-latest
+    env:
+      PYTHONOLDPARSER: old
+    steps:
+    - uses: actions/checkout@v1
+    - name: Configure CPython
+      run: ./configure --with-pydebug --with-openssl=/usr/local/opt/openssl --prefix=/opt/python-dev
+    - name: Build CPython
+      run: make -j4
+    - name: Display build info
+      run: make pythoninfo
+    - name: Tests
+      run: make buildbottest TESTOPTS="-j4 -uall,-cpu"
+
+  build_macos_pegen:
+    name: 'macOS - Pegen'
+    runs-on: macos-latest
     steps:
     - uses: actions/checkout@v1
     - name: Configure CPython
@@ -64,6 +81,34 @@ jobs:
   build_ubuntu:
     name: 'Ubuntu'
     runs-on: ubuntu-latest
+    env:
+      OPENSSL_VER: 1.1.1f
+      PYTHONOLDPARSER: old
+    steps:
+    - uses: actions/checkout@v1
+    - name: Install Dependencies
+      run: sudo ./.github/workflows/posix-deps-apt.sh
+    - name: 'Restore OpenSSL build'
+      id: cache-openssl
+      uses: actions/cache@v1
+      with:
+        path: ./multissl/openssl/${{ env.OPENSSL_VER }}
+        key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
+    - name: Install OpenSSL
+      if: steps.cache-openssl.outputs.cache-hit != 'true'
+      run: python3 Tools/ssl/multissltests.py --steps=library --base-directory $PWD/multissl --openssl $OPENSSL_VER --system Linux
+    - name: Configure CPython
+      run: ./configure --with-pydebug --with-openssl=$PWD/multissl/openssl/$OPENSSL_VER
+    - name: Build CPython
+      run: make -j4
+    - name: Display build info
+      run: make pythoninfo
+    - name: Tests
+      run: xvfb-run make buildbottest TESTOPTS="-j4 -uall,-cpu"
+
+  build_ubuntu_pegen:
+    name: 'Ubuntu - Pegen'
+    runs-on: ubuntu-latest
     env:
       OPENSSL_VER: 1.1.1f
     steps:
diff --git a/.travis.yml b/.travis.yml
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,5 @@
 language: c
-dist: xenial
+dist: bionic
 
 # To cache doc-building dependencies and C compiler output.
 cache:
@@ -22,6 +22,7 @@ env:
 branches:
   only:
     - master
+    - pegen
     - /^\d\.\d+$/
     - buildbot-custom
 
@@ -157,7 +158,9 @@ install:
 before_script:
   # -Og is much faster than -O0
   - CFLAGS="${CFLAGS} -Og" ./configure --with-pydebug
-  - make -j4 regen-all
+  - eval "$(pyenv init -)"
+  - pyenv global 3.8
+  - PYTHON_FOR_REGEN=python3.8 make -j4 regen-all
   - changes=`git status --porcelain`
   - |
       # Check for changes in regenerated files
diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst
--- a/Doc/using/cmdline.rst
+++ b/Doc/using/cmdline.rst
@@ -426,6 +426,8 @@ Miscellaneous options
    defines the following possible values:
 
    * ``-X faulthandler`` to enable :mod:`faulthandler`;
+   * ``-X oldparser``: enable the traditional LL(1) parser.  See also
+     :envvar:`PYTHONOLDPARSER`.
    * ``-X showrefcount`` to output the total reference count and number of used
      memory blocks when the program finishes or after each statement in the
      interactive interpreter. This only works on debug builds.
@@ -574,6 +576,12 @@ conflict.
    :option:`-d` multiple times.
 
 
+.. envvar:: PYTHONOLDPARSER
+
+   If this is set it is equivalent to specifying the :option:`-X`
+   ``oldparser`` option.
+
+
 .. envvar:: PYTHONINSPECT
 
    If this is set to a non-empty string it is equivalent to specifying the
diff --git a/"Misc/NEWS.d/next/Core and Builtins/2020-04-20-14-06-19.bpo-40334.CTLGEp.rst" b/"Misc/NEWS.d/next/Core and Builtins/2020-04-20-14-06-19.bpo-40334.CTLGEp.rst"
new file mode 100644
--- /dev/null
+++ b/"Misc/NEWS.d/next/Core and Builtins/2020-04-20-14-06-19.bpo-40334.CTLGEp.rst"
@@ -0,0 +1,5 @@
+Switch to a new parser, based on PEG.  For more details see PEP 617. To
+temporarily switch back to the old parser, use ``-X oldparser`` or
+``PYTHONOLDPARSER=1``.  In Python 3.10 we will remove the old parser
+completely, including the ``parser`` module (already deprecated) and
+anything that depends on it.
diff --git a/Tools/README b/Tools/README
--- a/Tools/README
+++ b/Tools/README
@@ -23,6 +23,8 @@ msi             Support for packaging Python as an MSI package on Windows.
 
 parser          Un-parsing tool to generate code from an AST.
 
+peg_generator   PEG-based parser generator (pegen) used for new parser.
+
 pynche          A Tkinter-based color editor.
 
 scripts         A number of useful single-file programs, e.g. tabnanny.py
diff --git a/Tools/peg_generator/data/xxl.zip b/Tools/peg_generator/data/xxl.zip
new file mode 100644
--- /dev/null
+++ b/Tools/peg_generator/data/xxl.zip