Closed mathieui closed 9 years ago
Hi mathieui and thanks for the pull request! Funny enough I was working on this exact same issue when I saw the notification of your pull request :-).
As you can see from my most recent commit (9d516b0962d2dfd3ac5f57624d8878bb8ad8474e) I was struggling to understand the interaction between Python 2.x, Python 3.x, the SQLite module and UTF-8 encoding.
Travis CI says that your change fixes Python 3.4 support and retains Python 2.x support but I was experimenting with removing the str()
call myself as well and in my local testing with Tox it fails on Python 2.6 and Python 2.7, as follows:
Traceback (most recent call last):
File "/home/peter/projects/python/deb-pkg-tools/deb_pkg_tools/cli.py", line 146, in main
cache.collect_garbage()
File "/home/peter/projects/python/deb-pkg-tools/deb_pkg_tools/cache.py", line 178, in collect_garbage
delete_cursor.execute('delete from package_cache where pathname = ?', (package.pathname,))
File "/home/peter/projects/python/deb-pkg-tools/.tox/py26/lib/python2.6/site-packages/cached_property.py", line 49, in __get__
value = self.func(obj)
File "/home/peter/projects/python/deb-pkg-tools/deb_pkg_tools/cache.py", line 297, in pathname
return self['pathname'].decode(self.cache.character_encoding)
AttributeError: 'buffer' object has no attribute 'decode'
Traceback (most recent call last):
File "/home/peter/projects/python/deb-pkg-tools/deb_pkg_tools/cli.py", line 146, in main
cache.collect_garbage()
File "/home/peter/projects/python/deb-pkg-tools/deb_pkg_tools/cache.py", line 175, in collect_garbage
delete_cursor.execute('delete from package_cache where pathname = ?', (package.pathname,))
File "/home/peter/projects/python/deb-pkg-tools/.tox/py27/local/lib/python2.7/site-packages/cached_property.py", line 49, in __get__
value = self.func(obj)
File "/home/peter/projects/python/deb-pkg-tools/deb_pkg_tools/cache.py", line 289, in pathname
return self['pathname'].decode(self.cache.character_encoding)
AttributeError: 'buffer' object has no attribute 'decode'
I've now merged your pull request but changed the implementation to use codecs.decode()
. According to my Tox based testing this works on Python 2.6, Python 2.7, Python 3.4 and PyPy. Let's hope Travis CI agrees :-).
Thanks again for the contribution! I've released this change as deb-pkg-tools 1.29.4 on PyPI and GitHub.
Thanks again for the prod, Travis CI just confirmed that Python 3.4 compatibility has been restored. The build is green again :-).
Thanks a lot, that was fast :)
I haven't tested this on python 2 yet, though.