Skip to content

Commit 0c68c4e

Browse files
odonyd-fence
authored andcommitted
[FIX] _vendor: fix compatibility with werkzeug 2.0+
As of werkzeug 2.0, the `posixemulation` compatibility layer for atomic rename operations is abandoned[1]. In the mean time an atomic, cross-platform file renaming function was introduced in the stdlib, as of Python 3.3: `os.replace()`. By using `os.replace()` instead of `posixemulation.rename()`, we can ensure compatibility with versions 0.x, 1.x and 2.x of werkzeug. We've always required Python 3.5+ since the P3 support, so `os.replace()` is always available. This is a follow-up of the work for supporting werkzeug 1.x [2] References: [1] pallets/werkzeug#1790 [2] vendoring of werkzeug.sessions: #45931 Part-of: #88803
1 parent a5f24b0 commit 0c68c4e

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

odoo/tools/_vendor/sessions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@
1919
import re
2020
import tempfile
2121
from hashlib import sha1
22-
from os import path
22+
from os import path, replace as rename
2323
from pickle import dump
2424
from pickle import HIGHEST_PROTOCOL
2525
from pickle import load
2626
from time import time
2727

2828
from werkzeug.datastructures import CallbackDict
29-
from werkzeug.posixemulation import rename
3029

3130
_sha1_re = re.compile(r"^[a-f0-9]{40}$")
3231

0 commit comments

Comments
 (0)