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 -- http://mail.python.org/mailman/listinfo/python-list