Skip to content

Instantly share code, notes, and snippets.

@mgood
Created June 5, 2013 20:29
Show Gist options
  • Save mgood/5717047 to your computer and use it in GitHub Desktop.
Save mgood/5717047 to your computer and use it in GitHub Desktop.
PyPI XML-RPC errors
Fails on Python 2.6 with http:
$ python2.6 releases.py http
Traceback (most recent call last):
File "releases.py", line 5, in <module>
print xmlrpclib.ServerProxy('%s://pypi.python.org/pypi' % protocol).package_releases('roundup')
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line 1199, in __call__
return self.__send(self.__name, args)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line 1489, in __request
verbose=self.__verbose
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line 1253, in request
return self._parse_response(h.getfile(), sock)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line 1390, in _parse_response
p.close()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line 604, in close
self._parser.Parse("", 1) # end of data
xml.parsers.expat.ExpatError: no element found: line 1, column 0
But works in 2.6 with https, or Python 2.7 on either protocol:
$ python2.6 releases.py https
['1.4.21']
$ python2.7 releases.py http
['1.4.21']
$ python2.7 releases.py https
['1.4.21']
import sys
import xmlrpclib
protocol = sys.argv[1]
client = xmlrpclib.ServerProxy('%s://pypi.python.org/pypi' % protocol)
print client.package_releases('roundup')
@mgood
Copy link
Author

mgood commented Jun 5, 2013

This presented itself in my project by breaking the Tox bootstrap script from here:

http://testrun.org/tox/latest//example/jenkins.html?highlight=toxbootstrap

This was working within the last few days, but today it was broken:

$ wget https://bitbucket.org/hpk42/tox/raw/default/toxbootstrap.py
$ python2.6 toxbootstrap.py
INFO:root:toxbootstrap version 1.5.dev11
INFO:root:Downloading https://github.com/pypa/virtualenv/raw/master/virtualenv.py
INFO:root:Running command: /usr/bin/python2.6 virtualenv.py --no-site-packages --distribute _toxinstall
New python executable in _toxinstall/bin/python2.6
Also creating executable in _toxinstall/bin/python
Installing distribute............................................................................................................................................................................................................................done.
Installing pip....................done.
INFO:root:removing virtualenv.py script after bootstrap venv creation
INFO:root:added to PATH: /Users/mgood/scratch/.tox/_toxinstall/bin
INFO:root:Running command (for output): _toxinstall/bin/python -s -c "import tox,sys; sys.stdout.write(str(tox.version))"
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named tox
Traceback (most recent call last):
File "toxbootstrap.py", line 251, in
cmdline(sys.argv[1:])
File "toxbootstrap.py", line 221, in cmdline
get_tox_version(TENV) != pypi_get_latest_version('tox')]):
File "toxbootstrap.py", line 167, in pypi_get_latest_version
versions = pypi.package_releases('tox')
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line 1199, in call
return self.__send(self.__name, args)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line 1489, in __request
verbose=self.__verbose
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line 1253, in request
return self._parse_response(h.getfile(), sock)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line 1390, in _parse_response
p.close()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line 604, in close
self._parser.Parse("", 1) # end of data
xml.parsers.expat.ExpatError: no element found: line 1, column 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment