#1138218 python-cobra: infinite recursion and GPR deepcopy failures on Python 3.14

Package:
python-cobra
Source:
python-cobra
Submitter:
Ujjwal Sarswat
Date:
2026-06-02 16:07:01 UTC
Severity:
normal
Tags:
#1138218#5
Date:
2026-05-29 15:13:29 UTC
From:
To:
Package: python-cobra
Version: 0.29.1-5
Severity: serious
Tags: patch ftbfs
Justification: fails to build from source (but built successfully in the past)
X-Debbugs-Cc: debian-amd64@lists.debian.org, debian-arm@lists.debian.org, debian-powerpc@lists.debian.org, ujjwal.sarswat@canonical.com
User: ubuntu-devel@lists.ubuntu.com
Usertags: origin-ubuntu stonking ubuntu-patch
User: debian-amd64@lists.debian.org
Usertags: amd64
User: debian-arm@lists.debian.org
Usertags: arm64 armhf
User: debian-qa@lists.debian.org
Usertags: i386
User: debian-powerpc@lists.debian.org
Usertags: ppc64el

Dear Maintainer,

In Python 3.14, two related regressions were introduced in cobrapy:

1. `deepcopy(super(Reaction, self), memo)` no longer short-circuits via the
   memo dict, causing `Reaction.__deepcopy__` to call itself indefinitely and
   raise a RecursionError (LP: #2154412,
https://github.com/opencobra/cobrapy/issues/1474).

2. `ast.Module.__reduce__` now returns three positional arguments, which
   `GPR.__init__` cannot accept, causing deepcopy of any model containing GPR
   objects to fail with a TypeError (LP: #2154413,
https://github.com/opencobra/cobrapy/issues/1475).

Both failures are triggered by the presence of the custom `__copy__` and
`__deepcopy__` overrides on `Reaction`. Removing them lets Python's default
copy machinery handle `Reaction` and the `GPR` objects it references correctly,
without requiring any manual workaround. The fix is minimal and has been
verified against the upstream test suite. Upstream has a fix PR merged
and should be available soon in debian after a new release:
https://github.com/opencobra/cobrapy/pull/1471

In Ubuntu, the attached patch was applied to achieve the following:

  * d/p/python-314.patch: remove Reaction.__copy__ and __deepcopy__,
    fixing infinite recursion and GPR deepcopy failures on Python 3.14
    (LP: #2154412, LP: #2154413)


Thanks for considering the patch.

#1138218#8
Date:
2026-06-02 15:59:09 UTC
From:
To:
Hello,

Bug #1138218 in python-cobra reported by you has been fixed in the
Git repository and is awaiting an upload. You can see the commit
message below and you can check the diff of the fix at:

https://salsa.debian.org/med-team/python-cobra/-/commit/67e866a1aaa36c7e7ea21dda293b4a8e3d940957

(this message was generated automatically)
-- 
Greetings

https://bugs.debian.org/1138218

#1138218#15
Date:
2026-06-02 16:05:25 UTC
From:
To:
We believe that the bug you reported is fixed in the latest version of
python-cobra, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 1138218@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Andreas Tille <tille@debian.org> (supplier of updated python-cobra package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)
Format: 1.8
Date: Tue, 02 Jun 2026 17:28:56 +0200
Source: python-cobra
Architecture: source
Version: 0.31.1-1
Distribution: unstable
Urgency: medium
Maintainer: Debian Med Packaging Team <debian-med-packaging@lists.alioth.debian.org>
Changed-By: Andreas Tille <tille@debian.org>
Closes: 1138218
Changes:
 python-cobra (0.31.1-1) unstable; urgency=medium
 .
   * Team upload.
 .
   [ Ujjwal Sarswat ]
   * Fix infinite recursion and GPR deepcopy failures on Python 3.14
     Closes: #1138218
 .
   [ Andreas Tille ]
   * DEP3
   * New upstream version
   * Standards-Version: 4.7.4 (routine-update)
   * Drop alien lintiantag
     python-package-depends-on-package-from-other-python-variant
   * Drop unknown architecture powerpcspe
   * Build-Depends: pybuild-plugin-pyproject
Checksums-Sha1:
 be88a3068176c7bb057eb4631311545ce7d96248 3077 python-cobra_0.31.1-1.dsc
 7fc4a78b22778d92c8f78583eca430fd072e7e09 3657267 python-cobra_0.31.1.orig.tar.gz
 96dd3dd274d901b5afc081137d15f82ae6805167 11072 python-cobra_0.31.1-1.debian.tar.xz
 705c6d1788bcda11cca3b7abdc2d8011da9c0719 12293 python-cobra_0.31.1-1_amd64.buildinfo
Checksums-Sha256:
 340ef899e598f9632b95bef31834ece940e5cb5ffbb7e5843cc9473fcbb859cd 3077 python-cobra_0.31.1-1.dsc
 0ae936b414d7fd905a75493630d506e408720bd21b2f5318b370a6c555666a5c 3657267 python-cobra_0.31.1.orig.tar.gz
 0265072178b1eef849214b5d26c7cae7db7abbbe91412b2fae6ac598403bb9b1 11072 python-cobra_0.31.1-1.debian.tar.xz
 11e4c1bb6200b5aed631e3fa01848fc4c2e73524049dc0569eb343dcf51eb076 12293 python-cobra_0.31.1-1_amd64.buildinfo
Files:
 ec6f1bee880002d5c81e89ec44b7fee8 3077 python optional python-cobra_0.31.1-1.dsc
 467af25cdd05df3b773448976f1e6e80 3657267 python optional python-cobra_0.31.1.orig.tar.gz
 e0af1d6703818ebe5ac3134b26c5706d 11072 python optional python-cobra_0.31.1-1.debian.tar.xz
 8c85e426144cbfb25b1cc119745ff9ac 12293 python optional python-cobra_0.31.1-1_amd64.buildinfo
-----BEGIN PGP SIGNATURE-----

iQJFBAEBCgAvFiEE8fAHMgoDVUHwpmPKV4oElNHGRtEFAmoe+jURHHRpbGxlQGRl
Ymlhbi5vcmcACgkQV4oElNHGRtGeag/8Dj5YVeSiOGP4Vq62CL9+jTfdMiWsyGCq
qK+LDnOq/0hzUcHymmNEHe1fRouYcfHUNYvcG3MOinGcTEgFLRt/cHpSlhl61HlF
ydyDir3sCUT2LyYQA5rmJoD6aqTbBUK/lNJFYI4n+MU7Il2ktB+8F5GZAvmHb1B6
q7mvKGoAm+QyXYgMe+oHSKrGOlQeHpVjZKP3gA/x+rH+GSUZTATUU5q01wuMmyyx
6mkmBYdCvx2AO+8xr/vRXNKGJASA4uBWeCU9dRYrW8wgNF3JhvT+FZqMQDgzBAMv
0kWr4gRCr9/e8uzM8imrZk5g56Krd8jxOcroUva7ea2Cbx1pwcKBKvBWj66fgWJ4
+tljXgkXyMj+mX675U6er5mIzPN3wAma3A9b6oAuIthhJC5sivVilmf9mO21uZZA
fp73Hg74hzWoYkpCNURo2gGQLhTt5LsaZz41VnVcsYnse5bPEeZqrVLoFUJSkIr8
ceqIyccYmLGpM/APbAOfDZSVI8k6FKx/oHYk6I4vYO0rC/S1Njoqa2vKN4NMDUCp
U6dg41x9QR+WBT89+qFQOztPM6hOPybm5541P0s9JRQ6Rgmj3TqJdW5FQf4wdeMq
XZ6Ok5oaAMKbICluE6soKMHOhZ45PvxqcbVHMC7fqkN4Gx1y795ZIF/DPu0Mk54x
ow3Wqgv+cvQ=
=ziKD
-----END PGP SIGNATURE-----