Skip to content

Commit

Permalink
Fix mode for case with updating file (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
menshikh-iv committed Nov 30, 2017
1 parent b512873 commit 6f83b85
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions smart_open/smart_open_lib.py
Expand Up @@ -617,7 +617,7 @@ def encoding_wrapper(fileobj, mode, encoding=None):
# smart_open(filename, encoding='utf-8') would return a byte stream
# without our assumption, because the default mode is rb.
#
if mode in ('rb', 'wb', 'ab') and encoding is None:
if 'b' in mode and encoding is None:
return fileobj

if encoding is None:
Expand Down Expand Up @@ -651,7 +651,7 @@ def file_smart_open(fname, mode='rb', encoding=None):
# filename ---------------> bytes -------------> bytes ---------> text
# raw_fobj decompressed_fobj decoded_fobj
#
try:
try: # TODO need to fix this place (for cases with r+ and so on)
raw_mode = {'r': 'rb', 'w': 'wb', 'a': 'ab'}[mode]
except KeyError:
raw_mode = mode
Expand Down

0 comments on commit 6f83b85

Please sign in to comment.