Tobias Columbus wrote:

> This is my first post here and I am not 100% sure if this topic 
> really belongs here.. Anyway, I'll give it a try.
> 
> I recently dealt with using vim's python omnicompletion for SAGE 
> development (see www.sagemath.org).
> In order to get SAGE working in vim I tried 
> 
> :py import sage.all
> 
> However, this fails due to the minimalistic implementation of 
> sys.stdout in vim's python interpreter (... and, to be honest, 
> due to a bug in SAGE which imports unnecessary stuff, which relies 
> on attributes that are not guaranteed to exist).
> 
> To be more precise, :py import sage.all crashes because vim's 
> sys.stdout has no 'flush' attribute. 
> I patched vim to include a dummy implementation of 
> sys.stdout.flush, which does nothing at all.
> A corresponding patch file is attached.
> 
> I wondered, if this modification could be merged into upstream?
> 
> Admittedly, the changes are quite specific and the python 
> documentation of sys.stdout states that vim's implementation is 
> 100% correct:
> 
> [...] stdout and stderr needn’t be built-in file objects: any 
> object is acceptable as long as it has a write() method that 
> takes a string argument.
> (See http://docs.python.org/library/sys.html)
> 
> However, the documentation of file.flush() also says:
> 
> [...] This may be a no-op on some file-like objects.
> (See http://docs.python.org/library/stdtypes.html#file-objects)
> 
> So it seems to me that my dummy flush implementation is alright 
> and should break no working code.

Thanks.  Looks harmless to me.  A few more lines can be omitted that you
apparently copied from OutputWrite().

I was hoping this would also fix the crash for ":python help(dir)", but
it doesn't.

-- 
No children may attend school with their breath smelling of "wild onions."
                [real standing law in West Virginia, United States of America]

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui