[PATCH] Fix for Bug #5807
Yuya Nishihara
yuya at tcha.org
Thu Mar 1 23:14:49 EST 2018
On Thu, 1 Mar 2018 11:06:59 +0100, Sascha Nemecek wrote:
> # HG changeset patch
> # User Sascha Nemecek <nemecek at wienfluss.net>
> # Date 1519831479 -3600
> # Wed Feb 28 16:24:39 2018 +0100
> # Node ID 42ddf4ee4f91d76f19ca0c3efc4c8e4c1c6fa96c
> # Parent 1bd132a021dd00f96604e33a8fb5306d37e56007
> Don't close 'fp' (= 'ui.fout') stream to prevent 'ValueError: I/O
> operation on closed file' (Bug #5807).
>
> Regression of changeset 30261:6bed17ba00a1
> (https://www.mercurial-scm.org/repo/hg/rev/6bed17ba00a1)
>
> diff -r 1bd132a021dd -r 42ddf4ee4f91 hgext/convert/subversion.py
> --- a/hgext/convert/subversion.py Wed Feb 21 14:36:42 2018 +0530
> +++ b/hgext/convert/subversion.py Wed Feb 28 16:24:39 2018 +0100
> @@ -149,7 +149,7 @@
> pickle.dump(str(inst), fp, protocol)
> else:
> pickle.dump(None, fp, protocol)
> - fp.close()
> + fp.flush()
> # With large history, cleanup process goes crazy and suddenly
> # consumes *huge* amount of memory. The output file being closed,
> # there is no need for clean termination.
I don't think fp.close() was the source of the problem. Here the process
_exit()s so no cleanup would be run.
I suspect that some hidden bug was disclosed by the change 3a4c0905f357,
"util: always force line buffered stdout when stdout is a tty." Before,
ui.fout.close() just called fflush() because sys.stdout.close() doesn't
close the underlying file stream. This no longer applies to the current
ui.fout as it is created by fdopen(1).
More information about the Mercurial-devel
mailing list