Skip to content

Commit

Permalink
CPT-268 Upgrade to Python 3.9 (#39)
Browse files Browse the repository at this point in the history
* CPT-268 Upgrade to Python 3.9

* CPT-268 Use pyenv 2.4.22

* CPT-268 Keep the old behavior of getaddresses by with strict=False
  • Loading branch information
borna-ng authored Dec 10, 2024
1 parent 2a38128 commit e1ca390
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.8.10
3.9.21
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ ENV PYENV_ROOT="/.pyenv"
ENV PATH="${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:${PATH}"
COPY .python-version .
RUN PYTHON_VERSION="$(cat .python-version)" \
&& git clone --depth 1 -b v2.4.1 https://github.com/pyenv/pyenv.git "${PYENV_ROOT}" \
&& git clone --depth 1 -b v2.4.22 https://github.com/pyenv/pyenv.git "${PYENV_ROOT}" \
&& pyenv install --verbose ${PYTHON_VERSION} \
&& pyenv global ${PYTHON_VERSION} \
&& rm .python-version
Expand Down
10 changes: 10 additions & 0 deletions odoo/tools/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import base64
import collections
import functools
import logging
from lxml.html import clean
import random
Expand All @@ -11,6 +12,7 @@
import threading
import time

import email.utils
from email.utils import getaddresses
from lxml import etree
from werkzeug import urls
Expand All @@ -22,6 +24,14 @@

_logger = logging.getLogger(__name__)

# JobRad: Upgrade to Python 3.9
# Keep the old behavior of getaddresses by specifying strict=False:
# https://docs.python.org/3.9/whatsnew/3.9.html#email
# Note that this is not needed from Odoo 15 onwards:
# https://github.com/jobrad-gmbh/odoo/blob/d7c0516e8c5fdda9661a74099a4085374595f758/odoo/tools/mail.py#L29
if getattr(email.utils, 'supports_strict_parsing', False):
getaddresses = functools.partial(getaddresses, strict=False)

#----------------------------------------------------------
# HTML Sanitizer
#----------------------------------------------------------
Expand Down

0 comments on commit e1ca390

Please sign in to comment.