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
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 @@
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: