Thread View
j: Next unread message
k: Previous unread message
j a: Jump to all threads
j l: Jump to MailingList overview
https://github.com/python/cpython/commit/ff51e5ec26168574761e128cc607b879d4…
commit: ff51e5ec26168574761e128cc607b879d4d5aa50
branch: 3.9
author: Miss Islington (bot) <31488909+miss-islington(a)users.noreply.github.com>
committer: terryjreedy <tjreedy(a)udel.edu>
date: 2020-11-30T17:36:06-05:00
summary:
bpo-42508: Remove bogus idlelib.pyshell.ModifiedInterpreter attribute (GH-23570) (GH-23571)
restart_subprocess is a method of self, the pyshell.InteractiveInterpreter instance. The latter does not have an interp attribute redundantly referring to itself. (The PyShell instance does have an interp attribute, referring to the InteractiveInterpreter instance.)
(cherry picked from commit e41bfd15dd148627b4f39c2a5837bddd8894d345)
Co-authored-by: Terry Jan Reedy <tjreedy(a)udel.edu>
files:
M Lib/idlelib/pyshell.py
diff --git a/Lib/idlelib/pyshell.py b/Lib/idlelib/pyshell.py
index b69916dbe876c..adc302883ae66 100755
--- a/Lib/idlelib/pyshell.py
+++ b/Lib/idlelib/pyshell.py
@@ -757,7 +757,7 @@ def runcommand(self, code):
def runcode(self, code):
"Override base class method"
if self.tkconsole.executing:
- self.interp.restart_subprocess()
+ self.restart_subprocess()
self.checklinecache()
debugger = self.debugger
try:
https://github.com/python/cpython/commit/b2652f2d7e1f3b868e9bec6669b3f3f905…
commit: b2652f2d7e1f3b868e9bec6669b3f3f905257991
branch: 3.9
author: Miss Islington (bot) <31488909+miss-islington(a)users.noreply.github.com>
committer: miss-islington <31488909+miss-islington(a)users.noreply.github.com>
date: 2020-11-30T14:34:43-08:00
summary:
bpo-42370: Check element before making mouse click in ttk tests (GH-23491)
(cherry picked from commit b0b428510cfd604a8eef1f245f039331e671ea4a)
Co-authored-by: Serhiy Storchaka <storchaka(a)gmail.com>
files:
M Lib/tkinter/test/test_ttk/test_widgets.py
diff --git a/Lib/tkinter/test/test_ttk/test_widgets.py b/Lib/tkinter/test/test_ttk/test_widgets.py
index 572e6daddf008..157ef0e8f87bb 100644
--- a/Lib/tkinter/test/test_ttk/test_widgets.py
+++ b/Lib/tkinter/test/test_ttk/test_widgets.py
@@ -435,11 +435,12 @@ def test_height(self):
def _show_drop_down_listbox(self):
width = self.combo.winfo_width()
- self.combo.event_generate('<ButtonPress-1>', x=width - 5, y=5)
- self.combo.event_generate('<ButtonRelease-1>', x=width - 5, y=5)
+ x, y = width - 5, 5
+ self.assertRegex(self.combo.identify(x, y), r'.*downarrow\Z')
+ self.combo.event_generate('<ButtonPress-1>', x=x, y=y)
+ self.combo.event_generate('<ButtonRelease-1>', x=x, y=y)
self.combo.update_idletasks()
-
def test_virtual_event(self):
success = []
@@ -1085,6 +1086,7 @@ def test_traversal(self):
self.nb.select(0)
+ self.assertEqual(self.nb.identify(5, 5), 'focus')
simulate_mouse_click(self.nb, 5, 5)
self.nb.focus_force()
self.nb.event_generate('<Control-Tab>')
@@ -1099,6 +1101,7 @@ def test_traversal(self):
self.nb.tab(self.child1, text='a', underline=0)
self.nb.enable_traversal()
self.nb.focus_force()
+ self.assertEqual(self.nb.identify(5, 5), 'focus')
simulate_mouse_click(self.nb, 5, 5)
if sys.platform == 'darwin':
self.nb.event_generate('<Option-a>')
@@ -1129,6 +1132,7 @@ def _click_increment_arrow(self):
height = self.spin.winfo_height()
x = width - 5
y = height//2 - 5
+ self.assertRegex(self.spin.identify(x, y), r'.*uparrow\Z')
self.spin.event_generate('<ButtonPress-1>', x=x, y=y)
self.spin.event_generate('<ButtonRelease-1>', x=x, y=y)
self.spin.update_idletasks()
@@ -1138,6 +1142,7 @@ def _click_decrement_arrow(self):
height = self.spin.winfo_height()
x = width - 5
y = height//2 + 4
+ self.assertRegex(self.spin.identify(x, y), r'.*downarrow\Z')
self.spin.event_generate('<ButtonPress-1>', x=x, y=y)
self.spin.event_generate('<ButtonRelease-1>', x=x, y=y)
self.spin.update_idletasks()
@@ -1526,6 +1531,9 @@ def test_heading(self):
def test_heading_callback(self):
def simulate_heading_click(x, y):
+ if tcl_version >= (8, 6):
+ self.assertEqual(self.tv.identify_column(x), '#0')
+ self.assertEqual(self.tv.identify_region(x, y), 'heading')
simulate_mouse_click(self.tv, x, y)
self.tv.update()
https://github.com/python/cpython/commit/1244c816d7cdfa8a26d1671cab67122a8c…
commit: 1244c816d7cdfa8a26d1671cab67122a8c5271a7
branch: master
author: pxinwr <peixing.xin(a)windriver.com>
committer: vstinner <vstinner(a)python.org>
date: 2020-11-30T22:48:33+01:00
summary:
bpo-31904: Support signal module on VxWorks (GH-23391)
files:
A Misc/NEWS.d/next/Library/2020-11-19-16-14-36.bpo-31904.83kf9d.rst
M Lib/test/test_signal.py
M Modules/signalmodule.c
diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py
index 5a8ff361f9656..6a43fe70372c5 100644
--- a/Lib/test/test_signal.py
+++ b/Lib/test/test_signal.py
@@ -519,10 +519,14 @@ def handler(signum, frame):
else:
write.setblocking(False)
- # Start with large chunk size to reduce the
- # number of send needed to fill the buffer.
written = 0
- for chunk_size in (2 ** 16, 2 ** 8, 1):
+ if sys.platform == "vxworks":
+ CHUNK_SIZES = (1,)
+ else:
+ # Start with large chunk size to reduce the
+ # number of send needed to fill the buffer.
+ CHUNK_SIZES = (2 ** 16, 2 ** 8, 1)
+ for chunk_size in CHUNK_SIZES:
chunk = b"x" * chunk_size
try:
while True:
@@ -595,6 +599,7 @@ def handler(signum, frame):
@unittest.skipIf(sys.platform == "win32", "Not valid on Windows")
+(a)unittest.skipUnless(hasattr(signal, 'siginterrupt'), "needs signal.siginterrupt()")
class SiginterruptTest(unittest.TestCase):
def readpipe_interrupted(self, interrupt):
@@ -680,6 +685,8 @@ def test_siginterrupt_off(self):
@unittest.skipIf(sys.platform == "win32", "Not valid on Windows")
+(a)unittest.skipUnless(hasattr(signal, 'getitimer') and hasattr(signal, 'setitimer'),
+ "needs signal.getitimer() and signal.setitimer()")
class ItimerTest(unittest.TestCase):
def setUp(self):
self.hndl_called = False
diff --git a/Misc/NEWS.d/next/Library/2020-11-19-16-14-36.bpo-31904.83kf9d.rst b/Misc/NEWS.d/next/Library/2020-11-19-16-14-36.bpo-31904.83kf9d.rst
new file mode 100644
index 0000000000000..e0ea23aefae7f
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-11-19-16-14-36.bpo-31904.83kf9d.rst
@@ -0,0 +1 @@
+Support signal module on VxWorks.
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index fcc8f1cbda227..7ac797a3aa3f8 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -120,7 +120,11 @@ static volatile struct {
#else
#define INVALID_FD (-1)
static volatile struct {
+#ifdef __VXWORKS__
+ int fd;
+#else
sig_atomic_t fd;
+#endif
int warn_on_full_buffer;
} wakeup = {.fd = INVALID_FD, .warn_on_full_buffer = 1};
#endif
https://github.com/python/cpython/commit/5c73afc36ee6cca41009a510092e1f901c…
commit: 5c73afc36ee6cca41009a510092e1f901c5dc0a0
branch: master
author: Christian Heimes <christian(a)python.org>
committer: vstinner <vstinner(a)python.org>
date: 2020-11-30T22:34:45+01:00
summary:
bpo-28468: Add platform.freedesktop_os_release() (GH-23492)
Add platform.freedesktop_os_release() function to parse freedesktop.org
os-release files.
Signed-off-by: Christian Heimes <christian(a)python.org>
Co-authored-by: Victor Stinner <vstinner(a)python.org>
files:
A Misc/NEWS.d/next/Library/2020-11-24-13-18-05.bpo-28468.8Gh2d4.rst
M Doc/library/platform.rst
M Doc/whatsnew/3.10.rst
M Lib/platform.py
M Lib/test/test_platform.py
diff --git a/Doc/library/platform.rst b/Doc/library/platform.rst
index b293adf48e6e3..fc51b5de881cc 100644
--- a/Doc/library/platform.rst
+++ b/Doc/library/platform.rst
@@ -253,3 +253,41 @@ Unix Platforms
using :program:`gcc`.
The file is read and scanned in chunks of *chunksize* bytes.
+
+
+Linux Platforms
+---------------
+
+.. function:: freedesktop_os_release()
+
+ Get operating system identification from ``os-release`` file and return
+ it as a dict. The ``os-release`` file is a `freedesktop.org standard
+ <https://www.freedesktop.org/software/systemd/man/os-release.html >`_ and
+ is available in most Linux distributions. A noticeable exception is
+ Android and Android-based distributions.
+
+ Raises :exc:`OSError` or subclass when neither ``/etc/os-release`` nor
+ ``/usr/lib/os-release`` can be read.
+
+ On success, the function returns a dictionary where keys and values are
+ strings. Values have their special characters like ``"`` and ``$``
+ unquoted. The fields ``NAME``, ``ID``, and ``PRETTY_NAME`` are always
+ defined according to the standard. All other fields are optional. Vendors
+ may include additional fields.
+
+ Note that fields like ``NAME``, ``VERSION``, and ``VARIANT`` are strings
+ suitable for presentation to users. Programs should use fields like
+ ``ID``, ``ID_LIKE``, ``VERSION_ID``, or ``VARIANT_ID`` to identify
+ Linux distributions.
+
+ Example::
+
+ def get_like_distro():
+ info = platform.freedesktop_os_release()
+ ids = [info["ID"]]
+ if "ID_LIKE" in info:
+ # ids are space separated and ordered by precedence
+ ids.extend(info["ID_LIKE"].split())
+ return ids
+
+ .. versionadded:: 3.10
diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst
index f96a3bcbca95f..a8f1080a504c7 100644
--- a/Doc/whatsnew/3.10.rst
+++ b/Doc/whatsnew/3.10.rst
@@ -254,6 +254,14 @@ Added negative indexing support to :attr:`PurePath.parents
<pathlib.PurePath.parents>`.
(Contributed by Yaroslav Pankovych in :issue:`21041`)
+platform
+--------
+
+Added :func:`platform.freedesktop_os_release()` to retrieve operation system
+identification from `freedesktop.org os-release
+<https://www.freedesktop.org/software/systemd/man/os-release.html >`_ standard file.
+(Contributed by Christian Heimes in :issue:`28468`)
+
py_compile
----------
diff --git a/Lib/platform.py b/Lib/platform.py
index 0eb5167d584f7..138a974f02bb6 100755
--- a/Lib/platform.py
+++ b/Lib/platform.py
@@ -1230,6 +1230,63 @@ def platform(aliased=0, terse=0):
_platform_cache[(aliased, terse)] = platform
return platform
+### freedesktop.org os-release standard
+# https://www.freedesktop.org/software/systemd/man/os-release.html
+
+# NAME=value with optional quotes (' or "). The regular expression is less
+# strict than shell lexer, but that's ok.
+_os_release_line = re.compile(
+ "^(?P<name>[a-zA-Z0-9_]+)=(?P<quote>[\"\']?)(?P<value>.*)(?P=quote)$"
+)
+# unescape five special characters mentioned in the standard
+_os_release_unescape = re.compile(r"\\([\\\$\"\'`])")
+# /etc takes precedence over /usr/lib
+_os_release_candidates = ("/etc/os-release", "/usr/lib/os-relesase")
+_os_release_cache = None
+
+
+def _parse_os_release(lines):
+ # These fields are mandatory fields with well-known defaults
+ # in pratice all Linux distributions override NAME, ID, and PRETTY_NAME.
+ info = {
+ "NAME": "Linux",
+ "ID": "linux",
+ "PRETTY_NAME": "Linux",
+ }
+
+ for line in lines:
+ mo = _os_release_line.match(line)
+ if mo is not None:
+ info[mo.group('name')] = _os_release_unescape.sub(
+ r"\1", mo.group('value')
+ )
+
+ return info
+
+
+def freedesktop_os_release():
+ """Return operation system identification from freedesktop.org os-release
+ """
+ global _os_release_cache
+
+ if _os_release_cache is None:
+ errno = None
+ for candidate in _os_release_candidates:
+ try:
+ with open(candidate, encoding="utf-8") as f:
+ _os_release_cache = _parse_os_release(f)
+ break
+ except OSError as e:
+ errno = e.errno
+ else:
+ raise OSError(
+ errno,
+ f"Unable to read files {', '.join(_os_release_candidates)}"
+ )
+
+ return _os_release_cache.copy()
+
+
### Command line interface
if __name__ == '__main__':
diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py
index 1590cd509b95c..2c6fbee8b6ffb 100644
--- a/Lib/test/test_platform.py
+++ b/Lib/test/test_platform.py
@@ -8,12 +8,70 @@
from test import support
from test.support import os_helper
+FEDORA_OS_RELEASE = """\
+NAME=Fedora
+VERSION="32 (Thirty Two)"
+ID=fedora
+VERSION_ID=32
+VERSION_CODENAME=""
+PLATFORM_ID="platform:f32"
+PRETTY_NAME="Fedora 32 (Thirty Two)"
+ANSI_COLOR="0;34"
+LOGO=fedora-logo-icon
+CPE_NAME="cpe:/o:fedoraproject:fedora:32"
+HOME_URL="https://fedoraproject.org/ "
+DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f32/system-administrators-guide/ "
+SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help "
+BUG_REPORT_URL="https://bugzilla.redhat.com/ "
+REDHAT_BUGZILLA_PRODUCT="Fedora"
+REDHAT_BUGZILLA_PRODUCT_VERSION=32
+REDHAT_SUPPORT_PRODUCT="Fedora"
+REDHAT_SUPPORT_PRODUCT_VERSION=32
+PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy "
+"""
+
+UBUNTU_OS_RELEASE = """\
+NAME="Ubuntu"
+VERSION="20.04.1 LTS (Focal Fossa)"
+ID=ubuntu
+ID_LIKE=debian
+PRETTY_NAME="Ubuntu 20.04.1 LTS"
+VERSION_ID="20.04"
+HOME_URL="https://www.ubuntu.com/ "
+SUPPORT_URL="https://help.ubuntu.com/ "
+BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/ "
+PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy "
+VERSION_CODENAME=focal
+UBUNTU_CODENAME=focal
+"""
+
+TEST_OS_RELEASE = r"""
+# test data
+ID_LIKE="egg spam viking"
+EMPTY=
+# comments and empty lines are ignored
+
+SINGLE_QUOTE='single'
+EMPTY_SINGLE=''
+DOUBLE_QUOTE="double"
+EMPTY_DOUBLE=""
+QUOTES="double\'s"
+SPECIALS="\$\`\\\'\""
+# invalid lines
+=invalid
+=
+INVALID
+IN-VALID=value
+IN VALID=value
+"""
+
class PlatformTest(unittest.TestCase):
def clear_caches(self):
platform._platform_cache.clear()
platform._sys_version_cache.clear()
platform._uname_cache = None
+ platform._os_release_cache = None
def test_architecture(self):
res = platform.architecture()
@@ -382,6 +440,54 @@ def test_macos(self):
self.assertEqual(platform.platform(terse=1), expected_terse)
self.assertEqual(platform.platform(), expected)
+ def test_freedesktop_os_release(self):
+ self.addCleanup(self.clear_caches)
+ self.clear_caches()
+
+ if any(os.path.isfile(fn) for fn in platform._os_release_candidates):
+ info = platform.freedesktop_os_release()
+ self.assertIn("NAME", info)
+ self.assertIn("ID", info)
+
+ info["CPYTHON_TEST"] = "test"
+ self.assertNotIn(
+ "CPYTHON_TEST",
+ platform.freedesktop_os_release()
+ )
+ else:
+ with self.assertRaises(OSError):
+ platform.freedesktop_os_release()
+
+ def test_parse_os_release(self):
+ info = platform._parse_os_release(FEDORA_OS_RELEASE.splitlines())
+ self.assertEqual(info["NAME"], "Fedora")
+ self.assertEqual(info["ID"], "fedora")
+ self.assertNotIn("ID_LIKE", info)
+ self.assertEqual(info["VERSION_CODENAME"], "")
+
+ info = platform._parse_os_release(UBUNTU_OS_RELEASE.splitlines())
+ self.assertEqual(info["NAME"], "Ubuntu")
+ self.assertEqual(info["ID"], "ubuntu")
+ self.assertEqual(info["ID_LIKE"], "debian")
+ self.assertEqual(info["VERSION_CODENAME"], "focal")
+
+ info = platform._parse_os_release(TEST_OS_RELEASE.splitlines())
+ expected = {
+ "ID": "linux",
+ "NAME": "Linux",
+ "PRETTY_NAME": "Linux",
+ "ID_LIKE": "egg spam viking",
+ "EMPTY": "",
+ "DOUBLE_QUOTE": "double",
+ "EMPTY_DOUBLE": "",
+ "SINGLE_QUOTE": "single",
+ "EMPTY_SINGLE": "",
+ "QUOTES": "double's",
+ "SPECIALS": "$`\\'\"",
+ }
+ self.assertEqual(info, expected)
+ self.assertEqual(len(info["SPECIALS"]), 5)
+
if __name__ == '__main__':
unittest.main()
diff --git a/Misc/NEWS.d/next/Library/2020-11-24-13-18-05.bpo-28468.8Gh2d4.rst b/Misc/NEWS.d/next/Library/2020-11-24-13-18-05.bpo-28468.8Gh2d4.rst
new file mode 100644
index 0000000000000..b1834065cf047
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-11-24-13-18-05.bpo-28468.8Gh2d4.rst
@@ -0,0 +1,2 @@
+Add :func:`platform.freedesktop_os_release` function to parse freedesktop.org
+``os-release`` files.
https://github.com/python/cpython/commit/aab93903347ec6d7f23dda2994dd26f611…
commit: aab93903347ec6d7f23dda2994dd26f6111d19d2
branch: 3.9
author: Miss Islington (bot) <31488909+miss-islington(a)users.noreply.github.com>
committer: rhettinger <rhettinger(a)users.noreply.github.com>
date: 2020-11-30T13:21:08-08:00
summary:
bpo-42501: Revise the usage note for Enums with the choices (GH-23563) (GH-23573)
files:
M Doc/library/argparse.rst
diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst
index 7a7a4cf94979a..a32b99901a7b4 100644
--- a/Doc/library/argparse.rst
+++ b/Doc/library/argparse.rst
@@ -1133,20 +1133,9 @@ container should match the type_ specified::
Any container can be passed as the *choices* value, so :class:`list` objects,
:class:`set` objects, and custom containers are all supported.
-This includes :class:`enum.Enum`, which could be used to restrain
-argument's choices; if we reuse previous rock/paper/scissors game example,
-this could be as follows::
-
- >>> from enum import Enum
- >>> class GameMove(Enum):
- ... ROCK = 'rock'
- ... PAPER = 'paper'
- ... SCISSORS = 'scissors'
- ...
- >>> parser = argparse.ArgumentParser(prog='game.py')
- >>> parser.add_argument('move', type=GameMove, choices=GameMove)
- >>> parser.parse_args(['rock'])
- Namespace(move=<GameMove.ROCK: 'rock'>)
+
+Use of :class:`enum.Enum` is not recommended because it is difficult to
+control its appearance in usage, help, and error messages.
required
https://github.com/python/cpython/commit/9bdc40ee3e0d886fb62b5334e8a88c1fe9…
commit: 9bdc40ee3e0d886fb62b5334e8a88c1fe9460ba0
branch: master
author: Pablo Galindo <Pablogsal(a)gmail.com>
committer: pablogsal <Pablogsal(a)gmail.com>
date: 2020-11-30T19:42:38Z
summary:
Refactor the grammar to match the language specification docs (GH-23574)
files:
M Grammar/python.gram
M Parser/parser.c
diff --git a/Grammar/python.gram b/Grammar/python.gram
index 9e915acf5dbaf..9f4709491469d 100644
--- a/Grammar/python.gram
+++ b/Grammar/python.gram
@@ -52,18 +52,18 @@ type_expressions[asdl_expr_seq*]:
| a[asdl_expr_seq*]=','.expression+ {a}
statements[asdl_stmt_seq*]: a=statement+ { (asdl_stmt_seq*)_PyPegen_seq_flatten(p, a) }
-statement[asdl_stmt_seq*]: a=compound_stmt { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a) } | a[asdl_stmt_seq*]=simple_stmt { a }
+statement[asdl_stmt_seq*]: a=compound_stmt { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a) } | a[asdl_stmt_seq*]=simple_stmts { a }
statement_newline[asdl_stmt_seq*]:
| a=compound_stmt NEWLINE { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a) }
- | simple_stmt
+ | simple_stmts
| NEWLINE { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, CHECK(stmt_ty, _Py_Pass(EXTRA))) }
| ENDMARKER { _PyPegen_interactive_exit(p) }
-simple_stmt[asdl_stmt_seq*]:
- | a=small_stmt !';' NEWLINE { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a) } # Not needed, there for speedup
- | a[asdl_stmt_seq*]=';'.small_stmt+ [';'] NEWLINE { a }
+simple_stmts[asdl_stmt_seq*]:
+ | a=simple_stmt !';' NEWLINE { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a) } # Not needed, there for speedup
+ | a[asdl_stmt_seq*]=';'.simple_stmt+ [';'] NEWLINE { a }
# NOTE: assignment MUST precede expression, else parsing a simple assignment
# will throw a SyntaxError.
-small_stmt[stmt_ty] (memo):
+simple_stmt[stmt_ty] (memo):
| assignment
| e=star_expressions { _Py_Expr(e, EXTRA) }
| &'return' return_stmt
@@ -308,7 +308,7 @@ class_def_raw[stmt_ty]:
block[asdl_stmt_seq*] (memo):
| NEWLINE INDENT a=statements DEDENT { a }
- | simple_stmt
+ | simple_stmts
| invalid_block
star_expressions[expr_ty]:
diff --git a/Parser/parser.c b/Parser/parser.c
index f469c8f0e49a8..b6c04953c899e 100644
--- a/Parser/parser.c
+++ b/Parser/parser.c
@@ -75,8 +75,8 @@ static KeywordToken *reserved_keywords[] = {
#define statements_type 1006
#define statement_type 1007
#define statement_newline_type 1008
-#define simple_stmt_type 1009
-#define small_stmt_type 1010
+#define simple_stmts_type 1009
+#define simple_stmt_type 1010
#define compound_stmt_type 1011
#define assignment_type 1012
#define augassign_type 1013
@@ -391,8 +391,8 @@ static asdl_expr_seq* type_expressions_rule(Parser *p);
static asdl_stmt_seq* statements_rule(Parser *p);
static asdl_stmt_seq* statement_rule(Parser *p);
static asdl_stmt_seq* statement_newline_rule(Parser *p);
-static asdl_stmt_seq* simple_stmt_rule(Parser *p);
-static stmt_ty small_stmt_rule(Parser *p);
+static asdl_stmt_seq* simple_stmts_rule(Parser *p);
+static stmt_ty simple_stmt_rule(Parser *p);
static stmt_ty compound_stmt_rule(Parser *p);
static stmt_ty assignment_rule(Parser *p);
static AugOperator* augassign_rule(Parser *p);
@@ -1213,7 +1213,7 @@ statements_rule(Parser *p)
return _res;
}
-// statement: compound_stmt | simple_stmt
+// statement: compound_stmt | simple_stmts
static asdl_stmt_seq*
statement_rule(Parser *p)
{
@@ -1248,18 +1248,18 @@ statement_rule(Parser *p)
D(fprintf(stderr, "%*c%s statement[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compound_stmt"));
}
- { // simple_stmt
+ { // simple_stmts
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> statement[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
+ D(fprintf(stderr, "%*c> statement[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmts"));
asdl_stmt_seq* a;
if (
- (a = (asdl_stmt_seq*)simple_stmt_rule(p)) // simple_stmt
+ (a = (asdl_stmt_seq*)simple_stmts_rule(p)) // simple_stmts
)
{
- D(fprintf(stderr, "%*c+ statement[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
+ D(fprintf(stderr, "%*c+ statement[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmts"));
_res = a;
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
@@ -1270,7 +1270,7 @@ statement_rule(Parser *p)
}
p->mark = _mark;
D(fprintf(stderr, "%*c%s statement[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt"));
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmts"));
}
_res = NULL;
done:
@@ -1278,7 +1278,7 @@ statement_rule(Parser *p)
return _res;
}
-// statement_newline: compound_stmt NEWLINE | simple_stmt | NEWLINE | $
+// statement_newline: compound_stmt NEWLINE | simple_stmts | NEWLINE | $
static asdl_stmt_seq*
statement_newline_rule(Parser *p)
{
@@ -1325,24 +1325,24 @@ statement_newline_rule(Parser *p)
D(fprintf(stderr, "%*c%s statement_newline[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compound_stmt NEWLINE"));
}
- { // simple_stmt
+ { // simple_stmts
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> statement_newline[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
- asdl_stmt_seq* simple_stmt_var;
+ D(fprintf(stderr, "%*c> statement_newline[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmts"));
+ asdl_stmt_seq* simple_stmts_var;
if (
- (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt
+ (simple_stmts_var = simple_stmts_rule(p)) // simple_stmts
)
{
- D(fprintf(stderr, "%*c+ statement_newline[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
- _res = simple_stmt_var;
+ D(fprintf(stderr, "%*c+ statement_newline[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmts"));
+ _res = simple_stmts_var;
goto done;
}
p->mark = _mark;
D(fprintf(stderr, "%*c%s statement_newline[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt"));
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmts"));
}
{ // NEWLINE
if (p->error_indicator) {
@@ -1407,9 +1407,9 @@ statement_newline_rule(Parser *p)
return _res;
}
-// simple_stmt: small_stmt !';' NEWLINE | ';'.small_stmt+ ';'? NEWLINE
+// simple_stmts: simple_stmt !';' NEWLINE | ';'.simple_stmt+ ';'? NEWLINE
static asdl_stmt_seq*
-simple_stmt_rule(Parser *p)
+simple_stmts_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -1418,23 +1418,23 @@ simple_stmt_rule(Parser *p)
}
asdl_stmt_seq* _res = NULL;
int _mark = p->mark;
- { // small_stmt !';' NEWLINE
+ { // simple_stmt !';' NEWLINE
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "small_stmt !';' NEWLINE"));
+ D(fprintf(stderr, "%*c> simple_stmts[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt !';' NEWLINE"));
stmt_ty a;
Token * newline_var;
if (
- (a = small_stmt_rule(p)) // small_stmt
+ (a = simple_stmt_rule(p)) // simple_stmt
&&
_PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 13) // token=';'
&&
(newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
)
{
- D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "small_stmt !';' NEWLINE"));
+ D(fprintf(stderr, "%*c+ simple_stmts[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt !';' NEWLINE"));
_res = ( asdl_stmt_seq * ) _PyPegen_singleton_seq ( p , a );
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
@@ -1444,28 +1444,28 @@ simple_stmt_rule(Parser *p)
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "small_stmt !';' NEWLINE"));
+ D(fprintf(stderr, "%*c%s simple_stmts[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt !';' NEWLINE"));
}
- { // ';'.small_stmt+ ';'? NEWLINE
+ { // ';'.simple_stmt+ ';'? NEWLINE
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';'.small_stmt+ ';'? NEWLINE"));
+ D(fprintf(stderr, "%*c> simple_stmts[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';'.simple_stmt+ ';'? NEWLINE"));
void *_opt_var;
UNUSED(_opt_var); // Silence compiler warnings
asdl_stmt_seq* a;
Token * newline_var;
if (
- (a = (asdl_stmt_seq*)_gather_12_rule(p)) // ';'.small_stmt+
+ (a = (asdl_stmt_seq*)_gather_12_rule(p)) // ';'.simple_stmt+
&&
(_opt_var = _PyPegen_expect_token(p, 13), 1) // ';'?
&&
(newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
)
{
- D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "';'.small_stmt+ ';'? NEWLINE"));
+ D(fprintf(stderr, "%*c+ simple_stmts[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "';'.simple_stmt+ ';'? NEWLINE"));
_res = a;
if (_res == NULL && PyErr_Occurred()) {
p->error_indicator = 1;
@@ -1475,8 +1475,8 @@ simple_stmt_rule(Parser *p)
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';'.small_stmt+ ';'? NEWLINE"));
+ D(fprintf(stderr, "%*c%s simple_stmts[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';'.simple_stmt+ ';'? NEWLINE"));
}
_res = NULL;
done:
@@ -1484,7 +1484,7 @@ simple_stmt_rule(Parser *p)
return _res;
}
-// small_stmt:
+// simple_stmt:
// | assignment
// | star_expressions
// | &'return' return_stmt
@@ -1499,7 +1499,7 @@ simple_stmt_rule(Parser *p)
// | &'global' global_stmt
// | &'nonlocal' nonlocal_stmt
static stmt_ty
-small_stmt_rule(Parser *p)
+simple_stmt_rule(Parser *p)
{
D(p->level++);
if (p->error_indicator) {
@@ -1507,7 +1507,7 @@ small_stmt_rule(Parser *p)
return NULL;
}
stmt_ty _res = NULL;
- if (_PyPegen_is_memoized(p, small_stmt_type, &_res)) {
+ if (_PyPegen_is_memoized(p, simple_stmt_type, &_res)) {
D(p->level--);
return _res;
}
@@ -1526,18 +1526,18 @@ small_stmt_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "assignment"));
+ D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "assignment"));
stmt_ty assignment_var;
if (
(assignment_var = assignment_rule(p)) // assignment
)
{
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "assignment"));
+ D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "assignment"));
_res = assignment_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "assignment"));
}
{ // star_expressions
@@ -1545,13 +1545,13 @@ small_stmt_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions"));
+ D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions"));
expr_ty e;
if (
(e = star_expressions_rule(p)) // star_expressions
)
{
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions"));
+ D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions"));
Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
if (_token == NULL) {
D(p->level--);
@@ -1570,7 +1570,7 @@ small_stmt_rule(Parser *p)
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions"));
}
{ // &'return' return_stmt
@@ -1578,7 +1578,7 @@ small_stmt_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'return' return_stmt"));
+ D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'return' return_stmt"));
stmt_ty return_stmt_var;
if (
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 500) // token='return'
@@ -1586,12 +1586,12 @@ small_stmt_rule(Parser *p)
(return_stmt_var = return_stmt_rule(p)) // return_stmt
)
{
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'return' return_stmt"));
+ D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'return' return_stmt"));
_res = return_stmt_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'return' return_stmt"));
}
{ // &('import' | 'from') import_stmt
@@ -1599,7 +1599,7 @@ small_stmt_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&('import' | 'from') import_stmt"));
+ D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&('import' | 'from') import_stmt"));
stmt_ty import_stmt_var;
if (
_PyPegen_lookahead(1, _tmp_14_rule, p)
@@ -1607,12 +1607,12 @@ small_stmt_rule(Parser *p)
(import_stmt_var = import_stmt_rule(p)) // import_stmt
)
{
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&('import' | 'from') import_stmt"));
+ D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&('import' | 'from') import_stmt"));
_res = import_stmt_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&('import' | 'from') import_stmt"));
}
{ // &'raise' raise_stmt
@@ -1620,7 +1620,7 @@ small_stmt_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'raise' raise_stmt"));
+ D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'raise' raise_stmt"));
stmt_ty raise_stmt_var;
if (
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 501) // token='raise'
@@ -1628,12 +1628,12 @@ small_stmt_rule(Parser *p)
(raise_stmt_var = raise_stmt_rule(p)) // raise_stmt
)
{
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'raise' raise_stmt"));
+ D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'raise' raise_stmt"));
_res = raise_stmt_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'raise' raise_stmt"));
}
{ // 'pass'
@@ -1641,13 +1641,13 @@ small_stmt_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'pass'"));
+ D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'pass'"));
Token * _keyword;
if (
(_keyword = _PyPegen_expect_token(p, 502)) // token='pass'
)
{
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'pass'"));
+ D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'pass'"));
Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
if (_token == NULL) {
D(p->level--);
@@ -1666,7 +1666,7 @@ small_stmt_rule(Parser *p)
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'pass'"));
}
{ // &'del' del_stmt
@@ -1674,7 +1674,7 @@ small_stmt_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'del' del_stmt"));
+ D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'del' del_stmt"));
stmt_ty del_stmt_var;
if (
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 503) // token='del'
@@ -1682,12 +1682,12 @@ small_stmt_rule(Parser *p)
(del_stmt_var = del_stmt_rule(p)) // del_stmt
)
{
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'del' del_stmt"));
+ D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'del' del_stmt"));
_res = del_stmt_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'del' del_stmt"));
}
{ // &'yield' yield_stmt
@@ -1695,7 +1695,7 @@ small_stmt_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'yield' yield_stmt"));
+ D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'yield' yield_stmt"));
stmt_ty yield_stmt_var;
if (
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 504) // token='yield'
@@ -1703,12 +1703,12 @@ small_stmt_rule(Parser *p)
(yield_stmt_var = yield_stmt_rule(p)) // yield_stmt
)
{
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'yield' yield_stmt"));
+ D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'yield' yield_stmt"));
_res = yield_stmt_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'yield' yield_stmt"));
}
{ // &'assert' assert_stmt
@@ -1716,7 +1716,7 @@ small_stmt_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'assert' assert_stmt"));
+ D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'assert' assert_stmt"));
stmt_ty assert_stmt_var;
if (
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 505) // token='assert'
@@ -1724,12 +1724,12 @@ small_stmt_rule(Parser *p)
(assert_stmt_var = assert_stmt_rule(p)) // assert_stmt
)
{
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'assert' assert_stmt"));
+ D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'assert' assert_stmt"));
_res = assert_stmt_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'assert' assert_stmt"));
}
{ // 'break'
@@ -1737,13 +1737,13 @@ small_stmt_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'break'"));
+ D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'break'"));
Token * _keyword;
if (
(_keyword = _PyPegen_expect_token(p, 506)) // token='break'
)
{
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'break'"));
+ D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'break'"));
Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
if (_token == NULL) {
D(p->level--);
@@ -1762,7 +1762,7 @@ small_stmt_rule(Parser *p)
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'break'"));
}
{ // 'continue'
@@ -1770,13 +1770,13 @@ small_stmt_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'continue'"));
+ D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'continue'"));
Token * _keyword;
if (
(_keyword = _PyPegen_expect_token(p, 507)) // token='continue'
)
{
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'continue'"));
+ D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'continue'"));
Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
if (_token == NULL) {
D(p->level--);
@@ -1795,7 +1795,7 @@ small_stmt_rule(Parser *p)
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'continue'"));
}
{ // &'global' global_stmt
@@ -1803,7 +1803,7 @@ small_stmt_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'global' global_stmt"));
+ D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'global' global_stmt"));
stmt_ty global_stmt_var;
if (
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 508) // token='global'
@@ -1811,12 +1811,12 @@ small_stmt_rule(Parser *p)
(global_stmt_var = global_stmt_rule(p)) // global_stmt
)
{
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'global' global_stmt"));
+ D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'global' global_stmt"));
_res = global_stmt_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'global' global_stmt"));
}
{ // &'nonlocal' nonlocal_stmt
@@ -1824,7 +1824,7 @@ small_stmt_rule(Parser *p)
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'nonlocal' nonlocal_stmt"));
+ D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'nonlocal' nonlocal_stmt"));
stmt_ty nonlocal_stmt_var;
if (
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 509) // token='nonlocal'
@@ -1832,17 +1832,17 @@ small_stmt_rule(Parser *p)
(nonlocal_stmt_var = nonlocal_stmt_rule(p)) // nonlocal_stmt
)
{
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'nonlocal' nonlocal_stmt"));
+ D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'nonlocal' nonlocal_stmt"));
_res = nonlocal_stmt_var;
goto done;
}
p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'nonlocal' nonlocal_stmt"));
}
_res = NULL;
done:
- _PyPegen_insert_memo(p, _mark, small_stmt_type, _res);
+ _PyPegen_insert_memo(p, _mark, simple_stmt_type, _res);
D(p->level--);
return _res;
}
@@ -6235,7 +6235,7 @@ class_def_raw_rule(Parser *p)
return _res;
}
-// block: NEWLINE INDENT statements DEDENT | simple_stmt | invalid_block
+// block: NEWLINE INDENT statements DEDENT | simple_stmts | invalid_block
static asdl_stmt_seq*
block_rule(Parser *p)
{
@@ -6283,24 +6283,24 @@ block_rule(Parser *p)
D(fprintf(stderr, "%*c%s block[%d-%d]: %s failed!\n", p->level, ' ',
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE INDENT statements DEDENT"));
}
- { // simple_stmt
+ { // simple_stmts
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
- asdl_stmt_seq* simple_stmt_var;
+ D(fprintf(stderr, "%*c> block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmts"));
+ asdl_stmt_seq* simple_stmts_var;
if (
- (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt
+ (simple_stmts_var = simple_stmts_rule(p)) // simple_stmts
)
{
- D(fprintf(stderr, "%*c+ block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
- _res = simple_stmt_var;
+ D(fprintf(stderr, "%*c+ block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmts"));
+ _res = simple_stmts_var;
goto done;
}
p->mark = _mark;
D(fprintf(stderr, "%*c%s block[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt"));
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmts"));
}
if (p->call_invalid_rules) { // invalid_block
if (p->error_indicator) {
@@ -16274,7 +16274,7 @@ _loop1_11_rule(Parser *p)
return _seq;
}
-// _loop0_13: ';' small_stmt
+// _loop0_13: ';' simple_stmt
static asdl_seq *
_loop0_13_rule(Parser *p)
{
@@ -16295,18 +16295,18 @@ _loop0_13_rule(Parser *p)
}
ssize_t _children_capacity = 1;
ssize_t _n = 0;
- { // ';' small_stmt
+ { // ';' simple_stmt
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _loop0_13[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';' small_stmt"));
+ D(fprintf(stderr, "%*c> _loop0_13[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';' simple_stmt"));
Token * _literal;
stmt_ty elem;
while (
(_literal = _PyPegen_expect_token(p, 13)) // token=';'
&&
- (elem = small_stmt_rule(p)) // small_stmt
+ (elem = simple_stmt_rule(p)) // simple_stmt
)
{
_res = elem;
@@ -16332,7 +16332,7 @@ _loop0_13_rule(Parser *p)
}
p->mark = _mark;
D(fprintf(stderr, "%*c%s _loop0_13[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';' small_stmt"));
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';' simple_stmt"));
}
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
if (!_seq) {
@@ -16349,7 +16349,7 @@ _loop0_13_rule(Parser *p)
return _seq;
}
-// _gather_12: small_stmt _loop0_13
+// _gather_12: simple_stmt _loop0_13
static asdl_seq *
_gather_12_rule(Parser *p)
{
@@ -16360,27 +16360,27 @@ _gather_12_rule(Parser *p)
}
asdl_seq * _res = NULL;
int _mark = p->mark;
- { // small_stmt _loop0_13
+ { // simple_stmt _loop0_13
if (p->error_indicator) {
D(p->level--);
return NULL;
}
- D(fprintf(stderr, "%*c> _gather_12[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "small_stmt _loop0_13"));
+ D(fprintf(stderr, "%*c> _gather_12[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt _loop0_13"));
stmt_ty elem;
asdl_seq * seq;
if (
- (elem = small_stmt_rule(p)) // small_stmt
+ (elem = simple_stmt_rule(p)) // simple_stmt
&&
(seq = _loop0_13_rule(p)) // _loop0_13
)
{
- D(fprintf(stderr, "%*c+ _gather_12[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "small_stmt _loop0_13"));
+ D(fprintf(stderr, "%*c+ _gather_12[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt _loop0_13"));
_res = _PyPegen_seq_insert_in_front(p, elem, seq);
goto done;
}
p->mark = _mark;
D(fprintf(stderr, "%*c%s _gather_12[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "small_stmt _loop0_13"));
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt _loop0_13"));
}
_res = NULL;
done:
https://github.com/python/cpython/commit/bcc9579227578de5dd7f8825d24ba51b61…
commit: bcc9579227578de5dd7f8825d24ba51b618ad3c2
branch: master
author: James Gerity <snoop.jedi(a)gmail.com>
committer: pablogsal <Pablogsal(a)gmail.com>
date: 2020-11-30T19:08:26Z
summary:
bpo-42485: [Doc] Link to PEP 617 from full grammar specification (GH-23532)
Co-authored-by: Lysandros Nikolaou <lisandrosnik(a)gmail.com>
files:
M Doc/reference/grammar.rst
diff --git a/Doc/reference/grammar.rst b/Doc/reference/grammar.rst
index acf83765b5796..59b45005836a7 100644
--- a/Doc/reference/grammar.rst
+++ b/Doc/reference/grammar.rst
@@ -13,7 +13,8 @@ In particular, ``&`` followed by a symbol, token or parenthesized
group indicates a positive lookahead (i.e., is required to match but
not consumed), while ``!`` indicates a negative lookahead (i.e., is
required _not_ to match). We use the ``|`` separator to mean PEG's
-"ordered choice" (written as ``/`` in traditional PEG grammars).
+"ordered choice" (written as ``/`` in traditional PEG grammars). See
+:pep:`617` for more details on the grammar's syntax.
.. literalinclude:: ../../Grammar/python.gram
:language: peg
https://github.com/python/cpython/commit/7f82f22eba1312617e1aa19cb916da1aae…
commit: 7f82f22eba1312617e1aa19cb916da1aae1609a4
branch: master
author: Raymond Hettinger <rhettinger(a)users.noreply.github.com>
committer: rhettinger <rhettinger(a)users.noreply.github.com>
date: 2020-11-30T09:55:13-08:00
summary:
bpo-42501: Revise the usage note for Enums with the choices (GH-23563)
files:
M Doc/library/argparse.rst
diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst
index 7a7a4cf94979a..a32b99901a7b4 100644
--- a/Doc/library/argparse.rst
+++ b/Doc/library/argparse.rst
@@ -1133,20 +1133,9 @@ container should match the type_ specified::
Any container can be passed as the *choices* value, so :class:`list` objects,
:class:`set` objects, and custom containers are all supported.
-This includes :class:`enum.Enum`, which could be used to restrain
-argument's choices; if we reuse previous rock/paper/scissors game example,
-this could be as follows::
-
- >>> from enum import Enum
- >>> class GameMove(Enum):
- ... ROCK = 'rock'
- ... PAPER = 'paper'
- ... SCISSORS = 'scissors'
- ...
- >>> parser = argparse.ArgumentParser(prog='game.py')
- >>> parser.add_argument('move', type=GameMove, choices=GameMove)
- >>> parser.parse_args(['rock'])
- Namespace(move=<GameMove.ROCK: 'rock'>)
+
+Use of :class:`enum.Enum` is not recommended because it is difficult to
+control its appearance in usage, help, and error messages.
required
https://github.com/python/cpython/commit/f4389bfbb5b9f67db1505dd0003987896e…
commit: f4389bfbb5b9f67db1505dd0003987896eae560b
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington(a)users.noreply.github.com>
committer: miss-islington <31488909+miss-islington(a)users.noreply.github.com>
date: 2020-11-30T09:30:46-08:00
summary:
bpo-42508: Remove bogus idlelib.pyshell.ModifiedInterpreter attribute (GH-23570)
restart_subprocess is a method of self, the pyshell.InteractiveInterpreter instance. The latter does not have an interp attribute redundantly referring to itself. (The PyShell instance does have an interp attribute, referring to the InteractiveInterpreter instance.)
(cherry picked from commit e41bfd15dd148627b4f39c2a5837bddd8894d345)
Co-authored-by: Terry Jan Reedy <tjreedy(a)udel.edu>
files:
M Lib/idlelib/pyshell.py
diff --git a/Lib/idlelib/pyshell.py b/Lib/idlelib/pyshell.py
index b69916dbe876c..adc302883ae66 100755
--- a/Lib/idlelib/pyshell.py
+++ b/Lib/idlelib/pyshell.py
@@ -757,7 +757,7 @@ def runcommand(self, code):
def runcode(self, code):
"Override base class method"
if self.tkconsole.executing:
- self.interp.restart_subprocess()
+ self.restart_subprocess()
self.checklinecache()
debugger = self.debugger
try:
https://github.com/python/cpython/commit/e41bfd15dd148627b4f39c2a5837bddd88…
commit: e41bfd15dd148627b4f39c2a5837bddd8894d345
branch: master
author: Terry Jan Reedy <tjreedy(a)udel.edu>
committer: terryjreedy <tjreedy(a)udel.edu>
date: 2020-11-30T12:09:43-05:00
summary:
bpo-42508: Remove bogus idlelib.pyshell.ModifiedInterpreter attribute (GH-23570)
restart_subprocess is a method of self, the pyshell.InteractiveInterpreter instance. The latter does not have an interp attribute redundantly referring to itself. (The PyShell instance does have an interp attribute, referring to the InteractiveInterpreter instance.)
files:
M Lib/idlelib/pyshell.py
diff --git a/Lib/idlelib/pyshell.py b/Lib/idlelib/pyshell.py
index 343d2ef32d7a7..c3ecdc7b1b077 100755
--- a/Lib/idlelib/pyshell.py
+++ b/Lib/idlelib/pyshell.py
@@ -757,7 +757,7 @@ def runcommand(self, code):
def runcode(self, code):
"Override base class method"
if self.tkconsole.executing:
- self.interp.restart_subprocess()
+ self.restart_subprocess()
self.checklinecache()
debugger = self.debugger
try: