Peter p.j.a.c...@googlemail.com added the comment:
I take it the IGNORE_EXCEPTION_DETAIL should ignore the module name
fix will not be applied to Python 3.1.x?
Is there a separate bug to enhance 2to3 to turn IGNORE_EXCEPTION_DETAIL
on?
--
nosy: +maubp
Nick Coghlan ncogh...@gmail.com added the comment:
On Wed, Jul 28, 2010 at 11:40 PM, Peter rep...@bugs.python.org wrote:
Peter p.j.a.c...@googlemail.com added the comment:
I take it the IGNORE_EXCEPTION_DETAIL should ignore the module name
fix will not be applied to Python 3.1.x?
Correct
R. David Murray rdmur...@bitdance.com added the comment:
2to3 can convert doctests, it just can't convert the *output* portion of
doctests. because they are arbitrary strings and not syntactically valid Python
code. Since turning on this flag would require recognizing something in the
output
Nick Coghlan ncogh...@gmail.com added the comment:
And done for 3.2 in r81944 (that checkin included a correction to the docs
example which I backported to 2.7 in r81945)
--
status: pending - closed
___
Python tracker rep...@bugs.python.org
Nick Coghlan ncogh...@gmail.com added the comment:
Committed for 2.7 in r80578
I'll forward port to 3.2 at some point after the next 2.7 beta is out.
--
resolution: - accepted
stage: patch review - committed/rejected
status: open - pending
___
Changes by Nick Coghlan ncogh...@gmail.com:
--
assignee: - ncoghlan
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7490
___
___
Python-bugs-list
Julian Scheid julian...@googlemail.com added the comment:
Having this in 2.6/2.7 would be great.
I don't think the ELLIPSIS workaround suggested by Barry works, have you
actually tried it?
Below is an example where ELLIPSIS doesn't seem to help (run in 2.6.5). I have
also tried ...Error:
Lennart Regebro rege...@gmail.com added the comment:
The ellipsis doesn't work, because when you have an ellipsis at the beginning
of the message, doctest will not understand that it's supposed to be an
Exception, so it doesn't even try to match exceptions, and it will therefore
always fail.
Julian Scheid julian...@googlemail.com added the comment:
Here's a better example that you can cut and paste.
import optparse
def foo():
foo() #doctest: +ELLIPSIS
Traceback (most recent call last):
. . .
...OptionError: option bar: foo
raise
Julian Scheid julian...@googlemail.com added the comment:
Ah, right... so there is no easy workaround at present?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7490
___
Lennart Regebro rege...@gmail.com added the comment:
Sure: Catch the exception in the test, and fail if it isn't catched.
try:
... do_something_that_raises_exception()
... raise Assertionerror(Exception Blah was not raised)
... except Blah:
... pass
Ugly, yes, but easy. To make it
Julian Scheid julian...@googlemail.com added the comment:
Thank you for the suggestion but in my mind that's not a viable workaround, and
not just because of uglyness: I'm using doctest to validate code examples,
which are included in the documentation and are meant to be educational. If
Julian Scheid julian...@googlemail.com added the comment:
Hmm, wait. Here's a variation of your suggestion that works OK-ish even as an
example:
try:
...# ... code that fails ...
... except mypkg.MyException, e:
...print(str(e))
Expected error message.
This works because it omits
Nick Coghlan ncogh...@gmail.com added the comment:
The corner case I was talking about was the one where you actually *want* the
old, more restrictive behaviour (i.e. you specifically want to receive
'x.y.Exception' and receiving 'a.b.Exception' instead should fail), but still
want to ignore
R. David Murray rdmur...@bitdance.com added the comment:
I think this one is worth making an exception for, since it would mean that a
project could have 3.x doctests that also work with 2.7, whereas if we leave it
out of 2.7 the doctests have to stay in 2.x format even if the project has (at
Lennart Regebro rege...@gmail.com added the comment:
It's not possible for 2to3 to reformat exceptions, as the formatting would need
to go from TheException to themodule.TheException, and there is no way to
figure out the module name...
--
___
Nick Coghlan ncogh...@gmail.com added the comment:
With a little more thought, I'm actually keen on including it as well (although
the docs still need a bit more tweaking). The 2.x/3.x compatibility point is a
good one.
If Benjamin OKs it, I'll include this in the list of things I want to get
R. David Murray rdmur...@bitdance.com added the comment:
@Lennart: no, in that direction (2.7 to 3.x) there's less of a problem. You
leave the module name off in the doctest, and have 2to3 add the
IGNORE_EXCEPTION_DETAIL to the doctest during translation.
I was looking at the farther future
Lennart Regebro rege...@gmail.com added the comment:
Sure, but +IGNORE_EXCEPTION_DETAIL will only work on Python 3.2+, so 2to3 can't
solve the issue. It can only help once 3.2 does the actual solving. ;)
3to2 could simply remove the module name from exceptions in the output. You
don't need to
R. David Murray rdmur...@bitdance.com added the comment:
By that logic, 2to3 can't solve anything. I don't think there's any question
that this patch should be applied to 3.2. 3.1 might be an issue as it is a new
feature, but maybe we can claim it is a bug fix :)
As for 3to2, like I said I
Benjamin Peterson benja...@python.org added the comment:
2010/4/15 Nick Coghlan rep...@bugs.python.org:
Nick Coghlan ncogh...@gmail.com added the comment:
With a little more thought, I'm actually keen on including it as well
(although the docs still need a bit more tweaking). The 2.x/3.x
Changes by Georg Brandl ge...@python.org:
--
nosy: +georg.brandl
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7490
___
___
Python-bugs-list
Changes by Lennart Regebro rege...@gmail.com:
Removed file: http://bugs.python.org/file15537/python-py3k-exception-detail.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7490
___
Changes by Lennart Regebro rege...@gmail.com:
Removed file:
http://bugs.python.org/file15538/python-trunk-exception-detail.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7490
___
Lennart Regebro rege...@gmail.com added the comment:
New diff for trunk, with the additional test
--
Added file: http://bugs.python.org/file15972/python-trunk-exception-detail.diff
___
Python tracker rep...@bugs.python.org
Lennart Regebro rege...@gmail.com added the comment:
New diff for Py3k with the additional test
--
Added file: http://bugs.python.org/file15973/python-py3k-exception-detail.diff
___
Python tracker rep...@bugs.python.org
Barry A. Warsaw ba...@python.org added the comment:
@Lennart: yes, I do think you should add a test for that case. I
haven't yet decided whether this should go into 2.6.
--
nosy: +barry
___
Python tracker rep...@bugs.python.org
New submission from Lennart Regebro rege...@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
Changes by Lennart Regebro rege...@gmail.com:
Added file: http://bugs.python.org/file15538/python-trunk-exception-detail.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7490
___
Changes by R. David Murray rdmur...@bitdance.com:
--
priority: - high
stage: - patch review
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7490
___
Changes by Nick Coghlan ncogh...@gmail.com:
--
nosy: +ncoghlan
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7490
___
___
Python-bugs-list mailing
Nick Coghlan ncogh...@gmail.com added the comment:
The only design level question I can see is as follows:
ExceptionName matches ExceptionName (always)
a.b.ExceptionName matches ExceptionName (under IGNORE_EXCEPTION_DETAIL)
ExceptionName matches a.b.ExceptionName (under IGNORE_EXCEPTION_DETAIL)
R. David Murray rdmur...@bitdance.com added the comment:
My impression is that IGNORE_EXCEPTION_DETAIL is designed to allow you
to have a doctest as an example with a fully typed out exception detail,
but have it pass even if the exception detail changes. If that is
indeed the original design,
Nick Coghlan ncogh...@gmail.com added the comment:
Agreed - particularly since that corner case can still be tested through
doctest if desired by using ELLIPSIS instead of IGNORE_EXCEPTION_DETAIL.
The patches mostly look good, but the doc changes should be updated to
indicate that using
Lennart Regebro rege...@gmail.com added the comment:
Yes, x.y.Exception and a.b.Exception should match. I just realized I
didn't add an explicit test for that, but maybe that's not strictly
necessary.
--
___
Python tracker rep...@bugs.python.org
35 matches
Mail list logo