Skip to content
This repository has been archived by the owner on Feb 25, 2018. It is now read-only.

Commit

Permalink
fix mode-checking error in Decrypt() wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
rfk committed Jun 7, 2009
1 parent 6ca9039 commit c39aee0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions filelike/wrappers/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ def __init__(self,fileobj,cipher,mode=None):
is the cipher object to be used. Other arguments are passed through
to FileWrapper.__init__
"""
if mode is None:
try:
mode = fileobj.mode
except AttributeError:
mode = "r+"
self._cipher = cipher
if cipher.mode == 1:
# MODE_ECB is a bytewise translation
Expand All @@ -84,11 +89,6 @@ def reset():
myFileObj = FixedBlockSize(myFileObj,cipher.block_size,mode=mode)
# To allow writes with seeks, we need to buffer.
# TODO: find a way around this.
if mode is None:
try:
mode = fileobj.mode
except AttributeError:
mode = "r+"
if self._check_mode("rw",mode):
myFileObj = FlushableBuffer(myFileObj,mode=mode)
elif self._check_mode("w",mode) and "-" not in mode:
Expand Down

0 comments on commit c39aee0

Please sign in to comment.