From 959059fb5e7e031d96da693455e6f969fb3d0c7b Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Tue, 29 Mar 2022 10:14:40 +0000 Subject: [PATCH] [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] https://github.com/pallets/werkzeug/pull/1790 [2] vendoring of werkzeug.sessions: odoo/odoo#45931 Part-of: odoo/odoo#91927 --- odoo/tools/_vendor/sessions.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/odoo/tools/_vendor/sessions.py b/odoo/tools/_vendor/sessions.py index e64a8865e21..5bdbc818e99 100644 --- a/odoo/tools/_vendor/sessions.py +++ b/odoo/tools/_vendor/sessions.py @@ -20,14 +20,13 @@ import os import re import tempfile from hashlib import sha1 -from os import path +from os import path, replace as rename from pickle import dump from pickle import HIGHEST_PROTOCOL from pickle import load from time import time from werkzeug.datastructures import CallbackDict -from werkzeug.posixemulation import rename _logger = logging.getLogger(__name__) _sha1_re = re.compile(r"^[a-f0-9]{40}$")