]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fix trivial PyPy failures
authormattip <matti.picus@gmail.com>
Wed, 20 May 2026 17:47:17 +0000 (13:47 -0400)
committersqla-tester <sqla-tester@sqlalchemy.org>
Wed, 20 May 2026 17:47:17 +0000 (13:47 -0400)
<!-- Provide a general summary of your proposed changes in the Title field above -->

### 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
<!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once)

-->

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: #<issue number>` 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: #<issue number>` 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

lib/sqlalchemy/dialects/sqlite/base.py
test/orm/test_utils.py

index a1c4cc8d355004ea587b0465a749710ed834984a..e8e30b4cff07f68842f408199dc150e3f18bff44 100644 (file)
@@ -2222,7 +2222,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
index f437a608504a5dd762d0bddd257f4a45edc2b7e5..41a7f113cf24ce2a8bd3a06ff2e6f186f23e03ca 100644 (file)
@@ -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):