bitbake: compress: Allow to operate on file descriptor

The code works fine if we pass a file descriptor in and we need to
do this from the siggen code so add that as a valid input.

(Bitbake rev: fc8d74b7de576005ecf67920501dc7e694880fda)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie 2021-10-13 16:11:02 +01:00
parent 5cd1fd86f4
commit d080eaa163

View File

@ -49,7 +49,7 @@ def open_wrap(
raise ValueError("Argument 'newline' not supported in binary mode")
file_mode = mode.replace("t", "")
if isinstance(filename, (str, bytes, os.PathLike)):
if isinstance(filename, (str, bytes, os.PathLike, int)):
binary_file = cls(filename, file_mode, **kwargs)
elif hasattr(filename, "read") or hasattr(filename, "write"):
binary_file = cls(None, file_mode, fileobj=filename, **kwargs)