From: Rob Browning Date: Thu, 10 Oct 2019 04:21:04 +0000 (-0500) Subject: txstat: fix for python 3 X-Git-Tag: 0.31~267 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=commitdiff_plain;h=544208fae44dfeaccb626c16f3a5c387f318d08f txstat: fix for python 3 Signed-off-by: Rob Browning --- diff --git a/Makefile b/Makefile index f4d999b..a8ad4a2 100644 --- a/Makefile +++ b/Makefile @@ -163,7 +163,8 @@ else lib/bup/t/thashsplit.py \ lib/bup/t/toptions.py \ lib/bup/t/tshquote.py \ - lib/bup/t/tvint.py + lib/bup/t/tvint.py \ + lib/bup/t/txstat.py endif # The "pwd -P" here may not be appropriate in the long run, but we diff --git a/buptest.py b/buptest.py index 22523b7..a503872 100644 --- a/buptest.py +++ b/buptest.py @@ -33,7 +33,7 @@ def no_lingering_errors(): # Assumes (of course) this file is at the top-level of the source tree -_bup_tmp = realpath(dirname(__file__) + '/t/tmp') +_bup_tmp = realpath(dirname(__file__.encode('iso-8859-1')) + b'/t/tmp') try: os.makedirs(_bup_tmp) except OSError as e: diff --git a/lib/bup/_helpers.c b/lib/bup/_helpers.c index 592c121..9078be3 100644 --- a/lib/bup/_helpers.c +++ b/lib/bup/_helpers.c @@ -1250,7 +1250,7 @@ static PyObject *bup_utimensat(PyObject *self, PyObject *args) PyObject *access_py, *modification_py; struct timespec ts[2]; - if (!PyArg_ParseTuple(args, "is((Ol)(Ol))i", + if (!PyArg_ParseTuple(args, "i" cstr_argf "((Ol)(Ol))i", &fd, &path, &access_py, &(ts[0].tv_nsec), @@ -1292,7 +1292,7 @@ static int bup_parse_xutimes_args(char **path, PyObject *access_py, *modification_py; long long access_us, modification_us; // POSIX guarantees tv_usec is signed. - if (!PyArg_ParseTuple(args, "s((OL)(OL))", + if (!PyArg_ParseTuple(args, cstr_argf "((OL)(OL))", path, &access_py, &access_us, &modification_py, &modification_us)) diff --git a/lib/bup/t/thelpers.py b/lib/bup/t/thelpers.py index d9f4704..501e8be 100644 --- a/lib/bup/t/thelpers.py +++ b/lib/bup/t/thelpers.py @@ -143,8 +143,8 @@ def test_batchpipe(): @wvtest def test_atomically_replaced_file(): with no_lingering_errors(): - with test_tempdir('bup-thelper-') as tmpdir: - target_file = os.path.join(tmpdir, 'test-atomic-write') + with test_tempdir(b'bup-thelper-') as tmpdir: + target_file = os.path.join(tmpdir, b'test-atomic-write') with atomically_replaced_file(target_file, mode='w') as f: f.write('asdf') diff --git a/lib/bup/t/txstat.py b/lib/bup/t/txstat.py index 64bad2d..d002a36 100644 --- a/lib/bup/t/txstat.py +++ b/lib/bup/t/txstat.py @@ -65,10 +65,10 @@ def test_bup_utimensat(): if not xstat._bup_utimensat: return with no_lingering_errors(): - with test_tempdir('bup-txstat-') as tmpdir: - path = tmpdir + '/foo' + with test_tempdir(b'bup-txstat-') as tmpdir: + path = tmpdir + b'/foo' open(path, 'w').close() - frac_ts = (0, 10**9 / 2) + frac_ts = (0, 10**9 // 2) xstat._bup_utimensat(_helpers.AT_FDCWD, path, (frac_ts, frac_ts), 0) st = _helpers.stat(path) atime_ts = st[8] @@ -84,10 +84,10 @@ def test_bup_utimes(): if not xstat._bup_utimes: return with no_lingering_errors(): - with test_tempdir('bup-txstat-') as tmpdir: - path = tmpdir + '/foo' + with test_tempdir(b'bup-txstat-') as tmpdir: + path = tmpdir + b'/foo' open(path, 'w').close() - frac_ts = (0, 10**6 / 2) + frac_ts = (0, 10**6 // 2) xstat._bup_utimes(path, (frac_ts, frac_ts)) st = _helpers.stat(path) atime_ts = st[8] @@ -103,10 +103,10 @@ def test_bup_lutimes(): if not xstat._bup_lutimes: return with no_lingering_errors(): - with test_tempdir('bup-txstat-') as tmpdir: - path = tmpdir + '/foo' + with test_tempdir(b'bup-txstat-') as tmpdir: + path = tmpdir + b'/foo' open(path, 'w').close() - frac_ts = (0, 10**6 / 2) + frac_ts = (0, 10**6 // 2) xstat._bup_lutimes(path, (frac_ts, frac_ts)) st = _helpers.stat(path) atime_ts = st[8]