summaryrefslogtreecommitdiffstats
path: root/Tools/parser
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2019-04-29 12:36:57 (GMT)
committerGitHub <noreply@github.com>2019-04-29 12:36:57 (GMT)
commit8c77b8cb9188165a123f2512026e3629bf03dc9b (patch)
tree863ea19f5f2c8ec179c32b3d06dc8366859ae26e /Tools/parser
parent99fcc616d400cd31af0733c3f8cc93bcc1d32a44 (diff)
downloadcpython-8c77b8cb9188165a123f2512026e3629bf03dc9b.zip
cpython-8c77b8cb9188165a123f2512026e3629bf03dc9b.tar.gz
cpython-8c77b8cb9188165a123f2512026e3629bf03dc9b.tar.bz2
bpo-36540: PEP 570 -- Implementation (GH-12701)
This commit contains the implementation of PEP570: Python positional-only parameters. * Update Grammar/Grammar with new typedarglist and varargslist * Regenerate grammar files * Update and regenerate AST related files * Update code object * Update marshal.c * Update compiler and symtable * Regenerate importlib files * Update callable objects * Implement positional-only args logic in ceval.c * Regenerate frozen data * Update standard library to account for positional-only args * Add test file for positional-only args * Update other test files to account for positional-only args * Add News entry * Update inspect module and related tests
Diffstat (limited to 'Tools/parser')
-rw-r--r--Tools/parser/unparse.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Tools/parser/unparse.py b/Tools/parser/unparse.py
index 70b47a1..385902e 100644
--- a/Tools/parser/unparse.py
+++ b/Tools/parser/unparse.py
@@ -592,14 +592,18 @@ class Unparser:
def _arguments(self, t):
first = True
# normal arguments
- defaults = [None] * (len(t.args) - len(t.defaults)) + t.defaults
- for a, d in zip(t.args, defaults):
+ all_args = t.posonlyargs + t.args
+ defaults = [None] * (len(all_args) - len(t.defaults)) + t.defaults
+ for index, elements in enumerate(zip(all_args, defaults), 1):
+ a, d = elements
if first:first = False
else: self.write(", ")
self.dispatch(a)
if d:
self.write("=")
self.dispatch(d)
+ if index == len(t.posonlyargs):
+ self.write(", /")
# varargs, or bare '*' if no varargs but keyword-only arguments present
if t.vararg or t.kwonlyargs: