diff --git a/src/PIL/ImageMath.py b/src/PIL/ImageMath.py index d985877a6..68247c290 100644 --- a/src/PIL/ImageMath.py +++ b/src/PIL/ImageMath.py @@ -28,7 +28,7 @@ VERBOSE = 0 def _isconstant(v): - return isinstance(v, int) or isinstance(v, float) + return isinstance(v, (int, float)) class _Operand(object): diff --git a/src/PIL/PdfParser.py b/src/PIL/PdfParser.py index eca550416..8f90b668d 100644 --- a/src/PIL/PdfParser.py +++ b/src/PIL/PdfParser.py @@ -356,8 +356,7 @@ def pdf_repr(x): return b"false" elif x is None: return b"null" - elif (isinstance(x, PdfName) or isinstance(x, PdfDict) or - isinstance(x, PdfArray) or isinstance(x, PdfBinary)): + elif isinstance(x, (PdfName, PdfDict, PdfArray, PdfBinary)): return bytes(x) elif isinstance(x, int): return str(x).encode("us-ascii")