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

Confusing error message from warnings.warn #55703

Closed
gerritholl mannequin opened this issue Mar 14, 2011 · 2 comments
Closed

Confusing error message from warnings.warn #55703

gerritholl mannequin opened this issue Mar 14, 2011 · 2 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@gerritholl
Copy link
Mannequin

gerritholl mannequin commented Mar 14, 2011

BPO 11494
Nosy @brettcannon, @gerritholl

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 2011-03-20.20:12:32.368>
created_at = <Date 2011-03-14.10:47:51.891>
labels = ['interpreter-core', 'type-bug', 'library']
title = 'Confusing error message from warnings.warn'
updated_at = <Date 2011-03-20.20:12:32.367>
user = 'https://github.com/gerritholl'

bugs.python.org fields:

activity = <Date 2011-03-20.20:12:32.367>
actor = 'brett.cannon'
assignee = 'none'
closed = True
closed_date = <Date 2011-03-20.20:12:32.368>
closer = 'brett.cannon'
components = ['Interpreter Core', 'Library (Lib)']
creation = <Date 2011-03-14.10:47:51.891>
creator = 'Gerrit.Holl'
dependencies = []
files = []
hgrepos = []
issue_num = 11494
keywords = []
message_count = 2.0
messages = ['130800', '131535']
nosy_count = 2.0
nosy_names = ['brett.cannon', 'Gerrit.Holl']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue11494'
versions = ['Python 3.1', 'Python 2.7', 'Python 3.2', 'Python 3.3']

@gerritholl
Copy link
Mannequin Author

gerritholl mannequin commented Mar 14, 2011

When accidentally passing a string to warnings.warn where one should pass a Warning-class, the error message is rather confusing:

 $ ./python 
 Python 2.7.1+ (release27-maint:88766, Mar  8 2011, 16:51:59) 
 [GCC 4.4.5] on linux2
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import warnings
 >>> warnings.warn("aaa", "bbb")
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
 TypeError: issubclass() arg 1 must be a class

It would be better for the error message to say TypeError: warnings must be classes inherited from ... or something like that.

@gerritholl gerritholl mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Mar 14, 2011
@brettcannon
Copy link
Member

I'm not crazy about the idea of adding an inspect.isclass() check simply to clear up this rare error message. It's still decipherable what the problem is from the issubclass() message.

Closing as "won't fix".

@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
interpreter-core (Objects, Python, Grammar, and Parser dirs) stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant