Python "SystemError" from a C Extension or Interpreter Bug in CI
A SystemError signals an internal failure in the interpreter or a C extension - a C function returned an inconsistent result. It rarely means your pure-Python code is wrong; it usually points at a broken or mismatched native module.
What this error means
Code raises SystemError, often "returned a result with an error set" or "null argument to internal routine", from inside a compiled module (numpy, lxml, a custom C extension). It can be triggered by an ABI mismatch after a partial upgrade.
SystemError: <built-in function ...> returned a result with an error set
# or
SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats
File ".../mypkg/_speedups.pyx", line 88, in mypkg._speedups.parseCommon causes
C-extension or ABI mismatch
A compiled extension built against a different Python/NumPy ABI behaves inconsistently at the C level, raising SystemError. Common after upgrading one half of a coupled pair.
A genuine bug in a native module
A C/Cython extension that mishandles the error state (returns NULL without setting an exception, or vice versa) surfaces as SystemError in the caller.
How to fix it
Reinstall the native module cleanly
Force a fresh, ABI-matched build/wheel of the offending extension and its coupled dependencies.
pip install --force-reinstall --no-cache-dir <pkg>
# for the numpy-coupled stack, reinstall together
pip install --force-reinstall numpy <pkg>Pin a known-good version
- Identify the compiled module in the traceback (the
.so/.pyxframe). - Pin that package - and anything it shares an ABI with - to a release combination known to work.
- Rebuild in a clean environment so no stale
.sois reused.
How to prevent it
- Keep ABI-coupled packages (NumPy and its consumers) pinned together.
- Rebuild native extensions from clean environments in CI.
- Report reproducible SystemErrors upstream - they’re usually native-module bugs.