Description: Python module uno.py overrides import. And that overwritten function fails to import some modules. Cairosvg is one example. Workaround is to import carirosvg before libreoffice ones. It looks like sys.modules can contain entry for module with value None. Maybe simple check against that would work. Or maybe there is needed other approach with Python 3.8? Steps to Reproduce: Simle code like: import uno import cairosvg After failure it looks like sys.modules["_elementtree"] is None. (Key exists in that dict, but with None as value) Actual Results: Traceback (most recent call last): File "test.py", line 2, in <module> import cairosvg File "/usr/lib64/python3.8/site-packages/uno.py", line 359, in _uno_import return _builtin_import(name, *optargs, **kwargs) File "/usr/lib/python3.8/site-packages/cairosvg/__init__.py", line 42, in <module> from . import surface # noqa isort:skip File "/usr/lib64/python3.8/site-packages/uno.py", line 359, in _uno_import return _builtin_import(name, *optargs, **kwargs) File "/usr/lib/python3.8/site-packages/cairosvg/surface.py", line 28, in <module> from .defs import ( File "/usr/lib64/python3.8/site-packages/uno.py", line 359, in _uno_import return _builtin_import(name, *optargs, **kwargs) File "/usr/lib/python3.8/site-packages/cairosvg/defs.py", line 24, in <module> from .bounding_box import calculate_bounding_box, is_non_empty_bounding_box File "/usr/lib64/python3.8/site-packages/uno.py", line 359, in _uno_import return _builtin_import(name, *optargs, **kwargs) File "/usr/lib/python3.8/site-packages/cairosvg/bounding_box.py", line 28, in <module> from .parser import Tree File "/usr/lib64/python3.8/site-packages/uno.py", line 359, in _uno_import return _builtin_import(name, *optargs, **kwargs) File "/usr/lib/python3.8/site-packages/cairosvg/parser.py", line 28, in <module> from defusedxml import ElementTree File "/usr/lib64/python3.8/site-packages/uno.py", line 359, in _uno_import return _builtin_import(name, *optargs, **kwargs) File "/usr/lib/python3.8/site-packages/defusedxml/ElementTree.py", line 63, in <module> _XMLParser, _iterparse, ParseError = _get_py3_cls() File "/usr/lib/python3.8/site-packages/defusedxml/ElementTree.py", line 48, in _get_py3_cls pure_pymod = importlib.import_module(pymodname) File "/usr/lib64/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/usr/lib64/python3.8/xml/etree/ElementTree.py", line 2053, in <module> from _elementtree import * File "/usr/lib64/python3.8/site-packages/uno.py", line 383, in _uno_import d = mod.__dict__ AttributeError: 'NoneType' object has no attribute '__dict__' Expected Results: Proper import of cairosvg, with modules it imports. Workaround is to use: import cairosvg import uno Reproducible: Always User Profile Reset: Yes Additional Info: Python 3.8.2 libreoffice-pyuno-6.4.3.2-1.fc32.x86_64
I can reproduce this with the following steps:
I can reproduce this bug with the following steps: 1. Install cairosvg with pip. 2. start ipython interactive console: > $ PYTHONPATH=/home/suokunlong/build/lo/master/instdir/program/ ipython3 3. Import cairosvg before importing uno: > In [1]: import cairosvg > In [2]: import uno > In [4]: sys.modules["_elementtree"] > Out[4]: <module '_elementtree' from '/usr/lib64/python3.8/lib-dynload/_elementtree.cpython-38-x86_64-linux-gnu.so'> 4. Import cairosvg after importing uno: > In [1]: import uno > In [2]: import cairosvg > AttributeError: 'NoneType' object has no attribute '__dict__' > In [3]: import sys > In [4]: sys.modules["_elementtree"] > (None) Fedora 32, master build as of today.
Niko Fink committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/1052ec9cff72e2810fdb934a85ab500d3b4ace35 tdf#133123: fix crash when importing defusedxml.ElementTree after pyuno It will be available in 7.5.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Niko Fink committed a patch related to this issue. It has been pushed to "libreoffice-7-4": https://git.libreoffice.org/core/commit/cd048ca7ab61718586f7ef5b48dccbb6bd38299c tdf#133123: fix crash when importing defusedxml.ElementTree after pyuno It will be available in 7.4.1. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
the Patch committed by @Niko Fink works also for: Version: 7.0.4.2 Build ID: 00(Build:2) CPU threads: 4; OS: Linux 5.15; UI render: default; VCL: gtk3 Locale: de-DE (de_DE.UTF-8); UI: de-DE Raspbian package version: 1:7.0.4-4+rpi1+deb11u3 Calc: threaded