This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Standard Library, Warnings, 28.5.4, example fails
Type: Stage:
Components: Documentation Versions: Python 2.7, Python 2.6
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: georg.brandl, jasontiller
Priority: normal Keywords:

Created on 2009-07-18 08:23 by jasontiller, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg90658 - (view) Author: Jason Tiller (jasontiller) Date: 2009-07-18 08:23
The example provided in section 28.5.4 (warnings) of the Standard
Library documentation fails.  This example assumes that the context
manager instance ('w' in "warnings.catch_warnings(record=True) as w")
supplies a list of objects, each of which has a data attribute
'.category' that is an instance.  However, the '.category' data
attribute is actually a class.

The example code fails in this way on 2.6.2:

Traceback (most recent call last):
  File "", line 14, in <module>
    assert isinstance(w[-1].category, DeprecationWarning)

Replacing 'isinstance' with 'issubclass' appears to satisfy the assertion.
msg90660 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-07-18 09:03
Thanks, fixed in r74074.
Date User Action Args
2022-04-11 14:56:51adminsetgithub: 50762
2009-07-18 09:03:41georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg90660
2009-07-18 08:23:41jasontillercreate