Skip to content

ZipFile error #4

@vidar

Description

@vidar

I am getting an error on python2.6 on the following script that works fine in python2.7, is this something that is fixable?

I can mitigate it with the fix in https://github.com/vidar/python-pptx/commit/3c87a0fd311c4f22a428877719638409cf4edd97 but that is obviously not a long term approach.

from pptx import Presentation

if __name__ == '__main__':
    prs = Presentation()
    slidelayout = prs.slidemasters[0].slidelayouts[5]
    img_slide = prs.slides.add_slide(slidelayout)
    prs.save('test.pptx')

gives the following stacktrace:

(DM)vidar@berzerker:~$ python a.py 
Traceback (most recent call last):
  File "a.py", line 7, in <module>
    prs.save('test.pptx')
  File "/Users/vidar/.virtualenvs/DM/src/pptx/pptx/api.py", line 64, in save
    return self.__package.save(path)
  File "/Users/vidar/.virtualenvs/DM/src/pptx/pptx/presentation.py", line 125, in save
    pkgng_pkg.save(path)
  File "/Users/vidar/.virtualenvs/DM/src/pptx/pptx/packaging.py", line 134, in save
    zipfs.write_element(cti.element, '/[Content_Types].xml')
  File "/Users/vidar/.virtualenvs/DM/src/pptx/pptx/packaging.py", line 849, in write_element
    if itemURI in self:
  File "/Users/vidar/.virtualenvs/DM/src/pptx/pptx/packaging.py", line 687, in __contains__
    return itemURI in self.itemURIs
  File "/Users/vidar/.virtualenvs/DM/src/pptx/pptx/packaging.py", line 811, in itemURIs
    zip = zipfile.ZipFile(self.path)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/zipfile.py", line 696, in __init__
    self._GetContents()
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/zipfile.py", line 716, in _GetContents
    self._RealGetContents()
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/zipfile.py", line 728, in _RealGetContents
    raise BadZipfile, "File is not a zip file"
zipfile.BadZipfile: File is not a zip file

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions