[New-bugs-announce] [issue7490] IGNORE_EXCEPTION_DETAIL should ignore the module name

Lennart Regebro report at bugs.python.org
Sun Dec 13 12:11:42 CET 2009


New submission from Lennart Regebro <regebro at gmail.com>:

In Python 3.x [1] the exception formatting prints the module path, while
under 2.x it prints only the exception class name. This makes it very
tricky to make doctests that pass under both Python 2 and Python 3
without resorting to ugly tricks.

Since IGNORE_EXCEPTION_DETAIL was implemented to hide differences
between exception messages in 2.3 and 2.4, it was suggested on
python-dev [2] that IGNORE_EXCEPTION_DETAIL should be extended to also
ignore the module name, so that `module.name.ExceptionClass` and
`ExceptionClass` would match each other. This is easily done by just
changing the regexp that is done for matching.

I'll attach diffs both for trunk and for py3k-branch, so that both forms
can be used on both versions. The diffs include tests and suggested
documentation changes (although I reserve the right to be useless at
writing documentation).



[1] And possibly in some cases under Python 2.7 according to reports in
the thread on python-dev about this issue, although I haven't been able
to confirm this. I'll include a 2.7 diff anyway, as it would be good if
both syntaxes work under both versions, if people start using 3to2, for
example.

[2] http://mail.python.org/pipermail/python-dev/2009-December/094460.html

----------
components: Tests
files: python-py3k-exception-detail.diff
keywords: patch
messages: 96329
nosy: lregebro
severity: normal
status: open
title: IGNORE_EXCEPTION_DETAIL should ignore the module name
type: behavior
versions: Python 2.7, Python 3.1
Added file: http://bugs.python.org/file15537/python-py3k-exception-detail.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7490>
_______________________________________


More information about the New-bugs-announce mailing list