[Bug 1556927] [NEW] python3 builtin help() fails with exception

David Cary 1556927 at bugs.launchpad.net
Mon Mar 14 12:49:23 UTC 2016


Public bug reported:

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

** Affects: python3-defaults (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: exception help inspect python3

** Attachment added: "A python module used to demonstrate the bug"
   https://bugs.launchpad.net/bugs/1556927/+attachment/4598669/+files/help_bug.py

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to python3-defaults in Ubuntu.
https://bugs.launchpad.net/bugs/1556927

Title:
  python3 builtin help() fails with exception

Status in python3-defaults package in Ubuntu:
  New

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

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/python3-defaults/+bug/1556927/+subscriptions



More information about the foundations-bugs mailing list