Yannick Gingras schrieb:
"Alexandre Vassalotti" <[EMAIL PROTECTED]> 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
dictionary.

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
bugs.python.org?

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:

(c-add-style
 "python-new"
 '((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)
                              (brace-list-intro)
                              (brace-list-close)
                              (brace-entry-open)
                              (substatement-open after)
                              (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 ()
  (save-excursion
    (if (re-search-forward "^\t" 3000 t)
        (c-set-style "python")
      (c-set-style "python-new"))))
(add-hook 'c-mode-hook 'c-select-style)

HTH,
Georg

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to