From 23405f733cb76a33d189cfcb2b9fc93cdf088a12 Mon Sep 17 00:00:00 2001 From: Daniel Quinn Date: Sat, 28 Apr 2018 12:17:29 +0100 Subject: [PATCH] Use `str()` instead of `.message` for exception In a case where a `KeyError` is raised, the exception is caught, but then it tried to reference `ex.message`, which doesn't exist for KeyErrors in modern versions of Python. Using `str(ex)` should deliver the same result. --- src/pyocr/tesseract.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pyocr/tesseract.py b/src/pyocr/tesseract.py index 49afb0b..22cc48d 100755 --- a/src/pyocr/tesseract.py +++ b/src/pyocr/tesseract.py @@ -221,7 +221,7 @@ def detect_orientation(image, lang=None): } except Exception as ex: raise TesseractError(-1, "No script found in image (%s - %s)" - % (ex.message, original_output)) + % (str(ex), original_output)) def get_name():