Wording suggestion for documentation (Data Model)

Discussion in 'Python' started by Jason R. Coombs, Jun 13, 2008.

  1. #!python

    """
    In the documentation for __del__ (under Python Language Reference/Data
    Model), the following warning is indicated:

    Warning [Caveat in 2.6]: Due to the precarious circumstances under
    which __del__() methods are invoked, exceptions that occur during
    their execution are ignored, and a warning is printed to sys.stderr
    instead. ...

    That statement appears, however, to be incorrect.

    Perhaps the warning should be re-worded to say "When __del__() methods
    are invoked, exceptions that occur during the execution of such
    methods must be caught and handled within the scope of the __del__()
    method call. Otherwise unhandled exceptions will be ignored except
    for a warning printed to sys.stderr instead."

    For example,
    """

    class X(object):
    def __del__(self):
    print 'deleting', self
    try:
    raise Exception, "OMG!"
    except:
    print 'caught exception, np'
    print 'made it past the exception'

    x = X()
    del x

    print 'x has been deleted, now what?'

    """
    All this prints something like:

    deleting <__main__.X object at 0x01BB1A50>
    caught exception, np
    made it past the exception
    x has been deleted, now what?
    """

    # - Jason R. Coombs
     
    Jason R. Coombs, Jun 13, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Frankie Montenegro
    Replies:
    3
    Views:
    522
    Frankie Montenegro
    Oct 14, 2005
  2. Paulo Jorge de O. C. de Matos

    Question on Wording

    Paulo Jorge de O. C. de Matos, Apr 26, 2008, in forum: C Programming
    Replies:
    8
    Views:
    334
    David Thompson
    May 5, 2008
  3. grocery_stocker
    Replies:
    4
    Views:
    253
    grocery_stocker
    May 2, 2009
  4. Ersek, Laszlo

    posting history -- wording of C1X sequencing

    Ersek, Laszlo, Sep 23, 2010, in forum: C Programming
    Replies:
    1
    Views:
    298
    Shao Miller
    Sep 24, 2010
  5. ZMZ
    Replies:
    1
    Views:
    326
    Michael Doubez
    Mar 3, 2011
Loading...

Share This Page