Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken "Exception ignored in:" message on OSError's #79924

Closed
salty-horse mannequin opened this issue Jan 15, 2019 · 4 comments
Closed

Broken "Exception ignored in:" message on OSError's #79924

salty-horse mannequin opened this issue Jan 15, 2019 · 4 comments
Labels
3.7 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@salty-horse
Copy link
Mannequin

salty-horse mannequin commented Jan 15, 2019

BPO 35743
Nosy @salty-horse, @vstinner

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2019-01-15.11:26:19.488>
created_at = <Date 2019-01-15.10:18:35.099>
labels = ['interpreter-core', '3.7', 'invalid']
title = 'Broken "Exception ignored in:" message on OSError\'s'
updated_at = <Date 2019-01-15.11:26:58.181>
user = 'https://github.com/salty-horse'

bugs.python.org fields:

activity = <Date 2019-01-15.11:26:58.181>
actor = 'vstinner'
assignee = 'none'
closed = True
closed_date = <Date 2019-01-15.11:26:19.488>
closer = 'salty-horse'
components = ['Interpreter Core']
creation = <Date 2019-01-15.10:18:35.099>
creator = 'salty-horse'
dependencies = []
files = []
hgrepos = []
issue_num = 35743
keywords = []
message_count = 4.0
messages = ['333661', '333672', '333676', '333679']
nosy_count = 2.0
nosy_names = ['salty-horse', 'vstinner']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue35743'
versions = ['Python 3.6', 'Python 3.7']

@salty-horse
Copy link
Mannequin Author

salty-horse mannequin commented Jan 15, 2019

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 bpo-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

@salty-horse salty-horse mannequin added 3.7 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Jan 15, 2019
@vstinner
Copy link
Member

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.

@salty-horse
Copy link
Mannequin Author

salty-horse mannequin commented Jan 15, 2019

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)

@salty-horse salty-horse mannequin closed this as completed Jan 15, 2019
@salty-horse salty-horse mannequin added the invalid label Jan 15, 2019
@vstinner
Copy link
Member

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!

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.7 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs)
Projects
None yet
Development

No branches or pull requests

1 participant