From 60da129d4bfdb05e17108f25110a9fbdfe4f4105 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 3 Apr 2021 21:42:14 +1100 Subject: [PATCH] Replaced register_open lambdas with _accept method for consistency --- src/PIL/BlpImagePlugin.py | 8 +++++--- src/PIL/IcnsImagePlugin.py | 6 +++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/PIL/BlpImagePlugin.py b/src/PIL/BlpImagePlugin.py index e07474621..7b78597b4 100644 --- a/src/PIL/BlpImagePlugin.py +++ b/src/PIL/BlpImagePlugin.py @@ -417,9 +417,11 @@ class BLP2Decoder(_BLPBaseDecoder): self.set_as_raw(bytes(data)) -Image.register_open( - BlpImageFile.format, BlpImageFile, lambda p: p[:4] in (b"BLP1", b"BLP2") -) +def _accept(prefix): + return prefix[:4] in (b"BLP1", b"BLP2") + + +Image.register_open(BlpImageFile.format, BlpImageFile, _accept) Image.register_extension(BlpImageFile.format, ".blp") Image.register_decoder("BLP1", BLP1Decoder) diff --git a/src/PIL/IcnsImagePlugin.py b/src/PIL/IcnsImagePlugin.py index ca6a0adad..a38f2fc5c 100644 --- a/src/PIL/IcnsImagePlugin.py +++ b/src/PIL/IcnsImagePlugin.py @@ -359,7 +359,11 @@ def _save(im, fp, filename): fp.write(f.read()) -Image.register_open(IcnsImageFile.format, IcnsImageFile, lambda x: x[:4] == b"icns") +def _accept(prefix): + return prefix[:4] == b"icns" + + +Image.register_open(IcnsImageFile.format, IcnsImageFile, _accept) Image.register_extension(IcnsImageFile.format, ".icns") if sys.platform == "darwin":