py/objsingleton: Use mp_generic_unary_op for singleton objects.
So these types more closely match NoneType, eg they can be hashed, like in CPython.
This commit is contained in:
parent
de8c04317b
commit
f5eec903fa
|
@ -47,6 +47,7 @@ const mp_obj_type_t mp_type_singleton = {
|
|||
{ &mp_type_type },
|
||||
.name = MP_QSTR_,
|
||||
.print = singleton_print,
|
||||
.unary_op = mp_generic_unary_op,
|
||||
};
|
||||
|
||||
const mp_obj_singleton_t mp_const_ellipsis_obj = {{&mp_type_singleton}, MP_QSTR_Ellipsis};
|
||||
|
|
|
@ -4,3 +4,6 @@ print(...)
|
|||
print(Ellipsis)
|
||||
|
||||
print(... == Ellipsis)
|
||||
|
||||
# Test that Ellipsis can be hashed
|
||||
print(type(hash(Ellipsis)))
|
||||
|
|
|
@ -48,3 +48,6 @@ except TypeError:
|
|||
|
||||
# NotImplemented isn't handled specially in unary methods
|
||||
print(-c)
|
||||
|
||||
# Test that NotImplemented can be hashed
|
||||
print(type(hash(NotImplemented)))
|
||||
|
|
Loading…
Reference in New Issue