[PATCH evemu 06/11] py: Fix file opening
Peter Hutterer
peter.hutterer at who-t.net
Thu Jan 2 16:38:21 PST 2014
On Thu, Jan 02, 2014 at 10:47:56PM +0100, Daniel Martin wrote:
> The device node is the only file that needs to be opened in binary mode
> and we've to open other "device" files (like prop files) in text mode.
> Otherwise lots of conversions from bytes objects to str will be
> necessary as Python 3 handles them differently.
>
> Signed-off-by: Daniel Martin <consume.noise at gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
Cheers,
Peter
> ---
> python/evemu/__init__.py | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/python/evemu/__init__.py b/python/evemu/__init__.py
> index 3f8e801..3a1a8d4 100644
> --- a/python/evemu/__init__.py
> +++ b/python/evemu/__init__.py
> @@ -47,7 +47,7 @@ class Device(object):
> """
>
> if type(f).__name__ == 'str':
> - self._file = open(f, 'r+b')
> + self._file = open(f)
> elif type(f).__name__ == 'file':
> self._file = f
> else:
> @@ -85,7 +85,7 @@ class Device(object):
> self._evemu._call(self._evemu.get_lib().evemu_create,
> self._evemu_device,
> self._uinput)
> - return open(self._find_newest_devnode(self.name), 'r+')
> + return open(self._find_newest_devnode(self.name), 'r+b', buffering=0)
>
> def _find_newest_devnode(self, target_name):
> newest_node = (None, float(0))
> --
> 1.8.5.2
>
> _______________________________________________
> Input-tools mailing list
> Input-tools at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/input-tools
More information about the Input-tools
mailing list