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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
f2de49fd
Commit
f2de49fd
authored
May 07, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow 'not None' declaration on buffer arguments
parent
6d1a3653
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+3
-2
tests/run/bufaccess.pyx
tests/run/bufaccess.pyx
+14
-0
No files found.
Cython/Compiler/Nodes.py
View file @
f2de49fd
...
...
@@ -2978,12 +2978,13 @@ class DefNode(FuncDefNode):
arg
.
needs_conversion
=
0
arg
.
needs_type_test
=
0
arg
.
is_generic
=
1
if
arg
.
type
.
is_pyobject
:
if
arg
.
type
.
is_pyobject
or
arg
.
type
.
is_buffer
:
if
arg
.
or_none
:
arg
.
accept_none
=
True
elif
arg
.
not_none
:
arg
.
accept_none
=
False
elif
arg
.
type
.
is_extension_type
or
arg
.
type
.
is_builtin_type
:
elif
(
arg
.
type
.
is_extension_type
or
arg
.
type
.
is_builtin_type
or
arg
.
type
.
is_buffer
):
if
arg
.
default
and
arg
.
default
.
constant_result
is
None
:
# special case: def func(MyType obj = None)
arg
.
accept_none
=
True
...
...
tests/run/bufaccess.pyx
View file @
f2de49fd
...
...
@@ -225,6 +225,20 @@ def as_argument(object[int] bufarg, int n):
print
bufarg
[
i
],
print
'END'
@
testcase
def
as_argument_not_none
(
object
[
int
]
bufarg
not
None
):
"""
>>> A = IntMockBuffer("A", range(6))
>>> as_argument_not_none(A)
acquired A
ACCEPTED
released A
>>> as_argument_not_none(None)
Traceback (most recent call last):
TypeError: Argument 'bufarg' must not be None
"""
print
'ACCEPTED'
@
testcase
def
as_argument_defval
(
object
[
int
]
bufarg
=
IntMockBuffer
(
'default'
,
range
(
6
)),
int
n
=
6
):
"""
...
...
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