This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jcea
Recipients jcea
Date 2010-11-08.21:36:49
SpamBayes Score 1.5325613e-10
Marked as misclassified No
Message-id <>
Uploading a new release of one of my libraries to PYPI I got this error:

Submitting dist/bsddb3-5.1.1.tar.gz to
Upload failed (400): A file named "bsddb3-5.1.1.tar.gz" already exists for  bsddb3-5.1.1. To fix problems with that file you should create a new release.
Traceback (most recent call last):
  File "", line 5, in <module>
    import setup2
  File "/home/pybsddb/", line 415, in <module>
    'Programming Language :: Python :: 3.2',
  File "/usr/local/lib/python2.7/distutils/", line 152, in setup
  File "/usr/local/lib/python2.7/distutils/", line 953, in run_commands
  File "/usr/local/lib/python2.7/distutils/", line 972, in run_command
  File "/usr/local/lib/python2.7/distutils/command/", line 60, in run
    self.upload_file(command, pyversion, filename)
  File "/usr/local/lib/python2.7/distutils/command/", line 189, in upload_file
    self.announce('-'*75,, '-'*75)
UnboundLocalError: local variable 'result' referenced before assignment

Checking the code, I see this:

        # send the data
            result = urlopen(request)
            status = result.getcode()
            reason = result.msg
        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),
        if self.show_response:
            self.announce('-'*75,, '-'*75)

Here, if we selected "show_response" *AND* some error happens, "result" will be undefined and the last line will fail.

This bug was introduced in Python 2.7. It used to work correctly under Python 2.6.

I didn't check Python 3.x.

I think this bug is trivial to reproduce: just try to upload any file with no permissions for it, using "--show_response" command line option.
Date User Action Args
2010-11-08 21:36:52jceasetrecipients: + jcea
2010-11-08 21:36:52jceasetmessageid: <>
2010-11-08 21:36:50jcealinkissue10367 messages
2010-11-08 21:36:49jceacreate