Reverted GitHub Actions changes.

pull/13171/head
Joshua Haberman 3 years ago
parent 14f696fad6
commit 5815be9ae6
  1. 5
      .github/workflows/bazel_tests.yml
  2. 17
      python/protobuf.c

@ -30,6 +30,7 @@ jobs:
- name: Setup Python venv
run: rm -rf /tmp/venv && python3 -m venv /tmp/venv
- name: Install dependencies
run: sudo apt install -y valgrind
run: sudo apt install -y ${{ matrix.install }}
if: matrix.install != ''
- name: Run tests
run: cd ${{ github.workspace }} && PATH=/tmp/venv/bin:$PATH CC=${{ matrix.CC }} bazel test --test_output=errors --config=valgrind python:minimal_test ${{ matrix.flags }}
run: cd ${{ github.workspace }} && PATH=/tmp/venv/bin:$PATH CC=${{ matrix.CC }} bazel test --test_output=errors ... ${{ matrix.flags }}

@ -50,6 +50,11 @@ static struct PyModuleDef module_def = {PyModuleDef_HEAD_INIT,
// ModuleState
// -----------------------------------------------------------------------------
PyUpb_ModuleState* PyUpb_ModuleState_MaybeGet(void) {
PyObject* module = PyState_FindModule(&module_def);
return module ? PyModule_GetState(module) : NULL;
}
PyUpb_ModuleState *PyUpb_ModuleState_GetFromModule(PyObject *module) {
PyUpb_ModuleState *state = PyModule_GetState(module);
assert(state);
@ -57,8 +62,9 @@ PyUpb_ModuleState *PyUpb_ModuleState_GetFromModule(PyObject *module) {
return state;
}
PyUpb_ModuleState *PyUpb_ModuleState_Get() {
PyUpb_ModuleState *PyUpb_ModuleState_Get(void) {
PyObject *module = PyState_FindModule(&module_def);
assert(module);
return PyUpb_ModuleState_GetFromModule(module);
}
@ -73,7 +79,14 @@ void PyUpb_ObjCache_Add(const void *key, PyObject *py_obj) {
}
void PyUpb_ObjCache_Delete(const void *key) {
PyUpb_ModuleState *s = PyUpb_ModuleState_Get();
PyUpb_ModuleState *s = PyUpb_ModuleState_MaybeGet();
if (!s) {
// During the shutdown sequence, our object's Dealloc() methods can be
// called *after* our module Dealloc() method has been called. At that
// point our state will be NULL and there is nothing to delete out of the
// map.
return;
}
upb_value val;
upb_inttable_remove(&s->obj_cache, (uintptr_t)key, &val);
assert(upb_value_getptr(val));

Loading…
Cancel
Save