leptonica.py: Fix exception on certain types of barcode failures
Closes #322
This commit is contained in:
@@ -17,7 +17,9 @@ Note that it is licensed under GPLv3, so scripts that ``import ocrmypdf`` and ar
|
||||
v7.4.1
|
||||
------
|
||||
|
||||
- Fix a few documentation problems.
|
||||
- Fixed a few documentation problems.
|
||||
|
||||
- Fixed an unhandled exception when attempting to mask barcodes. #322 <https://github.com/jbarlow83/OCRmyPDF/issues/322>`_
|
||||
|
||||
v7.4.0
|
||||
------
|
||||
|
||||
@@ -567,8 +567,8 @@ class Pix(LeptonicaObject):
|
||||
with _LeptonicaErrorTrap():
|
||||
pix = Pix(lept.pixConvertTo8(self._cdata, 0))
|
||||
pixa_candidates = PixArray(lept.pixExtractBarcodes(pix._cdata, 0))
|
||||
with suppress(FileNotFoundError):
|
||||
os.unlink('junkpixt.png') # leptonica may produce this
|
||||
if not pixa_candidates:
|
||||
return
|
||||
sarray = StringArray(lept.pixReadBarcodes(
|
||||
pixa_candidates._cdata,
|
||||
lept.L_BF_ANY,
|
||||
@@ -576,8 +576,12 @@ class Pix(LeptonicaObject):
|
||||
ffi.NULL,
|
||||
0
|
||||
))
|
||||
except (LeptonicaError, ValueError) as e:
|
||||
except (LeptonicaError, ValueError, IndexError) as e:
|
||||
return
|
||||
finally:
|
||||
with suppress(FileNotFoundError):
|
||||
os.unlink('junkpixt.png') # leptonica may produce this
|
||||
os.unlink('junkpixt')
|
||||
|
||||
for n, s in enumerate(sarray):
|
||||
decoded = s.decode()
|
||||
|
||||
Reference in New Issue
Block a user