Undefined behaviour in C [was Re: The Cost of Dynamism]

Chris Angelico rosuav at gmail.com
Sat Mar 26 17:58:42 EDT 2016


On Sun, Mar 27, 2016 at 4:43 AM, Rustom Mody <rustompmody at gmail.com> wrote:
> On Saturday, March 26, 2016 at 4:09:41 PM UTC+5:30, Steven D'Aprano wrote:
>> On Sat, 26 Mar 2016 04:30 pm, Rustom Mody wrote:
>>
>> > For one thing its good to remember that we wouldn't be here without python
>> > Python wouldn't be what it is without CPython
>>
>> There is nothing about Python that relies on the C standard being as it is.
>
> Um lets see...
> There is this nice piece of OO called the exception hierarchy:
> https://docs.python.org/2/library/exceptions.html#exception-hierarchy
>
> So we have
> BaseException ⊇ Exception ⊇ EnvironmentError ⊇ IOError
> At this point it would have been completely natural for IOError to continue
> subclassing to all the typical errors
> - File not found
> - No Space left on device
> etc etc
>
> But instead we have an integer errno and we must inquire what that is to
> figure out what the exact IOError was
> Are you suggesting that python's errno module:
> https://docs.python.org/2/library/errno.html
> And C's http://man7.org/linux/man-pages/man3/errno.3.html
> are coincidentally related?

You're reading documentation that's aimed at C programmers for the
same reason as above - aiming at C makes it accessible to the most
people. But errno is not inherently bound to C; if I were to build a
language interpreter in Fortran, I could make errno available to it.
What you're looking at isn't so much a C thing as a Linux thing;
Python makes available the Linux error code as a means of
disambiguating similar errors.

ChrisA



More information about the Python-list mailing list