xhtml2pdf broken in python 3.8 - AttributeError: module 'cgi' has no attribute 'escape'
sipposip opened this issue · 0 comments
sipposip commented
When using the CLI with python 3.8, the following error occurs:
Traceback (most recent call last):
File "c:\users\sscher\miniconda3\envs\ai-certification\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\sscher\miniconda3\envs\ai-certification\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\sscher\Miniconda3\envs\ai-certification\Scripts\aequitas-report.exe\__main__.py", line 7, in <module>
File "c:\users\sscher\miniconda3\envs\ai-certification\lib\site-packages\aequitas_cli\aequitas_audit.py", line 235, in main
push_topdf(args.input_file, report)
File "c:\users\sscher\miniconda3\envs\ai-certification\lib\site-packages\aequitas_cli\utils\io.py", line 97, in push_topdf
pisaStatus = pisa.CreatePDF(report, dest=result_pdf)
File "c:\users\sscher\miniconda3\envs\ai-certification\lib\site-packages\xhtml2pdf\document.py", line 136, in pisaDocument
doc.build(context.story)
File "c:\users\sscher\miniconda3\envs\ai-certification\lib\site-packages\reportlab\platypus\doctemplate.py", line 1080, in build
self.handle_flowable(flowables)
File "c:\users\sscher\miniconda3\envs\ai-certification\lib\site-packages\reportlab\platypus\doctemplate.py", line 932, in handle_flowable
self.afterFlowable(f)
File "c:\users\sscher\miniconda3\envs\ai-certification\lib\site-packages\xhtml2pdf\xhtml2pdf_reportlab.py", line 122, in afterFlowable
cgi.escape(copy.deepcopy(flowable.text), 1),
AttributeError: module 'cgi' has no attribute 'escape'
It is due to a problem in xhtml2pdf which uses cgi.escape, which has been removed in python 3.8. This is a known issue in xthml2pdf which has not yet been fixed (xhtml2pdf/xhtml2pdf#501)
workaround solution: downgrade to python 3.7