Bug#681744: [patch] fix ftbfs (1)
Hi,
the attached patch should fix the build, however there is still a test
failure in my chroot:
WARNING:root:skipping test because running on a non-multiarch system
======================================================================
ERROR: testAddAndExportKey (test_auth.TestAuthKeys)
Add an example key.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/python-apt-0.8.7ubuntu4/tests/test_auth.py", line 150, in
testAddAndExportKey
apt.auth.add_key(WHEEZY_KEY)
File
"/tmp/python-apt-0.8.7ubuntu4/build/lib.linux-x86_64-3.3/apt/auth.py",
line 195, in add_key
"--import", "-", stdin=content)
File
"/tmp/python-apt-0.8.7ubuntu4/build/lib.linux-x86_64-3.3/apt/auth.py",
line 84, in _call_apt_key_script
output, stderr = proc.communicate(content)
File "/usr/lib/python3.3/subprocess.py", line 906, in communicate
stdout, stderr = self._communicate(input, endtime, timeout)
File "/usr/lib/python3.3/subprocess.py", line 1528, in _communicate
orig_timeout)
File "/usr/lib/python3.3/subprocess.py", line 1601, in
_communicate_with_poll
self._save_input(input)
File "/usr/lib/python3.3/subprocess.py", line 1562, in _save_input
self._input = self._input.encode(self.stdin.encoding)
AttributeError: 'bytes' object has no attribute 'encode'
======================================================================
ERROR: testAddAndListKey (test_auth.TestAuthKeys)
Add an example key and test if it is correctly returned by
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/python-apt-0.8.7ubuntu4/tests/test_auth.py", line 161, in
testAddAndListKey
apt.auth.add_key(WHEEZY_KEY)
File
"/tmp/python-apt-0.8.7ubuntu4/build/lib.linux-x86_64-3.3/apt/auth.py",
line 195, in add_key
"--import", "-", stdin=content)
File
"/tmp/python-apt-0.8.7ubuntu4/build/lib.linux-x86_64-3.3/apt/auth.py",
line 84, in _call_apt_key_script
output, stderr = proc.communicate(content)
File "/usr/lib/python3.3/subprocess.py", line 906, in communicate
stdout, stderr = self._communicate(input, endtime, timeout)
File "/usr/lib/python3.3/subprocess.py", line 1528, in _communicate
orig_timeout)
File "/usr/lib/python3.3/subprocess.py", line 1601, in
_communicate_with_poll
self._save_input(input)
File "/usr/lib/python3.3/subprocess.py", line 1562, in _save_input
self._input = self._input.encode(self.stdin.encoding)
AttributeError: 'bytes' object has no attribute 'encode'
----------------------------------------------------------------------
Ran 64 tests in 6.787s
FAILED (errors=2)
=== modified file 'python/generic.h'
--- python/generic.h 2011-08-01 07:29:25 +0000
+++ python/generic.h 2012-10-23 06:57:19 +0000
@@ -80,10 +80,14 @@
static inline const char *PyUnicode_AsString(PyObject *op) {
// Convert to bytes object, using the default encoding.
+#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 3
+ return PyUnicode_AsUTF8(op);
+#else
// Use Python-internal API, there is no other way to do this
// without a memory leak.
PyObject *bytes = _PyUnicode_AsDefaultEncodedString(op, 0);
return bytes ? PyBytes_AS_STRING(bytes) : 0;
+#endif
}
// Convert any type of string based object to a const char.
Reply to: