Fix bug in Python builtin support for keyword args

The fix is when using kwargs feature or -keyword.
The fix is in the argument error checking when wrapping zero
argument constructors only. Supplied keyword args were silently
ignored.

Issue #1595
This commit is contained in:
William S Fulton 2019-11-01 19:46:42 +00:00
commit cb5d7398b5
4 changed files with 86 additions and 7 deletions

View file

@ -79,3 +79,46 @@ if rfoo(n=11, x=22) != -11:
if rfoo(x=11, n=22) != 11:
raise RuntimeError
# Extended constructors
e = Extending0()
e = Extending1(one=1)
e = Extending1(1)
e = Extending2(1, "two")
e = Extending2(1, two="two")
e = Extending2(two="two", one=1)
e = ExtendingOptArgs1()
e = ExtendingOptArgs1(1)
e = ExtendingOptArgs2(one=1)
e = ExtendingOptArgs2()
e = ExtendingOptArgs2(one=1)
e = ExtendingOptArgs2(two="two")
e = ExtendingOptArgs2(two="two", one=1)
# Invalid kwargs test
h = Hello()
try:
h = Hello(nonexistent=10)
raise RuntimeError("missed exception")
except TypeError as e:
pass
f = Foo(1)
f = Foo(a=1)
try:
f = Foo(nonexistent=10)
raise RuntimeError("missed exception")
except TypeError as e:
pass
try:
f = Foo(a=1, nonexistent=10)
raise RuntimeError("missed exception")
except TypeError as e:
pass
try:
f = Foo(1, nonexistent=10)
raise RuntimeError("missed exception")
except TypeError as e:
pass