[New-bugs-announce] [issue21512] time module becomes None after raise SystemExit

Ryder Lewis report at bugs.python.org
Thu May 15 19:50:18 CEST 2014


New submission from Ryder Lewis:

I'm not sure if this is a bug or expected behavior, but basically what I want to do is log the timestamp when an application exits. Sample script to illustrate the issue:

==== try.py ====
import time

class A():
    def __init__(self):
        print("Initializing A. The time is {}".format(time.time()))

    def __del__(self):
        if time is None:
            print("time is None!")
        else:
            print("Deleting A. The time is {}".format(time.time()))

a = A()
raise SystemExit()

=====

When running this script multiple times, there are 3 possible outcomes:

==== outcome #1 (happens about 25% of my trial runs, what I would expect is correct behavior) ====
Initializing A. The time is 1400175810.4806361
Deleting A. The time is 1400175810.483156

==== outcome #2 (happens about 50% of my trial runs) ====
Initializing A. The time is 1400175814.1646852
time is None!

==== outcome #3 (happens about 25% of my trial runs) ====
Initializing A. The time is 1400175809.6802816
Exception ignored in: <bound method A.__del__ of <__main__.A object at 0x7fb125eab5f8>>
Traceback (most recent call last):
  File "./try.py", line 12, in __del__
TypeError: 'NoneType' object is not callable

----------
components: Interpreter Core
messages: 218619
nosy: ryder.lewis
priority: normal
severity: normal
status: open
title: time module becomes None after raise SystemExit
type: behavior
versions: Python 3.4

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


More information about the New-bugs-announce mailing list