diff --git a/smart_open/smart_open_lib.py b/smart_open/smart_open_lib.py index 23dd93cb..eed17d9f 100644 --- a/smart_open/smart_open_lib.py +++ b/smart_open/smart_open_lib.py @@ -226,7 +226,7 @@ def open( binary, binary_mode, compression, - filename=uri, + filename=getattr(binary, "name", uri), ) if 'b' not in mode or explicit_encoding is not None: