Fix #2162 add stream check.
parent
00e94d6b34
commit
d861b36305
13
gnupg.py
13
gnupg.py
|
@ -116,12 +116,12 @@ def _copy_data(instream, outstream):
|
||||||
Copy data from one stream to another.
|
Copy data from one stream to another.
|
||||||
|
|
||||||
:param instream: A file descriptor to read from.
|
:param instream: A file descriptor to read from.
|
||||||
:param outstream: A file descriptor to write to.
|
:param outstream: The file descriptor of a tmpfile to write to.
|
||||||
"""
|
"""
|
||||||
sent = 0
|
sent = 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
assert isinstance(instream, BytesIO), "instream is not a file"
|
assert _is_stream(instream), "instream is not a stream"
|
||||||
assert isinstance(outstream, file), "outstream is not a file"
|
assert isinstance(outstream, file), "outstream is not a file"
|
||||||
except AssertionError as ae:
|
except AssertionError as ae:
|
||||||
logger.exception(ae)
|
logger.exception(ae)
|
||||||
|
@ -469,6 +469,15 @@ def _is_file(input):
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def _is_stream(input):
|
||||||
|
"""Check that the input is a byte stream.
|
||||||
|
|
||||||
|
:param input: An object provided for reading from or writing to
|
||||||
|
:rtype: C{bool}
|
||||||
|
:returns: True if :param:`input` is a stream, False if otherwise.
|
||||||
|
"""
|
||||||
|
return isinstance(input, BytesIO)
|
||||||
|
|
||||||
def _is_sequence(instance):
|
def _is_sequence(instance):
|
||||||
return isinstance(instance,list) or isinstance(instance,tuple)
|
return isinstance(instance,list) or isinstance(instance,tuple)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue