From 73b6055fb1c5e21d186cb1765574cbb903a852b2 Mon Sep 17 00:00:00 2001 From: cclauss Date: Sat, 12 Jan 2019 01:33:37 +0100 Subject: [PATCH 1/2] Builtin 'file' was removed in Python 3 --- adb/adb_commands.py | 5 +++++ adb/filesync_protocol.py | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/adb/adb_commands.py b/adb/adb_commands.py index f3667c8..b45eb5a 100644 --- a/adb/adb_commands.py +++ b/adb/adb_commands.py @@ -31,6 +31,11 @@ from adb import common from adb import filesync_protocol +try: + file # Python 2 +except NameError: # Python 3 + file = io.BaseIO + # From adb.h CLASS = 0xFF SUBCLASS = 0x42 diff --git a/adb/filesync_protocol.py b/adb/filesync_protocol.py index d0547f4..75622d8 100644 --- a/adb/filesync_protocol.py +++ b/adb/filesync_protocol.py @@ -28,6 +28,12 @@ from adb import adb_protocol from adb import usb_exceptions +try: + file # Python 2 +except NameError: # Python 3 + import io + file = io.BaseIO + # Default mode for pushed files. DEFAULT_PUSH_MODE = stat.S_IFREG | stat.S_IRWXU | stat.S_IRWXG # Maximum size of a filesync DATA packet. From fae562324423247e58d2330882cfa1fe07a62d4e Mon Sep 17 00:00:00 2001 From: cclauss Date: Sat, 12 Jan 2019 01:46:13 +0100 Subject: [PATCH 2/2] x --- adb/adb_commands.py | 2 +- adb/filesync_protocol.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/adb/adb_commands.py b/adb/adb_commands.py index b45eb5a..eed370f 100644 --- a/adb/adb_commands.py +++ b/adb/adb_commands.py @@ -34,7 +34,7 @@ try: file # Python 2 except NameError: # Python 3 - file = io.BaseIO + file = io.IOBase # From adb.h CLASS = 0xFF diff --git a/adb/filesync_protocol.py b/adb/filesync_protocol.py index 75622d8..599c499 100644 --- a/adb/filesync_protocol.py +++ b/adb/filesync_protocol.py @@ -32,7 +32,7 @@ file # Python 2 except NameError: # Python 3 import io - file = io.BaseIO + file = io.IOBase # Default mode for pushed files. DEFAULT_PUSH_MODE = stat.S_IFREG | stat.S_IRWXU | stat.S_IRWXG