homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Broken "Exception ignored in:" message on OSError's
Type: Stage: resolved
Components: Interpreter Core Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: salty-horse, vstinner
Priority: normal Keywords:

Created on 2019年01月15日 10:18 by salty-horse, last changed 2022年04月11日 14:59 by admin. This issue is now closed.

Messages (4)
msg333661 - (view) Author: Ori Avtalion (salty-horse) * Date: 2019年01月15日 10:18
When an OSError exception is raised in __del__, both Python 2 and 3 print the "Exception ignored" message, but Python 3 also prints a traceback.
This is similar to issue 22836, with dealt with errors in __repr__ while inside __del__.
Test script:
import os
class Obj(object):
 def __init__(self):
 self.f = open('/dev/null')
 os.close(self.f.fileno())
 def __del__(self):
 self.f.close()
f = Obj()
del f
Output with Python 3.7.2:
Exception ignored in: <function Obj.__del__ at 0x7fb18789be18>
Traceback (most recent call last):
 File "/tmp/test.py", line 9, in __del__
 self.f.close()
OSError: [Errno 9] Bad file descriptor
msg333672 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019年01月15日 10:47
Python works as expected, I don't understand why you opened a bug report? What looks wrong to you?
Closing a closed file descriptor is your fault, not a bug in Python.
Python logs an error as expected.
msg333676 - (view) Author: Ori Avtalion (salty-horse) * Date: 2019年01月15日 11:26
Sorry, I was confused by how Python 3 prints the traceback of ignored exceptions, and Python 2 does not.
(This happens on on any exception and not just OSError)
msg333679 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019年01月15日 11:26
> Sorry, I was confused by how Python 3 prints the traceback of ignored exceptions, and Python 2 does not.
It's not a bug but a nice feature which helps you to debug your code!
History
Date User Action Args
2022年04月11日 14:59:10adminsetgithub: 79924
2019年01月15日 11:26:58vstinnersetmessages: + msg333679
2019年01月15日 11:26:19salty-horsesetstatus: open -> closed
resolution: not a bug
messages: + msg333676

stage: resolved
2019年01月15日 10:47:42vstinnersetnosy: + vstinner
messages: + msg333672
2019年01月15日 10:18:35salty-horsecreate

AltStyle によって変換されたページ (->オリジナル) /