Skip to content

Commit

Permalink
Avoid using dbm.sqlite3 (bbangert#242)
Browse files Browse the repository at this point in the history
Python 3.13 added a new dbm backend, dbm.sqlite3, as the most-
preferred choice when you do `import dbm`. This backend causes
our test suite to fail with sqlite3 threading violations. This
tweaks our dbm loading to just skip sqlite3 and try the other
possible backends in the same order as Python < 3.13 did.

Signed-off-by: Adam Williamson <[email protected]>
  • Loading branch information
AdamWill committed Jun 21, 2024
1 parent a1eaad3 commit 4fea03d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions beaker/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,17 @@
import http.cookies as http_cookies
from base64 import b64decode as _b64decode, b64encode as _b64encode

# this reproduces the default behavior of Python 3.0 to 3.12
# Python 3.13 added dbm.sqlite3 as the first choice, but it
# doesn't work for us due to threading violations:
# https://github.com/bbangert/beaker/issues/242
try:
import dbm as anydbm
import dbm.gnu as anydbm
except:
import dumbdbm as anydbm
try:
import dbm.ndbm as anydbm
except:
import dbm.dumb as anydbm

def b64decode(b):
return _b64decode(b.encode('ascii'))
Expand Down

0 comments on commit 4fea03d

Please sign in to comment.