Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #8359
| From | Gregory Ewing <greg.ewing@canterbury.ac.nz> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: those darn exceptions |
| Date | 2011-06-24 19:50 +1200 |
| Message-ID | <96itucFadiU1@mid.individual.net> (permalink) |
| References | <itot0b022i@news4.newsguy.com> <96gb36Fc65U1@mid.individual.net> <iu00uh2dhg@news3.newsguy.com> |
Chris Torek wrote: > I can then check the now-valid > pid via os.kill(). However, it turns out that one form of "trash" > is a pid that does not fit within sys.maxint. This was a surprise > that turned up only in testing, and even then, only because I > happened to try a ridiculously large value as one of my test cases. It appears that this situation is not unique to os.kill(), for example, >>> import os >>> os.read(999999999999999999999999, 42) Traceback (most recent call last): File "<stdin>", line 1, in <module> OverflowError: Python int too large to convert to C long In fact I'd expect it to happen any time you pass a very large int to something that's wrapping a C function. You can't really blame the wrappers for this -- it's not reasonable to expect all of them to catch out-of-range ints and do whatever the underlying function would have done if it were given an invalid argument. I think the lesson to take from this is that you should probably add OverflowError to the list of things to catch whenever you're calling a function with input that's not fully validated. -- Greg
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
those darn exceptions Chris Torek <nospam@torek.net> - 2011-06-21 01:43 +0000
Re: those darn exceptions Chris Angelico <rosuav@gmail.com> - 2011-06-21 13:19 +1000
Re: those darn exceptions Chris Torek <nospam@torek.net> - 2011-06-21 04:40 +0000
Re: those darn exceptions Ben Finney <ben+python@benfinney.id.au> - 2011-06-21 14:04 +1000
Re: those darn exceptions Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-21 09:49 +0000
Re: those darn exceptions Chris Torek <nospam@torek.net> - 2011-06-21 21:51 +0000
Re: those darn exceptions John Nagle <nagle@animats.com> - 2011-06-27 11:52 -0700
Re: those darn exceptions Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-06-23 20:16 +1200
Re: those darn exceptions Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-23 18:40 +1000
Re: those darn exceptions Chris Torek <nospam@torek.net> - 2011-06-23 18:33 +0000
Re: those darn exceptions Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-06-24 19:50 +1200
Re: those darn exceptions Chris Torek <nospam@torek.net> - 2011-06-24 18:21 +0000
Re: those darn exceptions Ben Finney <ben+python@benfinney.id.au> - 2011-06-25 10:25 +1000
Re: those darn exceptions Chris Angelico <rosuav@gmail.com> - 2011-06-25 13:55 +1000
Re: those darn exceptions steve+comp.lang.python@pearwood.info - 2011-06-26 00:28 +1000
Re: those darn exceptions Chris Angelico <rosuav@gmail.com> - 2011-06-26 01:52 +1000
csiph-web