Permalink
Browse files

refs #2: with zipfile is not a thing in python 2.6

  • Loading branch information...
1 parent 09f10b2 commit 6ffb48e0f951a27516834c3074e5a7a092e2661b @jlward committed Mar 22, 2013
Showing with 6 additions and 3 deletions.
  1. +6 −3 pydocx/DocxParser.py
View
@@ -53,16 +53,19 @@ def __init__(self, path):
self._parsed = ''
self.in_list = False
- with zipfile.ZipFile(path) as f:
+ f = zipfile.ZipFile(path)
+ try:
self.document_text = f.read('word/document.xml')
try:
self.numbering_text = f.read('word/numbering.xml')
- except:
+ except zipfile.BadZipfile:
pass
try:
self.comment_text = f.read('word/comments.xml')
- except:
+ except zipfile.BadZipfile:
pass
+ finally:
+ f.close()
self.root = ElementTree.fromstring(
remove_namespaces(self.document_text),

0 comments on commit 6ffb48e

Please sign in to comment.