diff --git a/lbrynet/core/StreamDescriptor.py b/lbrynet/core/StreamDescriptor.py index 75e2538e3..a72a39c31 100644 --- a/lbrynet/core/StreamDescriptor.py +++ b/lbrynet/core/StreamDescriptor.py @@ -1,4 +1,4 @@ -import binascii +from binascii import unhexlify import string from collections import defaultdict import json @@ -264,7 +264,7 @@ def save_sd_info(blob_manager, sd_hash, sd_info): (sd_hash, calculated_sd_hash)) stream_hash = yield blob_manager.storage.get_stream_hash_for_sd_hash(sd_hash) if not stream_hash: - log.debug("Saving info for %s", binascii.unhexlify(sd_info['stream_name'])) + log.debug("Saving info for %s", unhexlify(sd_info['stream_name'])) stream_name = sd_info['stream_name'] key = sd_info['key'] stream_hash = sd_info['stream_hash'] @@ -415,14 +415,14 @@ class EncryptedFileStreamDescriptorValidator: def info_to_show(self): info = [] - info.append(("stream_name", binascii.unhexlify(self.raw_info.get("stream_name")))) + info.append(("stream_name", unhexlify(self.raw_info.get("stream_name")))) size_so_far = 0 for blob_info in self.raw_info.get("blobs", []): size_so_far += int(blob_info['length']) info.append(("stream_size", str(self.get_length_of_stream()))) suggested_file_name = self.raw_info.get("suggested_file_name", None) if suggested_file_name is not None: - suggested_file_name = binascii.unhexlify(suggested_file_name) + suggested_file_name = unhexlify(suggested_file_name) info.append(("suggested_file_name", suggested_file_name)) return info diff --git a/lbrynet/cryptstream/client/CryptStreamDownloader.py b/lbrynet/cryptstream/client/CryptStreamDownloader.py index 9e829084c..382365ce4 100644 --- a/lbrynet/cryptstream/client/CryptStreamDownloader.py +++ b/lbrynet/cryptstream/client/CryptStreamDownloader.py @@ -1,4 +1,4 @@ -import binascii +from binascii import unhexlify import logging from lbrynet.core.client.BlobRequester import BlobRequester from lbrynet.core.client.ConnectionManager import ConnectionManager @@ -60,8 +60,8 @@ class CryptStreamDownloader: self.blob_manager = blob_manager self.payment_rate_manager = payment_rate_manager self.wallet = wallet - self.key = binascii.unhexlify(key) - self.stream_name = binascii.unhexlify(stream_name).decode() + self.key = unhexlify(key) + self.stream_name = unhexlify(stream_name).decode() self.completed = False self.stopped = True self.stopping = False diff --git a/tests/functional/test_misc.py b/tests/functional/test_misc.py index 056eb5cd6..d2a94134f 100644 --- a/tests/functional/test_misc.py +++ b/tests/functional/test_misc.py @@ -92,7 +92,7 @@ class LbryUploader(object): query_handler_factories, self.peer_manager) self.server_port = reactor.listenTCP(5553, server_factory, interface="localhost") - test_file = GenFile(self.file_size, bytes([i for i in range(0, 64, 6)])) + test_file = GenFile(self.file_size, bytes(i for i in range(0, 64, 6))) lbry_file = yield create_lbry_file(self.blob_manager, self.storage, self.prm, self.lbry_file_manager, "test_file", test_file) defer.returnValue(lbry_file.sd_hash) diff --git a/tests/functional/test_reflector.py b/tests/functional/test_reflector.py index ac178ce2f..ac2982a53 100644 --- a/tests/functional/test_reflector.py +++ b/tests/functional/test_reflector.py @@ -83,7 +83,7 @@ class TestReflector(unittest.TestCase): return d def create_stream(): - test_file = mocks.GenFile(5209343, bytes([(i + 3) for i in range(0, 64, 6)])) + test_file = mocks.GenFile(5209343, bytes((i + 3) for i in range(0, 64, 6))) d = EncryptedFileCreator.create_lbry_file( self.client_blob_manager, self.client_storage, prm, self.client_lbry_file_manager, "test_file", diff --git a/tests/functional/test_streamify.py b/tests/functional/test_streamify.py index 771fea9e1..614aaff75 100644 --- a/tests/functional/test_streamify.py +++ b/tests/functional/test_streamify.py @@ -81,7 +81,7 @@ class TestStreamify(TestCase): yield b"%016d" % iv def create_stream(): - test_file = GenFile(5209343, bytes([(i + 3) for i in range(0, 64, 6)])) + test_file = GenFile(5209343, bytes((i + 3) for i in range(0, 64, 6))) d = create_lbry_file( self.blob_manager, self.storage, self.prm, self.lbry_file_manager, "test_file", test_file, key=b'0123456701234567', iv_generator=iv_generator() @@ -95,7 +95,7 @@ class TestStreamify(TestCase): @defer.inlineCallbacks def test_create_and_combine_stream(self): - test_file = GenFile(53209343, bytes([(i + 5) for i in range(0, 64, 6)])) + test_file = GenFile(53209343, bytes((i + 5) for i in range(0, 64, 6))) lbry_file = yield create_lbry_file(self.blob_manager, self.storage, self.prm, self.lbry_file_manager, "test_file", test_file) sd_hash = yield self.storage.get_sd_blob_hash_for_stream(lbry_file.stream_hash) diff --git a/tests/mocks.py b/tests/mocks.py index 016a74aa3..1e13cb8b9 100644 --- a/tests/mocks.py +++ b/tests/mocks.py @@ -268,7 +268,7 @@ class GenFile(io.RawIOBase): def __init__(self, size, pattern): io.RawIOBase.__init__(self) self.size = size - self.pattern = pattern.encode() if not isinstance(pattern, bytes) else pattern + self.pattern = pattern self.read_so_far = 0 self.buff = b'' self.last_offset = 0 diff --git a/tests/unit/lbryfilemanager/test_EncryptedFileCreator.py b/tests/unit/lbryfilemanager/test_EncryptedFileCreator.py index 7420009f1..f2a1dfa9e 100644 --- a/tests/unit/lbryfilemanager/test_EncryptedFileCreator.py +++ b/tests/unit/lbryfilemanager/test_EncryptedFileCreator.py @@ -64,7 +64,7 @@ class CreateEncryptedFileTest(unittest.TestCase): @defer.inlineCallbacks def create_file(self, filename): - handle = mocks.GenFile(3*MB, '1') + handle = mocks.GenFile(3*MB, b'1') key = b'2' * (AES.block_size // 8) out = yield EncryptedFileCreator.create_lbry_file( self.blob_manager, self.storage, self.prm, self.lbry_file_manager, filename, handle, key, iv_generator()