Thursday, September 19, 2019
1 change · master
Code cleanup and technical improvements
Odoo's mail-related features now use Python's newer email tools, reducing reliance on older components that are being phased out. This helps keep outgoing messages, mailing features, surveys, and related tests compatible with future Python versions without changing the expected user experience.
Original PR description
PEP 594 is depreciating some modules from the python standard library. Among them `email.message.Message` old email API and related modules, `imp` old import logic and the not commonly used `cgitb`…
PEP 594 is depreciating some modules from the python standard library. Among them `email.message.Message` old email API and related modules, `imp` old import logic and the not commonly used `cgitb` exception pretty printer. The legacy `email.message.Message` API has been replaced by `email.message.EmailMessage` API, the later supports automatic header value conversion out of the box which simplify how emails are generated. The `email.utils.formataddr` function is commonly used accros the code base to generate `John Doe <johndoe@example.com>` like strings. As the function has been depreciated too, it has been re-implemented but only to support utf-8 and base64 (other mail supported encoding are not used within the codebase). The `imp` module is used twice, first time to locate and load addons, the second to import handmade modules. The first has been replaced by `importlib.machinery.PathFinder`, the second by `types.ModuleName`. The `cgitb` is only used in order to ease the debugging in internal tools related to the documentation, as their are still in use, the module has been packaged as part of our codebase.