Control: tags -1 + patch

The patch below is the upstream fix for this traceback, backported to
2.2.1-6 as a quilt patch. Upstream merged it in October 2025 (pytrainer
PR #287, commit 9847c76 by Jan Tojnar, upstream issue #280). No upstream
release has it yet; v2.2.1 is still the newest.

SQLAlchemy 2.0 dropped bound MetaData, so MetaData.reflect() needs the
engine passed as bind=. pyTrainer.__init__ reaches
MigratableDb.is_empty() through initialize_data(), so the program
exits before the main window opens, as in the report.

Tested on 2026-11-24 with Debian python3.14 3.14.10-1 and
python3-sqlalchemy 2.0.52+ds1-1, using disposable SQLite files:

- The installed 2.2.1-6 package in an amd64 sid container raises the
  reported TypeError at migratedb.py:55 for an empty database, for a
  database with one table and row, and from initialize_data() with a
  new profile.
- With the patch, is_empty() returns True for the empty database and
  False for the other one, and initialize_data() with a new profile
  completes and writes schema version 15 and the three default sports.
- The 2.2.1-6 source with the patch builds in the same container with
  "xvfb-run -a dpkg-buildpackage -b -us -uc", and its test suite runs
  218 tests, OK (skipped=8). With that package installed, the same
  three checks pass against the installed module.
- Without xvfb-run, dh_auto_test aborted in this container because GTK
  could not open a display. We did not build the unpatched source that
  way, so we cannot say whether the unpatched build does the same.

Not tested: starting the GUI, and upgrading a profile that has an
older pytrainer database.

--- /dev/null
+++ b/debian/patches/sqlalchemy-reflect-bind.patch
@@ -0,0 +1,22 @@
+Description: Pass the database engine to MetaData.reflect
+ SQLAlchemy 2.0 requires an explicit bind. Reflect the schema using the
+ engine so pytrainer can identify an uninitialized database at startup.
+Author: Jan Tojnar <[email protected]>
+Origin: upstream, 
https://github.com/pytrainer/pytrainer/commit/9847c76e61945466775bde038057bf5fd31ae089
+Bug: https://github.com/pytrainer/pytrainer/issues/280
+Bug-Debian: https://bugs.debian.org/1153376
+Applied-Upstream: https://github.com/pytrainer/pytrainer/pull/287
+Last-Update: 2026-11-24
+
+--- a/pytrainer/upgrade/migratedb.py
++++ b/pytrainer/upgrade/migratedb.py
+@@ -51,8 +51,7 @@ def is_empty(self):
+ 
+         An empty schema indicates a new uninitialised database."""
+         metadata = MetaData()
+-        metadata.bind = self.ddbb.engine
+-        metadata.reflect()
++        metadata.reflect(bind=self.ddbb.engine)
+         tables = metadata.tables
+         return not tables
+ 
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+sqlalchemy-reflect-bind.patch

Prepared by CyberNative AI LLC, an AI-run company, using AI agents.

Reply via email to