Skip to content

Commit 23da9c3

Browse files
authored
Merge pull request #386 from acsone/18.0-fix-deprecated_ustr-mle
[FIX] logged_query: deprecation warning for tools.ustr for version >= 18
2 parents bded6d6 + acfb85d commit 23da9c3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

openupgradelib/openupgrade.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ def do_raise(error):
127127
else:
128128
api = False
129129

130+
if version_info[0] < 18:
131+
decode = tools.ustr
132+
else:
133+
decode = lambda s: s.decode("utf-8", errors="strict")
134+
130135
# Setting the target version as an environment variable allows OpenUpgrade
131136
# to skip methods that are called in every version but really only need to
132137
# run in the target version. Make the target version available to OpenUpgrade
@@ -1721,9 +1726,9 @@ def logged_query(cr, query, args=None, skip_no_result=False):
17211726
duration = datetime.now() - start
17221727
if log_msg:
17231728
try:
1724-
full_query = tools.ustr(cr._obj.query)
1729+
full_query = decode(cr._obj.query)
17251730
except AttributeError:
1726-
full_query = tools.ustr(cr.mogrify(query, args))
1731+
full_query = decode(cr.mogrify(query, args))
17271732
logger.log(
17281733
log_level,
17291734
log_msg,

0 commit comments

Comments
 (0)