05.12.19 21:25, Matthias Bussonnier пише:
I've been tripped up a couple of time by a few Exception names being lower case 
both in code and tracebacks.  In particular `error` (all lower case)
I tend to read `error` as a function instead of a class.

According to my non-scientific grep-foo, I find that  ~ 300 descendant from 
Exceptions start with an upper case:

~/dev/cpython[master ✗] $ rg '^[ ]*class [A-Z][a-zA-Z]+\(' | grep Excep | wc  -l
      333
18 of those are `Error` uppercase:
~/dev/cpython[master ✗] $ rg '^[ ]*class Error\(' | wc -l
       18
but 4 are lower case:

~/dev/cpython[master ✗]  $ rg '^[ ]*class [a-z][a-zA-Z]+\(' | grep Exception
Lib/sre_constants.py:class error(Exception):
Lib/imaplib.py:    class error(Exception): pass    # Logical errors - debug 
required
Doc/faq/design.rst:   class label(Exception): pass  # declare a label
Lib/dbm/__init__.py:class error(Exception):

... there are probably others if they don't directly inherit from Exception of 
course.

There are few more lowercase exception names (all of them start with "error"):

dbm/__init__.py:38:class error(Exception):
ftplib.py:58:class error_reply(Error): pass # unexpected [123]xx reply
ftplib.py:59:class error_temp(Error): pass           # 4xx errors
ftplib.py:60:class error_perm(Error): pass           # 5xx errors
ftplib.py:61:class error_proto(Error): pass # response does not begin with [1-5] imaplib.py:180: class error(Exception): pass # Logical errors - debug required
poplib.py:31:class error_proto(Exception): pass
sre_constants.py:23:class error(Exception):

There are also several aliases:

calendar.py:21:error = ValueError
copy.py:57:error = Error   # backward compatibility
dbm/__init__.py:45:error = (error, OSError)
dbm/dumb.py:33:error = OSError
distutils/log.py:62:error = _global_log.error
getopt.py:54:error = GetoptError # backward compatibility
http/client.py:1470:error = HTTPException
re.py:181:error = sre_compile.error
test/mock_socket.py:151:error = socket_module.error
zipfile.py:51:error = BadZipfile = BadZipFile # Pre-3.2 compatibility names
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/GWRQNDTO65KNSZ4H7SHEWVEA7HIVHW4W/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to