[issue12022] AttributeError should report the same details when raised by lookup_special() as when raised in the REPL

2021-06-29 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> 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



[issue12022] AttributeError should report the same details when raised by lookup_special() as when raised in the REPL

2021-06-29 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 20a88004bae8ead66a205a125e1fe979376fc3ea by Serhiy Storchaka in 
branch 'main':
bpo-12022: Change error type for bad objects in "with" and "async with" 
(GH-26809)
https://github.com/python/cpython/commit/20a88004bae8ead66a205a125e1fe979376fc3ea


--

___
Python tracker 

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



[issue12022] AttributeError should report the same details when raised by lookup_special() as when raised in the REPL

2021-06-20 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

PR 26809 makes "with" and "async with" raising TypeError instead of 
AttributeError for wrong types.

--

___
Python tracker 

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



[issue12022] AttributeError should report the same details when raised by lookup_special() as when raised in the REPL

2021-06-20 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +gvanrossum

___
Python tracker 

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



[issue12022] AttributeError should report the same details when raised by lookup_special() as when raised in the REPL

2021-06-20 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
keywords: +patch
pull_requests: +25391
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/26809

___
Python tracker 

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



[issue12022] AttributeError should report the same details when raised by lookup_special() as when raised in the REPL

2021-06-19 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
assignee:  -> serhiy.storchaka

___
Python tracker 

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



[issue12022] AttributeError should report the same details when raised by lookup_special() as when raised in the REPL

2021-06-19 Thread Irit Katriel


Irit Katriel  added the comment:

I've reproduced this on 3.11 (though the AttributeError is now on __enter__ and 
not __exit__ as was the case in msg135484):

>>> import transaction
>>> with transaction: pass
...
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: __enter__

>>> import sys
>>> sys.__exit__
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: module 'sys' has no attribute '__exit__'
>>>

--
nosy: +iritkatriel
versions: +Python 3.11 -Python 2.7

___
Python tracker 

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



[issue12022] AttributeError should report the same details when raised by lookup_special() as when raised in the REPL

2019-10-19 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Would not be better to change an AttributeError to TypeError? Seems this is the 
only place in the core when missing special method causes an AttributeError and 
not TypeError.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue12022] AttributeError should report the same details when raised by lookup_special() as when raised in the REPL

2011-05-23 Thread Éric Araujo

Éric Araujo  added the comment:

> hasattr(transaction, '__exit__')

http://docs.python.org/dev/reference/datamodel#special-method-names explains 
that magic methods are looked up on the class, not on the instances.  There’s a 
lot of code out there that erroneously checks for __len__ or __call__ on 
instances, and this is the second time to my knowledge that a project abused a 
module-level __enter__ function.

--
nosy: +eric.araujo

___
Python tracker 

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



[issue12022] AttributeError should report the same details when raised by lookup_special() as when raised in the REPL

2011-05-07 Thread Daniel Urban

Changes by Daniel Urban :


--
nosy: +durban

___
Python tracker 

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



[issue12022] AttributeError should report the same details when raised by lookup_special() as when raised in the REPL

2011-05-07 Thread Daniel Holth

Daniel Holth  added the comment:

Thank you Benjamin for following up on this issue

--

___
Python tracker 

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



[issue12022] AttributeError should report the same details when raised by lookup_special() as when raised in the REPL

2011-05-07 Thread Daniel Holth

Daniel Holth  added the comment:

Python should explain AttributeError in the same way when it's raised by the 
interpreter. The with: statement below should raise the second AttributeError, 
not the first.

import transaction
with transaction: pass
>>> AttributeError: __exit__

import sys
sys.__exit__
>>> AttributeError: 'module' object has no attribute '__exit__'

--
title: improve special method lookup error message -> AttributeError should 
report the same details when raised by lookup_special() as when raised in the 
REPL

___
Python tracker 

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