doctest cannot compile finally

Bug #606897 reported by Curtis Hovey
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pocket-lint
Fix Released
High
Unassigned

Bug Description

./lib/lp/registry/doc/message-holds-xmlrpc.txt
      54: Could not compile:
             finally:

    >>> try:
    ... print held_message_anne.posted_message.read()
    ... finally:
    ... held_message_anne.posted_message.close()

Related branches

Revision history for this message
Curtis Hovey (sinzui) wrote :

^ note that the formatter ruins the indentation, which does appear to be correct in the doctest. This issue is also in the pyflakes-doctest script. Two indenpendent implementation have the same issue.

Revision history for this message
Curtis Hovey (sinzui) wrote :

DocTestParser.parse() is returning the second part of the block indented. DocTestParser() knows that >>> starts a block and that ... is subordinate and thus indented. However, changing the example doctest to ">>> finally:' causes the test to fail.

This leads me to wonder if the finally is really running in the examples in the problematic doctest. In the cases I see in the test, we could use the 'with' statement instead, or rewrite the code as a function that will be treated in a manner we expect.

I know how to hack the checker to compile the 'finally:' line, but I think it is better for us to not second guess the parser(). The doctest is bad and we should rewrite.

Changed in pocket-lint:
status: Triaged → Won't Fix
Curtis Hovey (sinzui)
Changed in pocket-lint:
status: Won't Fix → Triaged
importance: Medium → Undecided
Curtis Hovey (sinzui)
Changed in pocket-lint:
status: Triaged → In Progress
importance: Undecided → High
assignee: nobody → Curtis Hovey (sinzui)
Revision history for this message
Curtis Hovey (sinzui) wrote :

There is a simple fix for this. Do not use _disambuguate_doctest() during __init__ because it mutates the continuation lines. Is this still needed by the doctest reformatter? The worst doctests were clean up, most that could have their continuation lines reformatted would be better rewritten. Consider removing the method.

Curtis Hovey (sinzui)
Changed in pocket-lint:
status: In Progress → Fix Committed
Curtis Hovey (sinzui)
Changed in pocket-lint:
milestone: none → 0.5.4
Curtis Hovey (sinzui)
Changed in pocket-lint:
status: Fix Committed → Fix Released
Curtis Hovey (sinzui)
Changed in pocket-lint:
assignee: Curtis Hovey (sinzui) → nobody
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.