From 1c14ed25d75caf3228a92d8f7292bf0bf040653b Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Thu, 20 Aug 2015 20:34:34 +0100 Subject: Fix: cannot read file objects with name attribute --- mammoth/docx/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mammoth/docx/__init__.py') diff --git a/mammoth/docx/__init__.py b/mammoth/docx/__init__.py index 1ca8cb0..c8f4e6e 100644 --- a/mammoth/docx/__init__.py +++ b/mammoth/docx/__init__.py @@ -28,7 +28,7 @@ _namespaces = [ def read(fileobj): zip_file = zipfile.ZipFile(fileobj) - body_readers = _body_readers(getattr(fileobj, "name"), zip_file) + body_readers = _body_readers(getattr(fileobj, "name", None), zip_file) return _read_notes(zip_file, body_readers).bind(lambda notes: _read_document(zip_file, body_readers, notes)) @@ -79,7 +79,7 @@ def _body_readers(document_path, zip_file): relationships=relationships, styles=styles, docx_file=zip_file, - files=Files(os.path.dirname(document_path)), + files=Files(None if document_path is None else os.path.dirname(document_path)), ) return for_name -- cgit v1.2.3