[issue10367] "python setup.py sdist upload --show-response" can fail with "UnboundLocalError: local variable 'result' referenced before assignment"

Priscila Manhaes report at bugs.python.org
Sat Nov 20 18:52:58 CET 2010

Priscila Manhaes <pmnhaes at gmail.com> added the comment:

Well, I fixed the problem moving the "if" that instances "result" even though it getting HTTPError into the "try".

        # send the data
            result = urlopen(request)
            status = result.getcode()
            reason = result.msg
            if self.show_response:
                self.announce('-'*75, result.read(), '-'*75)
        except socket.error, e:
            self.announce(str(e), log.ERROR)
        except HTTPError, e:
            status = e.code
            reason = e.msg

        if status == 200:
            self.announce('Server response (%s): %s' % (status, reason),
            self.announce('Upload failed (%s): %s' % (status, reason),


So now it explains the real error:

python setup.py sdist upload
running sdist
running check
warning: sdist: manifest template 'MANIFEST.in' does not exist (using default file list)

writing manifest file 'MANIFEST'
creating Python-2.7
creating Python-2.7/Lib
creating Python-2.7/Tools
creating Python-2.7/Tools/scripts
making hard links in Python-2.7...
hard linking README -> Python-2.7
'_struct.c' not a regular file -- skipping
hard linking setup.py -> Python-2.7
hard linking Lib/smtpd.py -> Python-2.7/Lib
hard linking Tools/scripts/2to3 -> Python-2.7/Tools/scripts
hard linking Tools/scripts/idle -> Python-2.7/Tools/scripts
hard linking Tools/scripts/pydoc -> Python-2.7/Tools/scripts
Creating tar archive
removing 'Python-2.7' (and everything under it)
running upload
Submitting dist/Python-2.7.tar.gz to http://pypi.python.org/pypi
Upload failed (401): Unauthorized


Is this ok?

nosy: +Priscila.Manhaes

Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list