Skip to content

history() not working in python3 or python2 #110

@priestc

Description

@priestc

This is the same as if I used ipython as if I used ipython3

$ sudo pip3 install -U pybitcointools
$ ipython3
>>> from bitcoin import history
>>> history('1PZ3Ps9RvCmUW1s1rHE25FeR8vtKUrhEai')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/usr/local/lib/python3.4/dist-packages/bitcoin/bci.py in history(*args)
    168             try:
--> 169                 jsonobj = json.loads(data)
    170             except:

/usr/lib/python3.4/json/__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    311         raise TypeError('the JSON object must be str, not {!r}'.format(
--> 312                             s.__class__.__name__))
    313     if s.startswith(u'\ufeff'):

TypeError: the JSON object must be str, not 'bytes'

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
<ipython-input-3-f52616f42edd> in <module>()
----> 1 history('1PZ3Ps9RvCmUW1s1rHE25FeR8vtKUrhEai')

/usr/local/lib/python3.4/dist-packages/bitcoin/bci.py in history(*args)
    169                 jsonobj = json.loads(data)
    170             except:
--> 171                 raise Exception("Failed to decode data: "+data)
    172             txs.extend(jsonobj["txs"])
    173             if len(jsonobj["txs"]) < 50:

TypeError: Can't convert 'bytes' object to str implicitly

I'm actually trying to build a separate python package that does exactly what history() is doing (calling an external block explorer to get utxo) I want my library to return data that is compatible with how this library's history() function works. But it appears that history() is broken? I tried updating to the latest version but the error persists.

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