#4020·Nuitka

AssertionError (micro_passes == 0) in ModuleRegistry.addModuleOptimizationTimeInformation when compiling PyAV's av.video.stream

Author: abraham-diazCreated Aug 31, 2026Updated Oct 1, 2026
Labelsbugfactory

Environment

  • Nuitka: 4.2 (also confirmed present, unchanged, in 4.1.3 before upgrading)
  • OS: Windows 11 (build 10.0.26200), x86_64
  • Python: 3.12.10, 64-bit CPython official
  • Compiler: MSVC 14.51 (irrelevant here — the crash happens during Python-level module optimization, before any C compilation/Scons step)
  • PyAV (av): 18.0.0

Minimal reproducer

python
# main.py
import av
print(av.__version__)

python -m nuitka --standalone --assume-yes-for-downloads --include-package=av main.py

Crashes within seconds, no other dependencies needed. We first hit this in a much
larger app (torch, transformers, faster-whisper, ...) that depends on PyAV
transitively through faster-whisper's audio decoding — the larger build takes
10+ minutes to reach the crash, but it's the exact same assert on the exact same
module, so I reduced it to the reproducer above.

Traceback

Traceback (most recent call last):
  File "<venv>\Lib\site-packages\nuitka\MainControl.py", line 1456, in main
    _main()
  File "<venv>\Lib\site-packages\nuitka\MainControl.py", line 1273, in _main
    main_module = _createMainModule()
  File "<venv>\Lib\site-packages\nuitka\MainControl.py", line 354, in _createMainModule
    optimizeModules(main_module.getOutputFilename())
  File "<venv>\Lib\site-packages\nuitka\optimizations\Optimization.py", line 410, in optimizeModules
    _optimizeModules(output_filename)
  File "<venv>\Lib\site-packages\nuitka\optimizations\Optimization.py", line 374, in _optimizeModules
    unfinished_modules = _makeOptimizationPass()
  File "<venv>\Lib\site-packages\nuitka\optimizations\Optimization.py", line 334, in _makeOptimizationPass
    ModuleRegistry.addModuleOptimizationTimeInformation(
  File "<venv>\Lib\site-packages\nuitka\ModuleRegistry.py", line 319, in addModuleOptimizationTimeInformation
    assert micro_passes == 0
AssertionError

This does not require --experimental=ignore-extra-micro-pass — it crashes
with default flags.

Diagnostic detail (from nuitka-crash-report.xml)

av.video.stream appears twice in the report, both times as:

<module name="av.video.stream" kind="PythonExtensionModule" usage="root_module"
        reason="Root module" source_path="${sys.prefix}\Lib\site-packages\av\video\stream.pyd"
        distribution="av">

Every other av.* submodule in the report appears once, with usage="import".
av.video.stream ships both a .py shim and a compiled .pyd (PyAV's Cython
pure-Python-mode pattern) — my guess is it's getting registered twice: once via
--include-package's extension-module collection (since it's a .pyd), and once
via av/__init__.py's own eager from av.video.stream import VideoStream. The
second registration then trips the assert micro_passes == 0 at
ModuleRegistry.py:319, whose surrounding comment ("Do not record cached
bytecode loaded timing information") suggests it was written to special-case a
cached-bytecode-reload replay, not two live root/import registrations of the
same compiled extension module.

Relation to #3946

Possibly the same family of "extra micro pass" invariant violations as #3946,
but a distinct manifestation: #3946 hits the guarded sysexit in
Optimization.py:119 (suppressible via --experimental=ignore-extra-micro-pass),
while this one is an unconditional assert further down in ModuleRegistry.py
that fires even without that flag.

Impact

Blocks --standalone compilation of anything depending on PyAV (e.g.
faster-whisper for audio decoding, or any video/audio processing pipeline using
av directly).

[nuitka-crash-report-sanitized.xml](https://github.com/user-attachments/files/31631530/nuitka-crash-report-sanitized.xml)