Skip to content

Commit af06957

Browse files
committed
python3 compatibility
1 parent 1a5d561 commit af06957

4 files changed

Lines changed: 17 additions & 11 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
dist
1+
dist
2+
testing.py

__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pass

cashaddress/convert.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from cashaddress.crypto import *
22
from base58 import b58decode_check, b58encode_check
3+
import sys
34

45

56
class InvalidAddress(Exception):
@@ -43,9 +44,14 @@ def cash_address(self):
4344

4445
@staticmethod
4546
def code_list_to_string(code_list):
46-
output = ''
47-
for code in code_list:
48-
output += chr(code)
47+
if sys.version_info > (3, 0):
48+
output = bytes()
49+
for code in code_list:
50+
output += bytes([code])
51+
else:
52+
output = ''
53+
for code in code_list:
54+
output += chr(code)
4955
return output
5056

5157
@staticmethod
@@ -57,8 +63,6 @@ def _address_type(address_type, version):
5763

5864
@staticmethod
5965
def from_string(address_string):
60-
if not isinstance(address_string, str):
61-
raise InvalidAddress('Expected string as input')
6266
if ':' not in address_string:
6367
return Address._legacy_string(address_string)
6468
else:
@@ -72,8 +76,8 @@ def _legacy_string(address_string):
7276
raise InvalidAddress('Could not decode legacy address')
7377
version = Address._address_type('legacy', decoded[0])[0]
7478
payload = list()
75-
for letter in str(decoded[1:]):
76-
payload.append(ord(letter))
79+
for letter in decoded[1:]:
80+
payload.append(letter)
7781
return Address(version, payload)
7882

7983
@staticmethod

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
from setuptools import find_packages
33

44
setup(name='cashaddress',
5-
version='1.0.0',
5+
version='1.0.1',
66
packages=find_packages(),
77
install_requires=['base58==0.2.5'],
88
description='Python tool for converty bitcoin cash legacy addresses',
99
author='Oskar Hladky',
1010
author_email='oskyks1@gmail.com',
1111
url='https://github.com/oskyk/cashaddress',
12-
download_url='https://github.com/oskyk/cashaddress/archive/1.0.0.tar.gz',
13-
python_requires='>=2.7,<3',
12+
download_url='https://github.com/oskyk/cashaddress/archive/1.0.1.tar.gz',
13+
python_requires='>=2.7',
1414
keywords=['bitcoincash', 'bch', 'address', 'cashaddress', 'legacy', 'convert']
1515
)

0 commit comments

Comments
 (0)