aboutsummaryrefslogtreecommitdiff
path: root/mammoth/docx/__init__.py
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2015-08-20 20:34:34 +0100
committerMichael Williamson <mike@zwobble.org>2015-08-20 20:35:14 +0100
commit1c14ed25d75caf3228a92d8f7292bf0bf040653b (patch)
treeaa36f672e71baebf7b870a8be609d1990dd450e3 /mammoth/docx/__init__.py
parent06ac97ac681accc691affdfafec97ded54faba23 (diff)
Fix: cannot read file objects with name attribute
Diffstat (limited to 'mammoth/docx/__init__.py')
-rw-r--r--mammoth/docx/__init__.py4
1 files changed, 2 insertions, 2 deletions
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