From e27aaf01e742c8e66364ae367780ba281d1b01f6 Mon Sep 17 00:00:00 2001 From: Tim Allen Date: Mon, 14 Feb 2011 22:41:43 +1100 Subject: [PATCH] Make redo read byte-strings from the database. By default, the database redo uses to store file state returns filenames as Unicode strings, and if redo tries to run a build-script whose fully-qualified path contains non-ASCII characters then redo crashes when trying to promote the path to a Unicode string. This patch ensures that the database always returns byte-strings, not Unicode strings. That way, the fully-qualified path and the target name are both byte-strings and can be joined without issue. (Fixes a bug reported by Zoran Zaric.) --- state.py | 1 + t/test-uniçøðë/test1.do | 0 t/test.do | 3 ++- t/unicode.do | 2 ++ 4 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 t/test-uniçøðë/test1.do create mode 100644 t/unicode.do diff --git a/state.py b/state.py index e38cf29..84eecf7 100644 --- a/state.py +++ b/state.py @@ -15,6 +15,7 @@ def _connect(dbfile): _db = sqlite3.connect(dbfile, timeout=TIMEOUT) _db.execute("pragma synchronous = off") _db.execute("pragma journal_mode = PERSIST") + _db.text_factory = str return _db diff --git a/t/test-uniçøðë/test1.do b/t/test-uniçøðë/test1.do new file mode 100644 index 0000000..e69de29 diff --git a/t/test.do b/t/test.do index 65538e3..41c0acc 100644 --- a/t/test.do +++ b/t/test.do @@ -3,4 +3,5 @@ redo-ifchange all redo nonshelltest shelltest \ deltest deltest2 test.args test2.args passfailtest chdirtest \ curse/test deps/test "space dir/test" modetest makedir2 \ - silencetest touchtest stamp/test alwaystest ifcreate-test + silencetest touchtest stamp/test alwaystest ifcreate-test \ + unicode diff --git a/t/unicode.do b/t/unicode.do new file mode 100644 index 0000000..309ed02 --- /dev/null +++ b/t/unicode.do @@ -0,0 +1,2 @@ +# Test that redo can handle a script whose path contains non-ASCII characters. +redo test-uniçøðë/test1