[pypy-commit] pypy default: Complain if we pass None to something which expects unicode or str
rlamy
pypy.commits at gmail.com
Fri Feb 23 11:02:17 EST 2018
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch:
Changeset: r93876:2ec2d28bba33
Date: 2018-02-23 16:01 +0000
http://bitbucket.org/pypy/pypy/changeset/2ec2d28bba33/
Log: Complain if we pass None to something which expects unicode or str
diff --git a/rpython/rlib/objectmodel.py b/rpython/rlib/objectmodel.py
--- a/rpython/rlib/objectmodel.py
+++ b/rpython/rlib/objectmodel.py
@@ -137,14 +137,11 @@
def decorator(f):
def get_annotation(t):
from rpython.annotator.signature import annotation
- from rpython.annotator.model import SomeObject, SomeString, SomeUnicodeString
+ from rpython.annotator.model import SomeObject
if isinstance(t, SomeObject):
return t
- s_result = annotation(t)
- if (isinstance(s_result, SomeString) or
- isinstance(s_result, SomeUnicodeString)):
- return s_result.__class__(can_be_None=True)
- return s_result
+ return annotation(t)
+
def get_type_descr_of_argument(arg):
# we don't want to check *all* the items in list/dict: we assume
# they are already homogeneous, so we only check the first
diff --git a/rpython/rlib/test/test_objectmodel.py b/rpython/rlib/test/test_objectmodel.py
--- a/rpython/rlib/test/test_objectmodel.py
+++ b/rpython/rlib/test/test_objectmodel.py
@@ -484,12 +484,6 @@
# in RPython there is an implicit int->float promotion
assert f(42) == 42
-def test_enforceargs_None_string():
- @enforceargs(str, unicode)
- def f(a, b):
- return a, b
- assert f(None, None) == (None, None)
-
def test_enforceargs_complex_types():
@enforceargs([int], {str: int})
def f(a, b):
More information about the pypy-commit
mailing list