From: Zooko O'Whielacronx Date: Thu, 22 Nov 2012 16:27:28 +0000 (-0700) Subject: pkg_resources: better error message on bad spec X-Git-Tag: allmydata-tahoe-1.10a1~38 X-Git-Url: https://git.rkrishnan.org/?a=commitdiff_plain;h=06a8b1ea84fd67c019ef91c28c18ddcc9ea2ecb8;p=tahoe-lafs%2Ftahoe-lafs.git pkg_resources: better error message on bad spec Include the text of the offending distribution spec when it is ill-formed. I got an error message from pkg_resources.py saying that a distribution spec was ill-formed, because it ended with an '=' and nothing came after the '='. However, the error message and stack trace didn't tell which distribution spec it was. With this patch, it includes the distribution spec itself in the error message. There is no unit test of this patch, but I did test it manually by inserting a "raise ValueError('WHATEVER')" into the code and re-running it and observing that the new output correctly included the distribution --- diff --git a/setuptools-0.6c16dev3.egg/pkg_resources.py b/setuptools-0.6c16dev3.egg/pkg_resources.py index 00d97225..3dbdec14 100644 --- a/setuptools-0.6c16dev3.egg/pkg_resources.py +++ b/setuptools-0.6c16dev3.egg/pkg_resources.py @@ -528,11 +528,14 @@ class WorkingSet(object): # dist is unsatisfactory, in which case we won't add it. if __requires__ is not None: for thisreqstr in __requires__: - for thisreq in parse_requirements(thisreqstr): - if thisreq.key == dist.key: - if dist not in thisreq: - return - + try: + for thisreq in parse_requirements(thisreqstr): + if thisreq.key == dist.key: + if dist not in thisreq: + return + except ValueError, e: + e.args = tuple(e.args + ({'thisreqstr': thisreqstr},)) + raise self.by_key[dist.key] = dist if dist.key not in keys: