xml2rfc icon indicating copy to clipboard operation
xml2rfc copied to clipboard

xml2rfc should not break on weasyprint if that isn't actually needed

Open cabo opened this issue 2 years ago • 4 comments

Describe the issue

After something randomly changed in my Python environment:

Traceback (most recent call last):
  File "/Users/cabo/bin/xml2rfc", line 5, in <module>
    from xml2rfc.run import main
  File "/Users/cabo/lib/python3.10/site-packages/xml2rfc/__init__.py", line 38, in <module>
    from weasyprint.text.ffi import pango
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1002, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 945, in _find_spec
  File "<frozen importlib._bootstrap_external>", line 1439, in find_spec
  File "<frozen importlib._bootstrap_external>", line 1405, in _get_spec
  File "<frozen importlib._bootstrap_external>", line 1255, in __iter__
  File "<frozen importlib._bootstrap_external>", line 1242, in _recalculate
  File "<frozen importlib._bootstrap_external>", line 1238, in _get_parent_path
KeyError: 'weasyprint'

I did not try to actually generate PDF, so xml2rfc should not depend on that loading properly.

Code of Conduct

cabo avatar Feb 01 '23 15:02 cabo

If you still have this environment, can you provide the Python version, xml2rfc version and the WeasyPrint version? Because I could not recreate this error with different WeasyPrint / xml2rfc combinations.

xml2rfc already checks for ImportError, OSError and AttributeError. Maybe we can add KeyError to the list or swallow all Exceptions.

kesara avatar Apr 11 '23 05:04 kesara

The error occurred when there was no working WeasyPrint installed (there may have been remnants of one). I have since fixed the problem that prevented installing WeasyPrint on that machine, so I don't have an easy way to reproduce.

cabo avatar Apr 11 '23 06:04 cabo

Python version must have been python3.10 (see messages above).

cabo avatar Apr 11 '23 06:04 cabo

Thank you. This looks like an error occurred due to a Python environment configuration issue. There's already logic guarding against not having WeasyPrint or an older version of WeasyPrint. So xml2rfc will not break if WeasyPrint is not installed.

kesara avatar Apr 12 '23 06:04 kesara