[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: autoprop_tests.py is creating mangled test files on my system

From: Julian Foad <julianfoad_at_btopenworld.com>
Date: 2004-10-03 04:42:47 CEST

Julian Foad wrote:
>> From autoprop_tests.py:

> fd = open(os.path.join(dir, name), 'w', 0644)
> fd.write('foo\nbar\nbaz\n')
> fd.close()
>
> An example file that it creates:

> 00000000 88 84 09 08 7c ba 38 40 62 61 7a 0a |....|º8@baz.|

The third argument to 'open', at least in my version of Python, is the buffer size to use (or 1 which means line buffering). "pydoc open" doesn't say what the units of this buffer size are, or whether there are any limits, but a quick experiment finds that some sizes work and other sizes produce this corruption.

So a fix is to remove the third argument. That is enough of a fix for me and us, though it doesn't cure the root of the problem.

Patch below. Can a Python expert verify this? I'll check it in soon anyway, as I think the change is uncontroversial. If my analysis in the log message is wrong I can correct it later.

- Julian

Fix an error in the regression tests for auto-props. The error is harmless in
theory, but in some cases triggers a Python bug which causes test failures.

(The bug is that on some installations of Python, open(filename, 'w', buf_size)
with some buffer sizes, including 0644, leads to corrupt data being written to
the file by a subsequent write().)

* subversion/tests/clients/cmdline/autoprop_tests.py
  (create_test_file): Don't try to pass a file permissions mode to open(); its
    optional third argument is a buffer size.

Index: subversion/tests/clients/cmdline/autoprop_tests.py
===================================================================
--- subversion/tests/clients/cmdline/autoprop_tests.py (revision 11207)
+++ subversion/tests/clients/cmdline/autoprop_tests.py (working copy)
@@ -91,7 +91,7 @@ def create_config(config_dir, enable_fla
 def create_test_file(dir, name):
   "create a test file"
 
- fd = open(os.path.join(dir, name), 'w', 0644)
+ fd = open(os.path.join(dir, name), 'w')
   fd.write('foo\nbar\nbaz\n')
   fd.close()
 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Oct 3 04:50:04 2004

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.