Skip to content

16.0 py311 moc#112317

Closed
d-fence wants to merge 4 commits intoodoo:16.0from
odoo-dev:16.0-py311-moc
Closed

16.0 py311 moc#112317
d-fence wants to merge 4 commits intoodoo:16.0from
odoo-dev:16.0-py311-moc

Conversation

@d-fence
Copy link
Copy Markdown
Contributor

@d-fence d-fence commented Feb 9, 2023

Since the next imminent release of Debian Bookworm will come with Python 3.11 as some other distros (like Fedora 37) this PR adapts Odoo 16.0 to work with Python 3.11.

Note:
This is an excerpt from this testing branch that was made to test against the Jammy and Bookworm distributions.

pimodoo and others added 2 commits February 9, 2023 13:17
When python expression is evaluated in odoo form an action or qweb, we
are checking the opcodes generated by the evaluation of this code. We do
such a verification, because the code from actions and templates can be
written by someone having not access to the server and we don't want to
let them perform actions out of the scope of their database.

In python 3.11, some opcodes from previous versions of Python have been
renamed, grouped or sepcified. There are also new ones that have been
introduce.

In this PR, we are whitelisting the new ones that are needed by odoo to
properly work in this version of Python.
As getdefaultlocale is deprecated in 3.11 in favor of getlocale which is
available since at least 3.0.
@robodoo
Copy link
Copy Markdown
Contributor

robodoo commented Feb 9, 2023

Pull request status dashboard

@d-fence d-fence marked this pull request as ready for review February 9, 2023 13:23
@C3POdoo C3POdoo requested review from a team, Gorash and VincentSchippefilt and removed request for a team February 9, 2023 13:24
@C3POdoo C3POdoo added the RD research & development, internal work label Feb 9, 2023
Copy link
Copy Markdown
Collaborator

@xmo-odoo xmo-odoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me, only remark would be to explain more clearly what the issue is in 89abe6713a18cc1e914846dbd2a1fbd5af3152d7 because that one's not exactly clear.

Also might want to add a note to the "sampling from a set" filterwarning that it really only applies to 3.9: bpo-40325 was implemented in 3.9, bpo-42470 was only backported to 3.10, so 3.10 should not trigger the warning on false positives.

Or maybe add a version check / gate in netsvc.py directly, and only filter out the warning when running on 3.9?

@C3POdoo C3POdoo requested a review from a team February 10, 2023 09:03
@d-fence
Copy link
Copy Markdown
Contributor Author

d-fence commented Feb 10, 2023

@xmo-odoo I applied the changes as suggested. I hope the explanation in 3871beac is clearer.
Thx

@xmo-odoo
Copy link
Copy Markdown
Collaborator

I applied the changes as suggested. I hope the explanation in 3871bea is clearer. Thx

It's ok, I'd have liked an explanation as to why pkgutil doesn't find the thing it did find before, for when it's the year 2047 and we've no idea what that was about and if we still need to care.

Since python/cpython#18544, unittest mock is not able to properly find
the "odoo.tools.config".

When trying to patch the `options` dictionnary, it leads to
`AttributeError: module 'odoo.tools.config' has no attribute 'options'`

In order to have the tests
working in python <= 3.11, we have to import the config module and patch
the options in place.
Since Python 3.11, sampling from a set deprecated, the population must
be a sequence.

This commit applies the suggested fix.

Also, the filtering of the deprecation warning about sampling from set
can be disabled when the python version is not 3.9. This warning was
wrongly triggered since 3.9 because recordsets are bot a sequence and a
set.
This was fixed in python 3.10, see https://bugs.python.org/issue42470
@xmo-odoo
Copy link
Copy Markdown
Collaborator

@robodoo override=ci/security r+

@d-fence
Copy link
Copy Markdown
Contributor Author

d-fence commented Feb 10, 2023

robodoo rebase-ff r+

@robodoo
Copy link
Copy Markdown
Contributor

robodoo commented Feb 10, 2023

Merge method set to rebase and fast-forward.

@robodoo
Copy link
Copy Markdown
Contributor

robodoo commented Feb 10, 2023

I'm sorry, @d-fence: this PR is already reviewed, reviewing it again is useless.

robodoo pushed a commit that referenced this pull request Feb 10, 2023
When python expression is evaluated in odoo form an action or qweb, we
are checking the opcodes generated by the evaluation of this code. We do
such a verification, because the code from actions and templates can be
written by someone having not access to the server and we don't want to
let them perform actions out of the scope of their database.

In python 3.11, some opcodes from previous versions of Python have been
renamed, grouped or sepcified. There are also new ones that have been
introduce.

In this PR, we are whitelisting the new ones that are needed by odoo to
properly work in this version of Python.

Part-of: #112317
robodoo pushed a commit that referenced this pull request Feb 10, 2023
As getdefaultlocale is deprecated in 3.11 in favor of getlocale which is
available since at least 3.0.

Part-of: #112317
robodoo pushed a commit that referenced this pull request Feb 10, 2023
Since python/cpython#18544, unittest mock is not able to properly find
the "odoo.tools.config".

When trying to patch the `options` dictionnary, it leads to
`AttributeError: module 'odoo.tools.config' has no attribute 'options'`

In order to have the tests
working in python <= 3.11, we have to import the config module and patch
the options in place.

Part-of: #112317
@robodoo robodoo closed this in 67c7cea Feb 10, 2023
@robodoo robodoo temporarily deployed to merge February 10, 2023 15:42 Inactive
This was referenced Feb 10, 2023
@fw-bot
Copy link
Copy Markdown
Contributor

fw-bot commented Feb 14, 2023

@d-fence @xmo-odoo this pull request has forward-port PRs awaiting action (not merged or closed):
#112450

@d-fence d-fence mentioned this pull request Feb 14, 2023
@d-fence d-fence deleted the 16.0-py311-moc branch February 14, 2023 08:41
This was referenced Feb 22, 2023
StevenSermeus pushed a commit to acsone/odoo that referenced this pull request Mar 9, 2023
When python expression is evaluated in odoo form an action or qweb, we
are checking the opcodes generated by the evaluation of this code. We do
such a verification, because the code from actions and templates can be
written by someone having not access to the server and we don't want to
let them perform actions out of the scope of their database.

In python 3.11, some opcodes from previous versions of Python have been
renamed, grouped or sepcified. There are also new ones that have been
introduce.

In this PR, we are whitelisting the new ones that are needed by odoo to
properly work in this version of Python.

Part-of: odoo#112317
StevenSermeus pushed a commit to acsone/odoo that referenced this pull request Mar 9, 2023
As getdefaultlocale is deprecated in 3.11 in favor of getlocale which is
available since at least 3.0.

Part-of: odoo#112317
StevenSermeus pushed a commit to acsone/odoo that referenced this pull request Mar 9, 2023
Since python/cpython#18544, unittest mock is not able to properly find
the "odoo.tools.config".

When trying to patch the `options` dictionnary, it leads to
`AttributeError: module 'odoo.tools.config' has no attribute 'options'`

In order to have the tests
working in python <= 3.11, we have to import the config module and patch
the options in place.

Part-of: odoo#112317
StevenSermeus pushed a commit to acsone/odoo that referenced this pull request Mar 9, 2023
Since Python 3.11, sampling from a set deprecated, the population must
be a sequence.

This commit applies the suggested fix.

Also, the filtering of the deprecation warning about sampling from set
can be disabled when the python version is not 3.9. This warning was
wrongly triggered since 3.9 because recordsets are bot a sequence and a
set.
This was fixed in python 3.10, see https://bugs.python.org/issue42470

closes odoo#112317

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
rajeeshknambiar pushed a commit to unipartdigital/odoo that referenced this pull request Aug 25, 2023
When python expression is evaluated in odoo form an action or qweb, we
are checking the opcodes generated by the evaluation of this code. We do
such a verification, because the code from actions and templates can be
written by someone having not access to the server and we don't want to
let them perform actions out of the scope of their database.

In python 3.11, some opcodes from previous versions of Python have been
renamed, grouped or sepcified. There are also new ones that have been
introduce.

In this PR, we are whitelisting the new ones that are needed by odoo to
properly work in this version of Python.

Part-of: odoo#112317
kdwyer pushed a commit to unipartdigital/odoo that referenced this pull request Oct 28, 2025
When python expression is evaluated in odoo form an action or qweb, we
are checking the opcodes generated by the evaluation of this code. We do
such a verification, because the code from actions and templates can be
written by someone having not access to the server and we don't want to
let them perform actions out of the scope of their database.

In python 3.11, some opcodes from previous versions of Python have been
renamed, grouped or sepcified. There are also new ones that have been
introduce.

In this PR, we are whitelisting the new ones that are needed by odoo to
properly work in this version of Python.

Part-of: odoo#112317
kdwyer pushed a commit to unipartdigital/odoo that referenced this pull request Nov 3, 2025
When python expression is evaluated in odoo form an action or qweb, we
are checking the opcodes generated by the evaluation of this code. We do
such a verification, because the code from actions and templates can be
written by someone having not access to the server and we don't want to
let them perform actions out of the scope of their database.

In python 3.11, some opcodes from previous versions of Python have been
renamed, grouped or sepcified. There are also new ones that have been
introduce.

In this PR, we are whitelisting the new ones that are needed by odoo to
properly work in this version of Python.

Part-of: odoo#112317
kdwyer pushed a commit to unipartdigital/odoo that referenced this pull request Nov 17, 2025
When python expression is evaluated in odoo form an action or qweb, we
are checking the opcodes generated by the evaluation of this code. We do
such a verification, because the code from actions and templates can be
written by someone having not access to the server and we don't want to
let them perform actions out of the scope of their database.

In python 3.11, some opcodes from previous versions of Python have been
renamed, grouped or sepcified. There are also new ones that have been
introduce.

In this PR, we are whitelisting the new ones that are needed by odoo to
properly work in this version of Python.

Part-of: odoo#112317
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RD research & development, internal work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants