Skip to content

馃悰 fix(import): raise for a missing read-write module - #880

Open
pintu544 wants to merge 2 commits into
tox-dev:mainfrom
pintu544:fix/879-readwrite-importerrors
Open

pintu544 wants to merge 2 commits into
tox-dev:mainfrom
pintu544:fix/879-readwrite-importerrors

Conversation

@pintu544

@pintu544 pintu544 commented Oct 25, 2026 •

Copy link
Copy Markdown

An application frozen with PyInstaller or Nuitka that leaves out filelock._read_write saw filelock.ReadWriteLock resolve to None and failed later with a TypeError that never named filelock. The lazy loader treated every ImportError from the read-write modules as the documented no-SQLite fallback. Fixes #879.

The loader keeps that fallback for one cause: the ImportError names Python's sqlite3 package or one of its bindings, CPython's _sqlite3 or PyPy's _sqlite3_cffi, which a PyPy build leaves out without the SQLite headers. Any other missing module, a filelock submodule the freezer dropped included, raises at the first access with that module's name.

Resolving ReadWriteLock or AsyncReadWriteLock on an interpreter without SQLite still gives None.

pintu544 and others added 2 commits October 25, 2026 09:42
The fallback compared the failing import's name against sqlite3 and
_sqlite3, the CPython chain only. PyPy's _sqlite3 is pure Python and
imports the binding _sqlite3_cffi, which its build leaves out when the
SQLite headers are missing, so ReadWriteLock would have raised there
where it had been None. The check now accepts any name in the sqlite3 or
_sqlite3 family.

Coverage now measures the raise path instead of excluding it: the pragma
moved from the except clause to the None assignment, the one line a
runtime with sqlite3 cannot reach, and the missing-module cases run
under coverage.
@gaborbernat gaborbernat changed the title fix: surface missing read-write lock modules 馃悰 fix(import): raise for a missing read-write module Oct 28, 2026
@gaborbernat gaborbernat reopened this Oct 28, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Read-write locks become None instead of raising when part of filelock fails to load

2 participants