mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 19:40:18 +00:00
...
This commit is contained in:
parent
53ea790caf
commit
8c4ccaa240
@ -360,7 +360,9 @@ i64 VM::py_hash(PyObject* obj){
|
||||
PyObject* ret = call_method(self, f);
|
||||
return CAST(i64, ret);
|
||||
}
|
||||
// it flow reaches here, obj must not be the trivial `object` type
|
||||
// if it is trivial `object`, return PK_BITS
|
||||
if(ti == &_all_types[tp_object]) return PK_BITS(obj);
|
||||
// otherwise, we check if it has a custom __eq__ other than object.__eq__
|
||||
bool has_custom_eq = false;
|
||||
if(ti->m__eq__) has_custom_eq = true;
|
||||
else{
|
||||
|
@ -845,6 +845,18 @@ try:
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
a = hash(object()) # object is hashable
|
||||
a = hash(A()) # A is hashable
|
||||
class B:
|
||||
def __eq__(self, o): return True
|
||||
|
||||
try:
|
||||
hash(B())
|
||||
print('未能拦截错误, 在测试 B.__hash__')
|
||||
exit(1)
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
# 未完全测试准确性-----------------------------------------------
|
||||
# 116: 1009: _vm->bind__repr__(_vm->tp_mappingproxy, [](VM* vm, PyObject* obj) {
|
||||
# #####: 1010: MappingProxy& self = _CAST(MappingProxy&, obj);
|
||||
|
Loading…
x
Reference in New Issue
Block a user