This commit is contained in:
blueloveTH 2023-06-17 22:54:02 +08:00
parent 5e93c0d6e8
commit 596ecd5c9e
2 changed files with 8 additions and 3 deletions

View File

@ -1471,6 +1471,9 @@ extern "C" {
}catch(pkpy::Exception& e){ }catch(pkpy::Exception& e){
*ok = false; *ok = false;
*res = e.summary().c_str_dup(); *res = e.summary().c_str_dup();
}catch(std::exception& e){
*ok = false;
*res = strdup(e.what());
}catch(...){ }catch(...){
*ok = false; *ok = false;
*res = strdup("unknown error"); *res = strdup("unknown error");

View File

@ -1566,9 +1566,11 @@ inline void Dict::_probe(PyObject *key, bool &ok, int &i) const{
inline void CodeObjectSerializer::write_object(VM *vm, PyObject *obj){ inline void CodeObjectSerializer::write_object(VM *vm, PyObject *obj){
if(is_int(obj)) write_int(_CAST(i64, obj)); if(is_int(obj)) write_int(_CAST(i64, obj));
if(is_float(obj)) write_float(_CAST(f64, obj)); else if(is_float(obj)) write_float(_CAST(f64, obj));
if(is_type(obj, vm->tp_str)) write_str(_CAST(Str&, obj)); else if(is_type(obj, vm->tp_str)) write_str(_CAST(Str&, obj));
FATAL_ERROR(); else{
throw std::runtime_error(fmt(OBJ_NAME(vm->_t(obj)).escape(), " is not serializable"));
}
} }
} // namespace pkpy } // namespace pkpy