Repository navigation
[18.0][FIX] queue_job_cron_jobrunner: do not use deprecated tools.ustr() - #1038
Open
robsalasco wants to merge 1 commit into
Open
robsalasco wants to merge 1 commit into
robsalasco wants to merge 1 commit into
Conversation
tools.ustr() is deprecated since Odoo 18 and emits a DeprecationWarning on every call. psycopg2 exposes pgerror as a str (or None), and for those values ustr() only returned str(value), so use str() directly. Add a test covering the PostgreSQL concurrency error branch of _process(): the job is postponed by PG_RETRY seconds with the error text as result, without deprecation warnings.
Contributor
|
Hi @ivantodorovich, |
ivantodorovich
approved these changes
Nov 25, 2026
Comment on lines
+72
to
+73
| # pgerror is already a str (or None): tools.ustr() is | ||
| # deprecated since Odoo 18 and only called str() here. |
Contributor
There was a problem hiding this comment.
Suggested change
| # pgerror is already a str (or None): tools.ustr() is | |
| # deprecated since Odoo 18 and only called str() here. |
this comment belongs to the commit message, not the code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a job raises a PostgreSQL concurrency error,
queue.job._process()builds the postpone message withtools.ustr(err.pgerror, errors="replace").ustr()is deprecated since Odoo 18 and emits aDeprecationWarningon every call, which shows up as apy.warningsWARNING in logs and test builds:Fix
Use
str(err.pgerror)instead. Behavior is unchanged: psycopg2 exposespgerroras astr(orNone), and for those valuesustr()only ever returnedstr(value). The now unusedtoolsimport is removed.Tests
New test
test_queue_job_process_concurrency_error: a job whoseperform()raises a serialization failure is postponed byPG_RETRYseconds with the error text as result, and noDeprecationWarningis emitted fromqueue_job_cron_jobrunner/models/queue_job.py. This branch of_process()had no test coverage before.-i queue_job_cron_jobrunner --test-tags /queue_job_cron_jobrunner:1 failed ... of 6 tests(the new test, with theustr()warning).0 failed, 0 error(s) of 6 tests, noWARNING/ERRORlines in the log.The same
tools.ustrcall exists on 17.0 and 19.0; this can be forward-ported once merged.