jgarzik / python-bitcoinrpc

Python interface to bitcoin's JSON-RPC API
GNU Lesser General Public License v2.1
644 stars 304 forks source link

Module causes RuntimeError, most methods unusable #54

Closed dpedu closed 8 years ago

dpedu commented 8 years ago

Running in Python 3.4.3 on ubuntu linux.

Setup - copied directly from the Readme:

# python3
Python 3.4.3 (default, Oct 14 2015, 20:28:29)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
>>> import logging
>>> logging.basicConfig()
>>> logging.getLogger("BitcoinRPC").setLevel(logging.DEBUG)
>>> rpc_connection = AuthServiceProxy("http://bobby:propane@192.168.1.210:6969")

Using getinfo() causes an error:

>>> print(rpc_connection.getinfo())
DEBUG:BitcoinRPC:-1-> getinfo []
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/pbot/botenv/lib/python3.4/site-packages/bitcoinrpc/authproxy.py", line 136, in __call__
    response = self._get_response()
  File "/pbot/botenv/lib/python3.4/site-packages/bitcoinrpc/authproxy.py", line 184, in _get_response
    log.debug("<-%s- %s"%(response["id"], json.dumps(response["result"], default=EncodeDecimal)))
  File "/usr/lib/python3.4/json/__init__.py", line 237, in dumps
    **kw).encode(obj)
  File "/usr/lib/python3.4/json/encoder.py", line 192, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python3.4/json/encoder.py", line 250, in iterencode
    return _iterencode(o, 0)
  File "/pbot/botenv/lib/python3.4/site-packages/bitcoinrpc/authproxy.py", line 77, in EncodeDecimal
    return round(o, 8)
  File "/usr/lib/python3.4/decimal.py", line 1878, in __round__
    return self.quantize(exp)
  File "/usr/lib/python3.4/decimal.py", line 2572, in quantize
    return ans._fix(context)
  File "/usr/lib/python3.4/decimal.py", line 1686, in _fix
    return Decimal(self)
  File "/usr/lib/python3.4/decimal.py", line 589, in __new__
    if isinstance(value, str):
RuntimeError: maximum recursion depth exceeded while calling a Python object

getaddressesbyaccount works:

>>> rpc_connection.getaddressesbyaccount('')
DEBUG:BitcoinRPC:-2-> getaddressesbyaccount [""]
DEBUG:BitcoinRPC:<-2- ["<snip>"]
['<snip>']

But not getbalance:

>>> rpc_connection.getbalance('')
DEBUG:BitcoinRPC:-3-> getbalance [""]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/pbot/botenv/lib/python3.4/site-packages/bitcoinrpc/authproxy.py", line 136, in __call__
    response = self._get_response()
  File "/pbot/botenv/lib/python3.4/site-packages/bitcoinrpc/authproxy.py", line 184, in _get_response
    log.debug("<-%s- %s"%(response["id"], json.dumps(response["result"], default=EncodeDecimal)))
  File "/usr/lib/python3.4/json/__init__.py", line 237, in dumps
    **kw).encode(obj)
  File "/usr/lib/python3.4/json/encoder.py", line 192, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python3.4/json/encoder.py", line 250, in iterencode
    return _iterencode(o, 0)
  File "/pbot/botenv/lib/python3.4/site-packages/bitcoinrpc/authproxy.py", line 77, in EncodeDecimal
    return round(o, 8)
  File "/usr/lib/python3.4/decimal.py", line 1878, in __round__
    return self.quantize(exp)
  File "/usr/lib/python3.4/decimal.py", line 2572, in quantize
    return ans._fix(context)
  File "/usr/lib/python3.4/decimal.py", line 1686, in _fix
    return Decimal(self)
  File "/usr/lib/python3.4/decimal.py", line 589, in __new__
    if isinstance(value, str):
RuntimeError: maximum recursion depth exceeded while calling a Python object
alecalve commented 8 years ago

Should be fixed now that #39 is merged