Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #46153
| Return-Path | <carlosnepomuceno@outlook.com> |
|---|---|
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'subject:error': 0.03; 'causing': 0.04; 'api.': 0.05; 'classes,': 0.05; 'elif': 0.05; 'subject:Python': 0.06; 'notice,': 0.07; 'exception.': 0.09; 'raises': 0.09; 'subject:messages': 0.09; 'throws': 0.09; 'try:': 0.09; 'python': 0.11; ':-(': 0.16; 'e.errno': 0.16; 'errno': 0.16; 'exceptions,': 0.16; 'ioerror': 0.16; 'ioerror,': 0.16; 'open()': 0.16; 'simulate': 0.16; 'subclass': 0.16; 'valueerror': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'module': 0.19; '+0000': 0.22; 'to:name:python-list@python.org': 0.22; 'error': 0.23; 'documented': 0.24; 'received:65.55.116': 0.24; 'mon,': 0.24; 'question': 0.24; "i've": 0.25; 'source': 0.25; 'least': 0.26; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'function': 0.29; 'skip:- 40': 0.29; '[1]': 0.29; 'raise': 0.29; '(like': 0.30; 'errors': 0.30; 'mode': 0.30; 'code': 0.31; 'documenting': 0.31; 'exceptions': 0.31; 'raised': 0.31; 'them?': 0.31; 'file': 0.32; 'there.': 0.32; 'themselves': 0.32; 'says': 0.33; 'url:python': 0.33; 'not.': 0.33; 'actual': 0.34; 'date:': 0.34; "i'd": 0.34; 'except': 0.35; 'something': 0.35; 'but': 0.35; 'there': 0.35; 'version': 0.36; 'raising': 0.36; 'url:org': 0.36; 'operating': 0.37; 'list': 0.37; 'email addr:python.org': 0.37; 'list.': 0.37; 'expected': 0.38; 'sometimes': 0.38; 'url:library': 0.38; 'version,': 0.38; 'to:addr:python-list': 0.38; 'subject:': 0.39; "couldn't": 0.39; '\xa0\xa0\xa0': 0.39; 'to:addr:python.org': 0.39; 'even': 0.60; 'full': 0.61; 'url:3': 0.61; 'course': 0.61; 'information': 0.63; 're:': 0.63; 'more': 0.64; 'email name:python-list': 0.65; 'details': 0.65; 'invalid': 0.68; 'subject': 0.69; 'discover': 0.82; 'find.': 0.84; 'subject:location': 0.84; '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0': 0.84; 'carlos': 0.91; 'releases.': 0.91; '2013': 0.98 |
| X-TMN | [vwFy6CDcyHCLc+rKI4NbGYVCF1QAPnf+] |
| X-Originating-Email | [carlosnepomuceno@outlook.com] |
| From | Carlos Nepomuceno <carlosnepomuceno@outlook.com> |
| To | "python-list@python.org" <python-list@python.org> |
| Subject | RE: Python error codes and messages location |
| Date | Mon, 27 May 2013 04:49:28 +0300 |
| Importance | Normal |
| In-Reply-To | <51a2ae95$0$30002$c3e8da3$5496439d@news.astraweb.com> |
| References | <51a2ae95$0$30002$c3e8da3$5496439d@news.astraweb.com> |
| Content-Type | text/plain; charset="iso-8859-1" |
| Content-Transfer-Encoding | quoted-printable |
| MIME-Version | 1.0 |
| X-OriginalArrivalTime | 27 May 2013 01:49:28.0440 (UTC) FILETIME=[6C93E780:01CE5A7C] |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2226.1369619377.3114.python-list@python.org> (permalink) |
| Lines | 86 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1369619377 news.xs4all.nl 15883 [2001:888:2000:d::a6]:51122 |
| X-Complaints-To | abuse@xs4all.nl |
| Path | csiph.com!usenet.pasdenom.info!news.stben.net!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
| Xref | csiph.com comp.lang.python:46153 |
Show key headers only | View raw
----------------------------------------
> From: steve+comp.lang.python@pearwood.info
> Subject: Re: Python error codes and messages location
> Date: Mon, 27 May 2013 00:53:41 +0000
> To: python-list@python.org
>
> On Mon, 27 May 2013 02:13:54 +0300, Carlos Nepomuceno wrote:
>
>> Where can I find all error codes and messages that Python throws (actual
>> codes and messages from exceptions raised by stdlib)?
>
> There is no list. It is subject to change from version to version,
> including point releases.
>
> Many functions and methods document which exceptions they can be expected
> to raise, or at least the *usual* exceptions, but many more do not. And
> the error messages themselves are implementation details and are subject
> to change without notice, even if the exception type is a documented part
> of the API.
>
> You can see a full list of built-in exception types in the docs:
>
> http://docs.python.org/3/library/exceptions.html
>
> but of course since they are classes, they can be subclassed, and in
> principle a function that raises (say) ValueError might sometimes raise a
> subclass of ValueError without documenting it.
>
> So the actual answer to your question is:
>
> "Read the source code."
>
>
> Sorry :-(
That's bad! I'd like to check all the IOError codes that may be raised by a function/method but the information isn't there.
Take open() for example[1]. It only says it raises an IOError exception.
I've had to try "open('','r')" to discover that Errno 22 is the one "IOError: [Errno 22] invalid mode ('r') or filename: ''"
Will I only be able to get all error codes reading the source code of open()?
Is there a way to simulate the errors instead of actually causing them? I mean not raising an instance of IOError that I create (like "raise IOError(666,'Hell happens')"), but one with the actual contents 'args = (errno, strerr)' that open() would raise?
Something like:
f=open('filename','r')
for x in range(25):
try:
f.raise_errno(x)
except IOError, e:
if e.errno == 1:
treat_err1()
continue
elif e.errno == 2:
treat_err2()
continue
...
[1] http://docs.python.org/2/library/functions.html#open
>> I've already found the module 'errno' and got a dictionary
>> (errno.errorcode) and some system error messages
>> (os.strerror(errno.ENAMETOOLONG)) but there's more I couldn't find.
>
> These are the standard C operating system and file system error codes,
> not Python exceptions.
Yes, the docs say it's from "linux/include/errno.h".
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Python error codes and messages location Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-27 02:13 +0300
Re: Python error codes and messages location Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-27 00:53 +0000
RE: Python error codes and messages location Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-27 04:49 +0300
Re: Python error codes and messages location Cameron Simpson <cs@zip.com.au> - 2013-05-27 12:02 +1000
csiph-web