typed_python icon indicating copy to clipboard operation
typed_python copied to clipboard

deserializePythonObjectFromName has unreachable code

Open wllgrnt opened this issue 2 years ago • 0 comments

In typed_python/PythonSerializationContext_deserialization.cpp, line 256, in the deserializePythonObjectFromName function, the second error type "Object named doesn't exist in this codebase" will never be raised.

PyObject* PythonSerializationContext::deserializePythonObjectFromName(DeserializationBuffer& b, size_t wireType, int64_t memo) const {
    PyEnsureGilAcquired acquireTheGil;

    assertWireTypesEqual(wireType, WireType::BYTES);

    std::string name = b.readStringObject();

    PyObject* result = PyObject_CallMethod(mContextObj, "objectFromName", "s", name.c_str());

    if (!result) {
        throw PythonExceptionSet();
    }
    if (result == Py_None){
        throw std::runtime_error("Failed to deserialize Type '" + name + "'");
    }

    if (result == Py_None) {
        throw std::runtime_error(
            "Object named " + name + " doesn't exist in this codebase. Perhaps you "
            "are deserializing an object from an earlier codebase?"
        );
    }

    if (memo != -1) {
        b.addCachedPyObj(memo, incref(result));
    }

    return result;
}```

wllgrnt avatar Sep 28 '22 15:09 wllgrnt