-
Notifications
You must be signed in to change notification settings - Fork 293
Closed
Description
Note that ensure_new_type
does not raise a NotImplementedError
, it returns it. This is remarkably weird for a public interface (and totally non-intuitive).
Also, this creates an asymmetry between Python 2 and Python 3 that probably shouldn't exist. For example, ensure_new_type([])
in Python 3 will return its argument without complaint. However, in Python 2, it will return a NotImplementedError
:
Python 3.4.3 (default, Sep 3 2015, 05:14:09)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from future.utils import ensure_new_type
>>> ensure_new_type([])
[]
Python 2.7.10 (default, Sep 24 2015, 10:13:45)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from future.utils import ensure_new_type
>>> ensure_new_type([])
NotImplementedError("type <type 'list'> not supported",)
Nothing in future
itself appears to depend on that behavior, nor does it appear to be widely used (in other words, changing its behavior at this point doesn't appear to have widespread backward compatibility implications).
I'm pretty sure the correct behavior should be just to return obj
in Python 2, if it can't be cast into a new type.
Metadata
Metadata
Assignees
Labels
No labels