mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
bpo-29622: Make AST constructor to accept less than enough number of positional arguments (GH-249)
bpo-29463 added optional "docstring" field to 4 AST types. While it is optional, it breaks backward compatibility because AST constructor requires number of positional argument is same to number of fields. AST types accepts empty arguments, and incomplete keyword arguments. But it's not big problem because field can be filled after creation, and checked when compiling. So stop requiring complete set of fields for positional arguments too.
This commit is contained in:
parent
561ca80cff
commit
4c78c527d2
3 changed files with 34 additions and 42 deletions
|
@ -373,12 +373,8 @@ class AST_Tests(unittest.TestCase):
|
|||
self.assertEqual(x.right, 3)
|
||||
self.assertEqual(x.lineno, 0)
|
||||
|
||||
# node raises exception when not given enough arguments
|
||||
self.assertRaises(TypeError, ast.BinOp, 1, 2)
|
||||
# node raises exception when given too many arguments
|
||||
self.assertRaises(TypeError, ast.BinOp, 1, 2, 3, 4)
|
||||
# node raises exception when not given enough arguments
|
||||
self.assertRaises(TypeError, ast.BinOp, 1, 2, lineno=0)
|
||||
# node raises exception when given too many arguments
|
||||
self.assertRaises(TypeError, ast.BinOp, 1, 2, 3, 4, lineno=0)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue