Skip to content

Commit a0c6090

Browse files
authored
fix: pypy problem cannot commit transaction (#3708)
* feat: test for pypy Signed-off-by: yihong0618 <zouzou0208@gmail.com> * fix: pypy failed Signed-off-by: yihong0618 <zouzou0208@gmail.com> * fix: drop test branch name in ci Signed-off-by: yihong0618 <zouzou0208@gmail.com> * fix: add news for it Signed-off-by: yihong0618 <zouzou0208@gmail.com> --------- Signed-off-by: yihong0618 <zouzou0208@gmail.com>
1 parent 324f00e commit a0c6090

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ jobs:
3939
- python-version: 3.12
4040
os: ubuntu-latest
4141
install-via: script
42+
- python-version: pypy-3.11
43+
os: ubuntu-latest
44+
install-via: pip
4245
steps:
4346
- uses: actions/checkout@v6.0.0
4447

news/3708.bugfix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Make sure cursor closing for fixing PyPy different gc mode also add PyPy in CI.

src/pdm/models/session.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import sqlite3
55
import sys
66
import threading
7+
from contextlib import closing
78
from functools import lru_cache
89
from pathlib import Path
910
from typing import TYPE_CHECKING, Any, cast
@@ -95,7 +96,8 @@ def _ensure_connection(self) -> sqlite3.Connection:
9596
self.database_path.parent.mkdir(parents=True, exist_ok=True)
9697
full_path = self.database_path.resolve()
9798
conn = sqlite3.connect(str(full_path), check_same_thread=False)
98-
conn.execute("PRAGMA journal_mode=WAL")
99+
with closing(conn.cursor()) as cursor:
100+
cursor.execute("PRAGMA foreign_keys=ON")
99101
self.connection = conn
100102
if not self._initialized:
101103
self._initialize_database()

0 commit comments

Comments
 (0)