python3 builtin help() fails with exception

Bug #1556927 reported by David Cary
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python3-defaults (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

The builtin help() function fails with an exception when called on a class that has a data attribute initialized to an object of a class which implements __eq__ in a manner that raises an exception when comparing to None.

The attached file, help_bug.py, is a module that illustrates the problem. In an interactive python3 session, importing the module as help_bug and then using the command:

  help(help_bug)

will cause help to fail with a TypeError exception raised by the __eq__ method of the RestrictedCompare class before any help documentation is displayed.

In this example, it is the attribute named 'restricted' in the HelpBug class that is causing the problem, specifically its initialization to an object from the RestrictedCompare class. The command help(help_bug.HelpBug) also fails with the exception, although help(help_bug.RestrictedCompare) is successful.

This is a result of a comparison of objects that is not protected by try ... except in the classify_class_attrs() function of the standard inspect module. In particular, it is happening at the first comparison of:

    srch_obj == get_obj

when srch_obj is None.

The help(help_bug) and help(help_bug.HelpBug) calls successfully display help documentation in Python 2.7.

The output of lsb_release -rd is:

Description: Ubuntu 14.04.4 LTS
Release: 14.04

The package containing the inspect.py file is version libpython3.4-minimal 3.4.3-1ubuntu~14.04.3

Revision history for this message
David Cary (dcary) wrote :
Mathew Hodson (mhodson)
tags: added: testcase trusty
removed: exception help inspect python3
Changed in python3-defaults (Ubuntu):
importance: Undecided → Medium
Revision history for this message
Serhiy Storchaka (storchaka) wrote :

This is fixed in version 3.4.4 in mainstream (https://bugs.python.org/issue23898).

Revision history for this message
Matthias Klose (doko) wrote :

so fixed at least in 16.04 LTS and newer releases

Changed in python3-defaults (Ubuntu):
status: New → Fix Released
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.