From: mattip Date: Wed, 20 May 2026 17:47:17 +0000 (-0400) Subject: Fix trivial PyPy failures X-Git-Tag: rel_2_0_50~6 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=24fada1c243ab78b8ac64af47e393f6d98d4c19f;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Fix trivial PyPy failures ### Description Fixes: #13274 References: #9154 There were two relatively causes to some of the ~21 failures on PyPy: - weakrefs may be deleted but the objects not finalized on PyPy. This manifests as `ref.obj() is None` I added a test for the `release()` case that also failed on CPython before the fix. - a condition added in 2022 for missing sqllite3 behaviour is no longer necessary, and is now causing a failure In order to run the changes in CI, I added PyPy to the PR CI run. Before merging I will revert that change. There are still a number of failures with PyPy around different error messages, different inspect.signatures and one sticky problem with the pure-python datetime.py that actually comes from CPython. I will continue to work on them, but they are not specific to sqlalchemy. Note the CI run is ~6 minutes where the CPython ones are ~3 minutes. This is expected, since PyPy's JIT does not kick in on short tests, and the base compiler is about 2x slower. ### Checklist This pull request is: - [ ] A documentation / typographical / small typing error fix - Good to go, no issue or tests are needed - [x] A short code fix - please include the issue number, and create an issue if none exists, which must include a complete example of the issue. one line code fixes without an issue and demonstration will not be accepted. - Please include: `Fixes: #` in the commit message - please include tests. one line code fixes without tests will not be accepted. - [ ] A new feature implementation - please include the issue number, and create an issue if none exists, which must include a complete example of how the feature would look. - Please include: `Fixes: #` in the commit message - please include tests. **Have a nice day!** Closes: #13276 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13276 Pull-request-sha: 00472f32f64827325f071150e8b6ecf1fbe9f22e Change-Id: Id5d4ba37cf8db2345a948f973d7b1710910359a1 (cherry picked from commit 56edb237cb652bed221a377cdc2ae2b7b835dd61) --- diff --git a/lib/sqlalchemy/dialects/sqlite/base.py b/lib/sqlalchemy/dialects/sqlite/base.py index be388a5146..11c69ef218 100644 --- a/lib/sqlalchemy/dialects/sqlite/base.py +++ b/lib/sqlalchemy/dialects/sqlite/base.py @@ -2209,7 +2209,7 @@ class SQLiteDialect(default.DefaultDialect): 14, ) - if self.dbapi.sqlite_version_info < (3, 35) or util.pypy: + if self.dbapi.sqlite_version_info < (3, 35): self.update_returning = self.delete_returning = ( self.insert_returning ) = False diff --git a/test/orm/test_utils.py b/test/orm/test_utils.py index f437a60850..41a7f113cf 100644 --- a/test/orm/test_utils.py +++ b/test/orm/test_utils.py @@ -145,7 +145,9 @@ class ContextualWarningsTest(fixtures.TestBase): "initializing objects.)" ), ): - sess.execute(select(Foo)) + result = sess.execute(select(Foo)) + result.close() + sess.close() class AliasedClassTest(fixtures.MappedTest, AssertsCompiledSQL):