[MERGE] fix non-ascii messages handling in 'missing' command
Alexander Belchenko
bialix at ukr.net
Wed Jun 28 21:40:37 BST 2006
John Arbash Meinel пишет:
> I really don't like swallowing the exception this way, but if win32
> python is going to raise IOError with errno = 0 and text 'Error', there
> isn't much we can do. They aren't raising EPIPE, and it seems to be
> EINVAL to call flush() on sys.stdout once the pipe is gone.
>
> We could remove the sys.stdout.flush() call, but the whole point is to
> force something like EPIPE to be handled inside the exception handlers,
> rather than while the stack is unwinding at the end.
>
> I'll have to think of a way to test this. 'less' does exist on win32, so
> it might be sufficient to call run_bzr_subprocess with the output piped
> into less. It's just tricky to force real win32 errors in the current
> test suite.
Well, actually on win32 by default exists only 'more' pager. I've
install 'less' manually from http://gnuwin32.sf.net project. On other
hand -- when 'more' used the same error with pipe is raised.
> ------------------------------------------------------------------------
>
> === modified file 'bzrlib/commands.py'
> --- bzrlib/commands.py 2006-06-20 05:32:16 +0000
> +++ bzrlib/commands.py 2006-06-28 19:54:25 +0000
> @@ -669,7 +669,8 @@
> if not hasattr(e, 'errno'):
> raise
> if e.errno != errno.EPIPE:
> - raise
> + if sys.platform != 'win32' or e.errno != 0:
> + raise
> pass
> except KeyboardInterrupt:
> pass
> @@ -692,7 +693,14 @@
> return run_bzr(argv)
> finally:
> # do this here inside the exception wrappers to catch EPIPE
> - sys.stdout.flush()
> + if sys.platform != 'win32':
> + sys.stdout.flush()
> + else:
> + try:
> + sys.stdout.flush()
> + except IOError, e:
> + if e.errno != errno.EINVAL:
> + raise
> except Exception, e:
> # used to handle AssertionError and KeyboardInterrupt
> # specially here, but hopefully they're handled ok by the logger now
>
This changes seems reasonable for me.
--
Alexander
P.S. My preferred nick as short name is 'bialix'. You can use it for pqm
stuff.
More information about the bazaar
mailing list