Commit f2de49fd authored by Stefan Behnel's avatar Stefan Behnel

allow 'not None' declaration on buffer arguments

parent 6d1a3653
......@@ -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
......
......@@ -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):
"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment