CodecRegistry.decode should not explicitly open files.
@@ -193,17 +193,6 @@ class CodecRegistry:
Any decoders that match the file extension will be tried first. If no
decoders match the extension, all decoders will then be tried in order.
"""
-
- if not file:
- file = open(filename, 'rb')
- opened_file = file
- else:
- opened_file = None
-
- if not hasattr(file, 'seek'):
- file = io.BytesIO(file.read())
-
- try:
first_exception = None
for decoder in self.get_decoders(filename):
@@ -224,10 +213,6 @@ class CodecRegistry:
raise DecodeException(f"No decoders available for this file type: {filename}")
raise first_exception
- finally:
- if opened_file:
- opened_file.close()
-
def encode(self, media, filename, file=None, **kwargs):
"""Attempt to encode a pyglet object to a specified format. All registered
encoders that advertise support for the specific file extension will be tried.
