Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
2e257fcf
Commit
2e257fcf
authored
Feb 02, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test argument unpacking code for extension types and Python types
parent
0c1b5aa8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
235 additions
and
0 deletions
+235
-0
tests/run/classkwonlyargs.pyx
tests/run/classkwonlyargs.pyx
+110
-0
tests/run/extkwonlyargs.pyx
tests/run/extkwonlyargs.pyx
+110
-0
tests/run/kwonlyargs.pyx
tests/run/kwonlyargs.pyx
+15
-0
No files found.
tests/run/classkwonlyargs.pyx
0 → 100644
View file @
2e257fcf
__doc__
=
"""
>>> spam = Spam()
>>> b,c,d,e,f,g,h,k = spam.b,spam.c,spam.d,spam.e,spam.f,spam.g,spam.h,spam.k
>>> b(1,2,3)
>>> b(1,2,3,4)
Traceback (most recent call last):
TypeError: function takes exactly 4 arguments (5 given)
>>> c(1,2)
>>> c(1,2,3)
>>> c(1,2,3,4)
Traceback (most recent call last):
TypeError: function takes at most 4 arguments (5 given)
>>> d(1,2)
>>> d(1,2, c=1)
>>> d(1,2,3)
Traceback (most recent call last):
TypeError: function takes at most 3 positional arguments (4 given)
>>> d(1,2, d=1)
Traceback (most recent call last):
TypeError: 'd' is an invalid keyword argument for this function
>>> e(1,2)
>>> e(1,2, c=1)
>>> e(1,2, d=1)
>>> e(1,2, c=1, d=2, e=3)
>>> e(1,2,3)
>>> e(1,2,3,4)
Traceback (most recent call last):
TypeError: function takes at most 4 positional arguments (5 given)
>>> f(1,2, c=1)
>>> f(1,2, c=1, d=2)
>>> f(1,2,3)
Traceback (most recent call last):
TypeError: function takes at most 3 positional arguments (4 given)
>>> f(1,2)
Traceback (most recent call last):
TypeError: required keyword argument 'c' is missing
>>> f(1,2, c=1, e=2)
Traceback (most recent call last):
TypeError: 'e' is an invalid keyword argument for this function
>>> g(1,2, c=1, f=2)
>>> g(1,2, c=1, e=0, f=2, d=11)
>>> g(1,2, c=1, f=2, e=0, x=25)
>>> g(1,2,3)
Traceback (most recent call last):
TypeError: function takes at most 3 positional arguments (4 given)
>>> g(1,2)
Traceback (most recent call last):
TypeError: required keyword argument 'c' is missing
>>> g(1,2, c=1)
Traceback (most recent call last):
TypeError: required keyword argument 'f' is missing
>>> h(1,2, c=1, f=2)
>>> h(1,2, c=1, f=2, e=3)
>>> h(1,2,3,4,5,6, c=1, f=2)
>>> h(1,2,3,4,5,6, c=1, f=2, e=3, x=25, y=11)
>>> h(1,2,3)
Traceback (most recent call last):
TypeError: required keyword argument 'c' is missing
>>> h(1,2, d=1)
Traceback (most recent call last):
TypeError: required keyword argument 'c' is missing
>>> k(1,2, c=1, f=2)
>>> k(1,2, c=1, f=2, e=3)
>>> k(1,2,3,4,5,6, d=1, f=2)
>>> k(1,2,3,4,5,6, d=1, f=2, e=3, x=25, y=11)
>>> k(1,2,3)
Traceback (most recent call last):
TypeError: required keyword argument 'f' is missing
>>> k(1,2, d=1)
Traceback (most recent call last):
TypeError: required keyword argument 'f' is missing
"""
class
Spam
:
def
b
(
self
,
a
,
b
,
c
):
pass
def
c
(
self
,
a
,
b
,
c
=
1
):
pass
def
d
(
self
,
a
,
b
,
*
,
c
=
88
):
pass
def
e
(
self
,
a
,
b
,
c
=
88
,
**
kwds
):
pass
def
f
(
self
,
a
,
b
,
*
,
c
,
d
=
42
):
pass
def
g
(
self
,
a
,
b
,
*
,
c
,
d
=
42
,
e
=
17
,
f
,
**
kwds
):
pass
def
h
(
self
,
a
,
b
,
*
args
,
c
,
d
=
42
,
e
=
17
,
f
,
**
kwds
):
pass
def
k
(
self
,
a
,
b
,
c
=
1
,
*
args
,
d
=
42
,
e
=
17
,
f
,
**
kwds
):
pass
tests/run/extkwonlyargs.pyx
0 → 100644
View file @
2e257fcf
__doc__
=
"""
>>> ext = Ext()
>>> b,c,d,e,f,g,h,k = ext.b,ext.c,ext.d,ext.e,ext.f,ext.g,ext.h,ext.k
>>> b(1,2,3)
>>> b(1,2,3,4)
Traceback (most recent call last):
TypeError: function takes exactly 3 arguments (4 given)
>>> c(1,2)
>>> c(1,2,3)
>>> c(1,2,3,4)
Traceback (most recent call last):
TypeError: function takes at most 3 arguments (4 given)
>>> d(1,2)
>>> d(1,2, c=1)
>>> d(1,2,3)
Traceback (most recent call last):
TypeError: function takes at most 2 positional arguments (3 given)
>>> d(1,2, d=1)
Traceback (most recent call last):
TypeError: 'd' is an invalid keyword argument for this function
>>> e(1,2)
>>> e(1,2, c=1)
>>> e(1,2, d=1)
>>> e(1,2, c=1, d=2, e=3)
>>> e(1,2,3)
>>> e(1,2,3,4)
Traceback (most recent call last):
TypeError: function takes at most 3 positional arguments (4 given)
>>> f(1,2, c=1)
>>> f(1,2, c=1, d=2)
>>> f(1,2,3)
Traceback (most recent call last):
TypeError: function takes at most 2 positional arguments (3 given)
>>> f(1,2)
Traceback (most recent call last):
TypeError: required keyword argument 'c' is missing
>>> f(1,2, c=1, e=2)
Traceback (most recent call last):
TypeError: 'e' is an invalid keyword argument for this function
>>> g(1,2, c=1, f=2)
>>> g(1,2, c=1, e=0, f=2, d=11)
>>> g(1,2, c=1, f=2, e=0, x=25)
>>> g(1,2,3)
Traceback (most recent call last):
TypeError: function takes at most 2 positional arguments (3 given)
>>> g(1,2)
Traceback (most recent call last):
TypeError: required keyword argument 'c' is missing
>>> g(1,2, c=1)
Traceback (most recent call last):
TypeError: required keyword argument 'f' is missing
>>> h(1,2, c=1, f=2)
>>> h(1,2, c=1, f=2, e=3)
>>> h(1,2,3,4,5,6, c=1, f=2)
>>> h(1,2,3,4,5,6, c=1, f=2, e=3, x=25, y=11)
>>> h(1,2,3)
Traceback (most recent call last):
TypeError: required keyword argument 'c' is missing
>>> h(1,2, d=1)
Traceback (most recent call last):
TypeError: required keyword argument 'c' is missing
>>> k(1,2, c=1, f=2)
>>> k(1,2, c=1, f=2, e=3)
>>> k(1,2,3,4,5,6, d=1, f=2)
>>> k(1,2,3,4,5,6, d=1, f=2, e=3, x=25, y=11)
>>> k(1,2,3)
Traceback (most recent call last):
TypeError: required keyword argument 'f' is missing
>>> k(1,2, d=1)
Traceback (most recent call last):
TypeError: required keyword argument 'f' is missing
"""
cdef
class
Ext
:
def
b
(
self
,
a
,
b
,
c
):
pass
def
c
(
self
,
a
,
b
,
c
=
1
):
pass
def
d
(
self
,
a
,
b
,
*
,
c
=
88
):
pass
def
e
(
self
,
a
,
b
,
c
=
88
,
**
kwds
):
pass
def
f
(
self
,
a
,
b
,
*
,
c
,
d
=
42
):
pass
def
g
(
self
,
a
,
b
,
*
,
c
,
d
=
42
,
e
=
17
,
f
,
**
kwds
):
pass
def
h
(
self
,
a
,
b
,
*
args
,
c
,
d
=
42
,
e
=
17
,
f
,
**
kwds
):
pass
def
k
(
self
,
a
,
b
,
c
=
1
,
*
args
,
d
=
42
,
e
=
17
,
f
,
**
kwds
):
pass
tests/run/kwonlyargs.pyx
View file @
2e257fcf
...
...
@@ -67,6 +67,18 @@ __doc__ = """
>>> h(1,2, d=1)
Traceback (most recent call last):
TypeError: required keyword argument 'c' is missing
>>> k(1,2, c=1, f=2)
>>> k(1,2, c=1, f=2, e=3)
>>> k(1,2,3,4,5,6, d=1, f=2)
>>> k(1,2,3,4,5,6, d=1, f=2, e=3, x=25, y=11)
>>> k(1,2,3)
Traceback (most recent call last):
TypeError: required keyword argument 'f' is missing
>>> k(1,2, d=1)
Traceback (most recent call last):
TypeError: required keyword argument 'f' is missing
"""
def
b
(
a
,
b
,
c
):
...
...
@@ -89,3 +101,6 @@ def g(a, b, *, c, d = 42, e = 17, f, **kwds):
def
h
(
a
,
b
,
*
args
,
c
,
d
=
42
,
e
=
17
,
f
,
**
kwds
):
pass
def
k
(
a
,
b
,
c
=
1
,
*
args
,
d
=
42
,
e
=
17
,
f
,
**
kwds
):
pass
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment