Skip to content

Fixing the code from Python2 to python 3.6  #12

@garrisa

Description

@garrisa

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions