Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing the code from Python2 to python 3.6 #12

Open
garrisa opened this issue Jun 13, 2018 · 1 comment
Open

Fixing the code from Python2 to python 3.6 #12

garrisa opened this issue Jun 13, 2018 · 1 comment

Comments

@garrisa
Copy link

garrisa commented Jun 13, 2018

Hi,

I open this issues to point out some changes that the code has to have to be able to run in python 3.6.
First, the Print ""...have to changed to Print()
then in blocktools.py,

The ord() funtion has to be removed in the line
def hashStr(bytebuffer):
return ''.join(('%02x'%ord(a)) for a in bytebuffer)
In Python 2, bytestrings are the "standard" string objects, so that indexing into one returns the character at that position (itself a string) …

Python 2.7

b'whatever'[3]
't'
… and calling ord() on the result behaves as expected:

ord(b'whatever'[3])
116
However, in Python 3, everything is different: the standard string object is a Unicode string, and bytestrings are instead sequences of integers. Because of this, indexing into a bytestring returns the relevant integer directly …

Python 3.6

b'whatever'[3]
116
… so calling ord() on that integer makes no sense

Second in the block.py

the line print("\tCoinbase Text:\t %s" % hashStr(self.prevhash).decode("utf-8"))

in python 3.6 str has no longer a decode method, so they recommend removed, but im not sure, it is right.

Its seems that its working with this changes.

Hope this help,

Thanks and kid regards,

        Iván
@tenthirtyone
Copy link
Owner

Thanks for taking the time here. I will check this out tonight and merge up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants