Exception when loading top_level.txt while loading module help info

Bug #1719465 reported by Ajith Antony
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
cliff
Fix Released
Medium
Doug Hellmann

Bug Description

In this patch that prepares a mapping of module names to project names,

    https://git.openstack.org/cgit/openstack/cliff/commit/?h=2.9.0&id=9491749b09caf4f600447e3ebecdb1943cc77bf7

    37 for dist in pkg_resources.working_set:
    38 try:
    39 mod_name = dist.get_metadata('top_level.txt').strip()
    40 except KeyError:
    41 # Could not retrieve metadata. Ignore.
    42 pass

We attempt to iterate through the set of pkg_resources.DistInfoDistribution
objects. For each one we attempt to read the "top_level.txt" file. However,
not all python packages have a top_level.txt

    >>> pkg_resources.working_set.by_key['ptyprocess'].get_metadata('top_level.txt')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "<redacted>/.env/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1486, in get_metadata
        value = self._get(self._fn(self.egg_info, name))
      File "<redacted>/.env/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1595, in _get
        with open(path, 'rb') as stream:
    IOError: [Errno 2] No such file or directory: '<redacted>/.env/lib/python2.7/site-packages/ptyprocess-0.5.2.dist-info/top_level.txt'

This raises IOError which is not handled locally since we only catch KeyError
here. This exception causes the cli to exit, and precludes executing any cli
command.

Another note, toplevel.txt, when it is present, is potentially multi-lined, so
strictly speaking, each line should be added to the mapping, so that all the
potential top level modules are mapped to the project name.

First seen in 2.9.0

Changed in python-cliff:
status: New → Triaged
assignee: nobody → Doug Hellmann (doug-hellmann)
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cliff (master)

Fix proposed to branch: master
Review: https://review.openstack.org/507679

Changed in python-cliff:
status: Triaged → In Progress
description: updated
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cliff (master)

Reviewed: https://review.openstack.org/507679
Committed: https://git.openstack.org/cgit/openstack/cliff/commit/?id=a9719bc23ea3ad90cbad9ab743e678f491e85f0a
Submitter: Jenkins
Branch: master

commit a9719bc23ea3ad90cbad9ab743e678f491e85f0a
Author: Doug Hellmann <email address hidden>
Date: Tue Sep 26 17:17:08 2017 -0400

    handle more varied top_level.txt files in distributions

    Deal with distributions that do not have the top_level.txt metadata
    file, or that have more than one module name listed in it.

    Change-Id: I7d21f4ba674ee95d072b0bc8e5f22b5b4b7a32b4
    Closes-Bug: #1719465
    Signed-off-by: Doug Hellmann <email address hidden>

Changed in python-cliff:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/cliff 2.9.1

This issue was fixed in the openstack/cliff 2.9.1 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.