Fix trivial PyPy failures

<!-- 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: 00472f32f6

Change-Id: Id5d4ba37cf8db2345a948f973d7b1710910359a1
This commit is contained in:
mattip
2026-05-20 13:47:17 -04:00
committed by sqla-tester
parent 5594b60d4a
commit 56edb237cb
2 changed files with 4 additions and 2 deletions
+1 -1
View 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
+3 -1
View 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):