New submission from Jason Tiller <ja...@sonos.org>:

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 "bob.py", line 14, in <module>
    assert isinstance(w[-1].category, DeprecationWarning)
AssertionError
-----

Replacing 'isinstance' with 'issubclass' appears to satisfy the assertion.

----------
assignee: georg.brandl
components: Documentation
messages: 90658
nosy: georg.brandl, jasontiller
severity: normal
status: open
title: Standard Library, Warnings, 28.5.4, example fails
versions: Python 2.6, Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue6513>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to