[MERGE][Win32] explicit close of file in textfile

John Arbash Meinel john at arbash-meinel.com
Thu May 4 02:05:32 BST 2006


Aaron Bentley wrote:
> This patch fixes the binary file detection by explicitly closing the
> file, which is needed on win32.
> 
> Aaron
> 
> 
> ------------------------------------------------------------------------
> 
> === modified file 'a/bzrlib/textfile.py'
> --- a/bzrlib/textfile.py	
> +++ b/bzrlib/textfile.py	
> @@ -46,4 +46,8 @@
>      """Check whether the supplied path is a text, not binary file.
>      Raise BinaryFile if a NUL occurs in the first 1024 bytes.
>      """
> -    text_file(open(path, 'rb'))
> +    try:
> +        f = open(path, 'rb')
> +        text_file(f)
> +    finally:
> +        f.close()
> 

+1 from me. Though I honestly believe that CPython will have closed the
file either by the time text_file is done, or by the time
check_text_path is done.

If you are seeing otherwise, I would be interested to hear about it.

John
=:->

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060503/0ad0477d/attachment.pgp 


More information about the bazaar mailing list