SystemError: returned a result with an error set (original) (raw)

Running this script

import fitz print(fitz.doc) doc = fitz.open('2-p1.pdf') for page in doc: allSpans = page.get_texttrace() print(f"{page.number}, # of spans={len(allSpans)}")

on some pdf file, for example, 2-p1.pdf
will cause

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcb in position 0: invalid continuation byte

The above exception was the direct cause of the following exception:

SystemError: <class 'UnicodeDecodeError'> returned a result with an error set

<same messages repeats many times>

  File "D:\Program Files\Python\Python37\lib\site-packages\fitz\fitz.py", line 6278, in get_texttrace
    val = _fitz.Page_get_texttrace(self)
SystemError: <built-in function Page_get_texttrace> returned a result with an error set

My system

PyMuPDF 1.21.0: Python bindings for the MuPDF 1.21.0 library.
Version date: 2022-11-08 00:00:01.
Built for Python 3.7 on win32 (64-bit).

I tried also 1.19.6 and 1.20.2. All give this same error.