This commit is contained in:
blueloveTH 2023-08-13 00:42:36 +08:00
parent 48b83b6a07
commit b42a2d5b26
4 changed files with 7 additions and 6 deletions

View File

@ -21,7 +21,7 @@
#include <type_traits>
#include <random>
#define PK_VERSION "1.1.3"
#define PK_VERSION "1.1.4"
#include "config.h"
#include "export.h"

View File

@ -49,7 +49,7 @@ struct Dict{
PyObject* try_get(PyObject* key) const;
bool contains(PyObject* key) const;
void erase(PyObject* key);
bool erase(PyObject* key);
void update(const Dict& other);
template<typename __Func>

View File

@ -102,10 +102,10 @@ namespace pkpy{
return ok;
}
void Dict::erase(PyObject* key){
bool Dict::erase(PyObject* key){
bool ok; int i;
_probe(key, ok, i);
if(!ok) return;
if(!ok) return false;
_items[i].first = nullptr;
_items[i].second = nullptr;
_size--;
@ -127,6 +127,7 @@ namespace pkpy{
}
_nodes[i].prev = -1;
_nodes[i].next = -1;
return true;
}
void Dict::update(const Dict& other){

View File

@ -1077,8 +1077,8 @@ void init_builtins(VM* _vm) {
_vm->bind__delitem__(_vm->tp_dict, [](VM* vm, PyObject* obj, PyObject* key) {
Dict& self = _CAST(Dict&, obj);
if(!self.contains(key)) vm->KeyError(key);
self.erase(key);
bool ok = self.erase(key);
if(!ok) vm->KeyError(key);
});
_vm->bind_method<1>("dict", "pop", [](VM* vm, ArgsView args) {