Repository navigation
Fix hasattr's exception problems #46449
Copy link
Copy link
Closed
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dirinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
| BPO | 2196 |
|---|---|
| Nosy | @brettcannon, @birkenfeld, @benjaminp |
| Files |
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 = 'https://github.com/birkenfeld'
closed_at = <Date 2008-05-12.00:41:47.228>
created_at = <Date 2008-02-26.22:51:54.721>
labels = ['interpreter-core', 'type-bug', 'tests', 'docs']
title = "Fix hasattr's exception problems"
updated_at = <Date 2008-05-12.00:41:47.130>
user = 'https://github.com/benjaminp'bugs.python.org fields:
activity = <Date 2008-05-12.00:41:47.130>
actor = 'benjamin.peterson'
assignee = 'georg.brandl'
closed = True
closed_date = <Date 2008-05-12.00:41:47.228>
closer = 'benjamin.peterson'
components = ['Documentation', 'Interpreter Core', 'Tests']
creation = <Date 2008-02-26.22:51:54.721>
creator = 'benjamin.peterson'
dependencies = []
files = ['9563', '9567', '9576', '9630', '9631']
hgrepos = []
issue_num = 2196
keywords = ['patch']
message_count = 12.0
messages = ['63055', '63112', '63138', '63147', '63151', '63341', '63350', '63366', '63367', '63996', '63999', '66693']
nosy_count = 4.0
nosy_names = ['brett.cannon', 'georg.brandl', '_doublep', 'benjamin.peterson']
pr_nums = []
priority = 'normal'
resolution = 'accepted'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue2196'
versions = ['Python 2.6']Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dirinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
benjaminp commentedon Feb 26, 2008
hasattr currently returns False when any exception happens in getattr. I
see that this tracker I previous patches trying to fix this issue, but
they were rejected because they only tried to catch attribute errors. My
patch only propagates SystemExit and KeyboardInterrupt exceptions.
benjaminp commentedon Feb 28, 2008
Here's a documentation change that explains hasattr's exception issues
top accompany my patch.
birkenfeld commentedon Feb 29, 2008
Please reformat your patch using tabs.
benjaminp commentedon Feb 29, 2008
After looking more closely, I saw that this is documented at
http://www.python.org/dev/patches/style/. So the C uses tabs, and the
Python uses spaces?
brettcannon commentedon Feb 29, 2008
On Fri, Feb 29, 2008 at 2:04 PM, Benjamin Peterson
<report@bugs.python.org> wrote:
Yes, although that is changing in Python 3.0.
benjaminp commentedon Mar 6, 2008
I suppose another way we could do this is propagate any exception which
doesn't inherit Exception. I, however, like just having just those 2
specific exceptions continue.
doublep commentedon Mar 7, 2008
I think it would be better not to hardcode specific 2 exceptional cases
and indeed follow that second way of instanceof(..., Exception). I
think it was introduced exactly to separate "things that can be caught
by default" from "things that may be caught only in very special cases".
I don't find it good Python interpreter not following its own rules.
benjaminp commentedon Mar 7, 2008
Here's a patch for that. Personally, I'm +1 on either option; I just
want it fixed. :)
I suppose the only (minor) problem with propagate things which are not
Exception is libraries where the exceptions don't extend Exception.
However, the ability to do this is being removed in Py3k, so it's not huge.
benjaminp commentedon Mar 7, 2008
That last patch is malformed.
benjaminp commentedon Mar 18, 2008
Further comments?
brettcannon commentedon Mar 18, 2008
On Tue, Mar 18, 2008 at 4:48 PM, Benjamin Peterson
<report@bugs.python.org> wrote:
I have not looked at the patch yet (and I don't know when I will get to it).
benjaminp commentedon May 12, 2008
Done in r63119.