[Python-Dev] Symbolic errno values in error messages
g.brandl at gmx.net
Mon May 19 22:04:41 CEST 2008
Yannick Gingras schrieb:
> "Alexandre Vassalotti" <alexandre at peadrop.com> writes:
>>>> So now I am not sure what OP is proposing. Do you want to replace 21
>>>> with EISDIR in the above?
>>> Yes, that's what I had in mind.
>> Then, check out EnvironmentError_str in Objects/exceptions.c. You
>> should be able import the errno module and fetch its errorcode
> It wasn't as hard as I expected. It's the first time that I play with
> the Python C API; I didn't expect the API to be that high level.
> I attached a patch to convert errno to its symbolic value when an
> EnvironmentError is printed. Should attach it to a ticket on
> I'm sure there is a style guide like PEP-8 for C code, feel free to
> point me to it because my patch is probably not fully style compliant.
> With Emacs, doing
> M-x c-set-style python
> doesn't seems to do the right thing. Are you all using a bunch of
> shared settings in you .emacs files?
For new-style Python C files, this style definition works well:
'((indent-tabs-mode . nil)
(fill-column . 78)
(c-basic-offset . 4)
(c-offsets-alist . ((substatement-open . 0)
(inextern-lang . 0)
(arglist-intro . +)
(knr-argdecl-intro . +)))
(c-hanging-braces-alist . ((brace-list-open)
(block-close . c-snug-do-while)))
(c-block-comment-prefix . "* "))
This is a very crude hook that auto-selects the C style depending on
whether it finds a line starting with tab in the first 3000 characters
in the file:
(defun c-select-style ()
(if (re-search-forward "^\t" 3000 t)
(add-hook 'c-mode-hook 'c-select-style)
More information about the Python-Dev