Title: AttributeError on opening ZipFile
Type: Stage: resolved
Components: Versions: Python 3.6
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Jacob B2, vstinner
Priority: normal Keywords:

Created on 2017-04-28 01:15 by Jacob B2, last changed 2017-04-28 01:20 by vstinner. This issue is now closed.

Messages (2)
msg292494 - (view) Author: Jacob B (Jacob B2) Date: 2017-04-28 01:15
The error occurs when I attempt to run the following code:

from urllib.request import urlretrieve
from os import path
from zipfile import ZipFile

download_url = ""

def setup_program():
    zip_name = urlretrieve(download_url)

    zip_file = ZipFile(zip_name, "r")

setup_program()  # REMOVE after test

I get the following traceback:

$ python
Traceback (most recent call last):
  File "", line 15, in <module>
  File "", line 11, in setup_program
    zip_file = ZipFile(zip_name, "r")
  File "C:\Python36\lib\", line 1100, in __init__
  File "C:\Python36\lib\", line 1163, in _RealGetContents
    endrec = _EndRecData(fp)
  File "C:\Python36\lib\", line 241, in _EndRecData, 2)
AttributeError: 'tuple' object has no attribute 'seek'
msg292495 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-04-28 01:20
urlretrieve() returns (filename, file-like object). It's a bug in your code, not in Python itself ;-)
Date User Action Args
2017-04-28 01:20:15vstinnersetstatus: open -> closed

nosy: + vstinner
messages: + msg292495

resolution: not a bug
stage: resolved
2017-04-28 01:15:03Jacob B2create