[issue35137] Exception in isinstance when __class__ property raises

2018-11-02 Thread Brett Cannon


Brett Cannon  added the comment:

I'm with Serhiy that exceptions should not be swallowed up unless there's a 
very good reason to, and in this instance there isn't if there's a bug in code 
as that low of a level as debugging that would be atrocious.

--
nosy: +brett.cannon
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35137] Exception in isinstance when __class__ property raises

2018-11-01 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

MemoryError and RecursionError are subclasses of Exception. And there are may 
be other exceptions that can be raised by virtually any code and depend on 
conditions out of your control.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35137] Exception in isinstance when __class__ property raises

2018-11-01 Thread Anthony Sottile


Anthony Sottile  added the comment:

arbitrary, sure, but deriving from `Exception` maybe?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35137] Exception in isinstance when __class__ property raises

2018-11-01 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Arbitrary exceptions should not be silenced. Imagine that the user pressed 
Ctrl-C when the __class__ property implemented in Python was executed. The 
KeyboardInterrupt exception will be silenced in Python 2, and isinstance() will 
silently return incorrect result.

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35137] Exception in isinstance when __class__ property raises

2018-11-01 Thread daniel hahler


Change by daniel hahler :


--
nosy: +blueyed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35137] Exception in isinstance when __class__ property raises

2018-11-01 Thread Anthony Sottile


New submission from Anthony Sottile :

This may be intentional, but the behaviour changed between python2 and python3. 
 Want to make sure it's intentional as we're working (hacking) around this in 
pytest: https://github.com/pytest-dev/pytest/pull/4284

The actual impact on pytest is the use of `inspect.isclass`

Simplest reproduction:

class C(object):
@property
def __class__(self):
raise AssertionError('fail')

isinstance(C(), type)


In python2.x:

$ python2 t.py
$

In python 3.x:

$ python3.7 t.py
Traceback (most recent call last):
  File "t.py", line 6, in 
isinstance(C(), type)
  File "t.py", line 4, in __class__
raise AssertionError('fail')
AssertionError: fail


In python2.x it appears there's code which intentionally avoids this case:

https://github.com/python/cpython/blob/ca079a3ea30098aff3197c559a0e32d42dda6d84/Objects/abstract.c#L2906-L2909

Mostly want to see if this is intentional or not, it does feel odd that 
`inspect.isclass` raises instead of returning `False` in this case, but it's 
unclear if it's a problem with `isclass` or `isinstance`

--
components: Library (Lib)
messages: 329078
nosy: Anthony Sottile
priority: normal
severity: normal
status: open
title: Exception in isinstance when __class__ property raises
type: behavior
versions: Python 3.7, Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com