New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unorderable types error under Python 3 #670

pfmoore opened this Issue Sep 10, 2012 · 1 comment


None yet
2 participants

pfmoore commented Sep 10, 2012

There's what looks like a very obscure bug in pip's handling of index scanning, that shows up as a crash under Python 3 with the error "TypeError: unorderable types: Link() < Link()". I got it while testing the wheel patches, but I don't believe it's related to wheels. The error is:

>pip install --use-wheel --find-links file://D:/Apps/Virtualenv/wheels --no-index regex
Ignoring indexes:
Downloading/unpacking regex
Traceback (most recent call last):
  File "D:\Data\vetest\lib\site-packages\pip-1.2-py3.3.egg\pip\", line 106, in main
    status =, args)
  File "D:\Data\vetest\lib\site-packages\pip-1.2-py3.3.egg\pip\commands\", line 273, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "D:\Data\vetest\lib\site-packages\pip-1.2-py3.3.egg\pip\", line 1135, in prepare_files
    url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
  File "D:\Data\vetest\lib\site-packages\pip-1.2-py3.3.egg\pip\", line 167, in find_requirement
TypeError: unorderable types: Link() < Link()

The wheel bits in the command invocation are not particularly relevant, as far as I can tell - see the analysis below.

It looks like the issue comes because file_versions is created by a call to _package_versions, which in turn calls _link_package_versions. That code returns "an iterable of triples (pkg_resources_version_key, link, python_version) that can be extracted from the given link". So when we sort that list, if we get two pkg_resources_version_key values the same, the second-level sort is on the link. And links aren't comparable except for equality. So if the links differ, boom.

A relatively easy fix is to add the comparison operators __le__, __lt__, __gt__, __ge__, __ne__ in the Link class. This avoids the TypeError, but it's not clear that the ordering means much in the context of the file_versions.sort() call. If that is an issue, I don't know enough to address it.

At the moment, I don't have a test that provokes this issue. I can't even completely see how my original command triggers the sequence of events I describe here. I will try to produce a test that provokes the bug. If I manage, I'll add it to this issue.


This comment has been minimized.

Show comment
Hide comment

carljm Sep 11, 2012


Fixed with merge of #671


carljm commented Sep 11, 2012

Fixed with merge of #671

@carljm carljm closed this Sep 11, 2012

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