GithubHelp home page GithubHelp logo

jsonrpclib's People

Contributors

domob1812 avatar efokschaner avatar joshmarshall avatar prs247au avatar quentinmit avatar rayrapetyan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jsonrpclib's Issues

TypeError: 'NoneType' object is not subscriptable

Got the following traceback:

  File "/opt/redislabs/lib/python3.9/site-packages/jsonrpclib/jsonrpc.py", line 778, in __call__
    return self.__send(self.__name, kwargs)
  File "/opt/redislabs/lib/python3.9/site-packages/jsonrpclib/jsonrpc.py", line 652, in _request
    return response["result"]
TypeError: 'NoneType' object is not subscriptable

from what I could see ServerProxy._request performs self._run_request(request), which can return None, in which case check_for_errors returns the same None, and that is accessed.

Unix socket tests failing on RHEL5, Python 2.7

$ uname -srv
Linux 2.6.18-238.1.1.el5 #1 SMP Tue Jan 4 13:32:19 EST 2011

$ python -V
Python 2.7

$ python tests.py
===============================================================
  NOTE: There may be threading exceptions after tests finish.  
===============================================================
....................EEEEEEEE
======================================================================
ERROR: test_connect (__main__.UnixSocketInternalTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 279, in test_connect
    result = client.ping()
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 276, in __call__
    return self.__send(self.__name, kwargs)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 224, in _request
    response = self._run_request(request)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 242, in _run_request
    verbose=self.__verbose
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1303, in single_request
    self.close()
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1378, in close
    if self._connection[1]:
TypeError: 'NoneType' object is not subscriptable

======================================================================
ERROR: test_multicall_failure (__main__.UnixSocketInternalTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 341, in test_multicall_failure
    result = multicall()
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 362, in _request
    responses = self._server._run_request(request_body)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 242, in _run_request
    verbose=self.__verbose
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1303, in single_request
    self.close()
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1378, in close
    if self._connection[1]:
TypeError: 'NoneType' object is not subscriptable

======================================================================
ERROR: test_multicall_success (__main__.UnixSocketInternalTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 333, in test_multicall_success
    result = multicall()
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 362, in _request
    responses = self._server._run_request(request_body)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 242, in _run_request
    verbose=self.__verbose
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1303, in single_request
    self.close()
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1378, in close
    if self._connection[1]:
TypeError: 'NoneType' object is not subscriptable

======================================================================
ERROR: test_single_args (__main__.UnixSocketInternalTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 284, in test_single_args
    result = client.add(5, 10)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 274, in __call__
    return self.__send(self.__name, args)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 224, in _request
    response = self._run_request(request)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 242, in _run_request
    verbose=self.__verbose
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1303, in single_request
    self.close()
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1378, in close
    if self._connection[1]:
TypeError: 'NoneType' object is not subscriptable

======================================================================
ERROR: test_single_kwargs (__main__.UnixSocketInternalTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 289, in test_single_kwargs
    result = client.add(x=5, y=10)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 276, in __call__
    return self.__send(self.__name, kwargs)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 224, in _request
    response = self._run_request(request)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 242, in _run_request
    verbose=self.__verbose
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1303, in single_request
    self.close()
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1378, in close
    if self._connection[1]:
TypeError: 'NoneType' object is not subscriptable

======================================================================
ERROR: test_single_kwargs_and_args (__main__.UnixSocketInternalTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 294, in test_single_kwargs_and_args
    self.assertRaises(ProtocolError, client.add, (5,), {'y':10})
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/unittest/case.py", line 456, in assertRaises
    callableObj(*args, **kwargs)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 274, in __call__
    return self.__send(self.__name, args)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 224, in _request
    response = self._run_request(request)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 242, in _run_request
    verbose=self.__verbose
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1303, in single_request
    self.close()
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1378, in close
    if self._connection[1]:
TypeError: 'NoneType' object is not subscriptable

======================================================================
ERROR: test_single_namespace (__main__.UnixSocketInternalTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 303, in test_single_namespace
    response = client.namespace.sum(1,2,4)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 274, in __call__
    return self.__send(self.__name, args)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 224, in _request
    response = self._run_request(request)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 242, in _run_request
    verbose=self.__verbose
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1303, in single_request
    self.close()
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1378, in close
    if self._connection[1]:
TypeError: 'NoneType' object is not subscriptable

======================================================================
ERROR: test_single_notify (__main__.UnixSocketInternalTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 298, in test_single_notify
    result = client._notify.add(5, 10)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 274, in __call__
    return self.__send(self.__name, args)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 231, in _request_notify
    response = self._run_request(request, notify=True)
  File "/net/noble/vol2/home/mmh1/sandbox/jsonrpclib/jsonrpclib/jsonrpc.py", line 242, in _run_request
    verbose=self.__verbose
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1303, in single_request
    self.close()
  File "/net/gs/vol3/software/modules-sw/python/2.7/Linux/RHEL5/x86_64/lib/python2.7/xmlrpclib.py", line 1378, in close
    if self._connection[1]:
TypeError: 'NoneType' object is not subscriptable

----------------------------------------------------------------------
Ran 28 tests in 0.124s

FAILED (errors=8)

recvfrom SYSCALL infinite loop

Hi,
When using jsonrpclib to build a RPC Server.
server = SimpleJSONRPCServer(('0.0.0.0', rpc_listening_port))
server.register_function(floatingip_check, 'floatingip_check')
server.serve_forever()

It's found that the RPC Server process is stucked in a recv_from infinite loop.
recvfrom(4, "", 1, 0, NULL, NULL) = 0
recvfrom(4, "", 1, 0, NULL, NULL) = 0
(output from strace)

It seems rpc server doesn't close the socket normally while recvfrom return zero which indicating the peer has performed an shutdown.

Is this a bug of jsonrpclib or I missed something to make it work.
Thanks a lot.

Using this library with Python 3.x

Can this library be supported to work for Python 3.x if certain issues are fixed? The following are the basic issues I have found. There are no compilation issues.

jsonrpc.py:
from xmlrpclib becomes from xmlrpc.client.
from httplib import HTTP, HTTPConnection becomes from http.client import HTTPConnection

SimpleJSONRPCServer.py:
SimpleXMLRPCServer becomes xmlrpc.server
ServerSocket becomes serversocket
Line 62: except Exception, e: becomes except Exception as e:

Any other changes I am missing?

Issues with __import__ in jsonclass.py

jsonclass.py uses import to import a module. It looks like it expects import to return the imported module, but it doesn't work that way for nested modules: e.g., if I import a.b.c, import returns a, not c.

I'll attach a patch to fix this.

AttributeError: 'SafeTransport' object has no attribute 'context'

I'm running into an error when running this code on python 2.7.9

import jsonrpclib
server = jsonrpclib.Server('https://<ip_addr>:<port>')
print server.foo()

And get the following stacktrace:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/lgbland/code/xmsso/venv/lib/python2.7/site-packages/jsonrpclib/jsonrpc.py", line 274, in __call__
    return self.__send(self.__name, args)
  File "/home/lgbland/code/xmsso/venv/lib/python2.7/site-packages/jsonrpclib/jsonrpc.py", line 224, in _request
    response = self._run_request(request)
  File "/home/lgbland/code/xmsso/venv/lib/python2.7/site-packages/jsonrpclib/jsonrpc.py", line 242, in _run_request
    verbose=self.__verbose
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1273, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1293, in single_request
    h = self.make_connection(host)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1509, in make_connection
    self._connection = host, HTTPS(chost, None, context=self.context, **(x509 or {}))
AttributeError: 'SafeTransport' object has no attribute 'context'

The same code works fine in python 2.7.6. Some underlying change in xmlrpclib perhaps?

No tag for 0.1.3 release

Please tag 0.1.3 in git so that packagers can easily fetch the tarball from github and not pypi (which lacks some useful files, like tests).

fcntl question

Hello Josh,

In the SimpleJSONRPCServer is see this code:

    if fcntl is not None and hasattr(fcntl, 'FD_CLOEXEC'):
        flags = fcntl.fcntl(self.fileno(), fcntl.F_GETFD)
        flags |= fcntl.FD_CLOEXEC
        fcntl.fcntl(self.fileno(), fcntl.F_SETFD, flags)

What should it do? Why are we forcing close-on-exec on the descriptor of the socket?

Thanks and regards,
Jan

memory leak

Hi,
There is a memory leak in the program client, at each call to the function

I enclosed server and client.

HTTP Error 415 Unsupported media type

The new JSONRPC API of XBMC demands the Content-Type is set on "application/json" instead of "application/json-rpc". So this lib doesn't work out-of-the-box for the XBMC API. I had to change it in the code.

Is it possible to make this a config option so developers can change this when they want?

easy_install jsonrpclib fails with error: [Errno 2] No such file or directory: 'README.md'

Looks like something went wrong after the version bump:

miranda@ubuntu:~/ir-miranda$ sudo easy_install jsonrpclib
Searching for jsonrpclib
Reading https://pypi.python.org/simple/jsonrpclib/
Best match: jsonrpclib 0.1.4
Downloading https://pypi.python.org/packages/source/j/jsonrpclib/jsonrpclib-0.1.4.tar.gz#md5=a80e95fd1f9437736e2ae894a877d7c8
Processing jsonrpclib-0.1.4.tar.gz
Writing /tmp/easy_install-OCR0tL/jsonrpclib-0.1.4/setup.cfg
Running jsonrpclib-0.1.4/setup.py -q bdist_egg --dist-dir /tmp/easy_install-OCR0tL/jsonrpclib-0.1.4/egg-dist-tmp-a6jcXZ
error: [Errno 2] No such file or directory: 'README.md'

UnicodeDecodeError because of locale settings

Issue: json rpc call gives the following error and stacktrace:

Traceback (most recent call last):
   File "C:\Python26\lib\site-packages\jsonrpclib\jsonrpc.py", line 220, in __call__
     return self.__send(self.__name, kwargs)
   File "C:\Python26\lib\site-packages\jsonrpclib\jsonrpc.py", line 167, in _request
     rpcid=rpcid, version=self.__version)
   File "C:\Python26\lib\site-packages\jsonrpclib\jsonrpc.py", line 444, in dumps
     return jdumps(request, encoding=encoding)
   File "C:\Python26\lib\site-packages\jsonrpclib\jsonrpc.py", line 90, in jdumps
     return json.dumps(obj, encoding=encoding)
   File "C:\Python26\lib\json\__init__.py", line 230, in dumps
     return _default_encoder.encode(obj)
   File "C:\Python26\lib\json\encoder.py", line 367, in encode
     chunks = list(self.iterencode(o))
   File "C:\Python26\lib\json\encoder.py", line 309, in _iterencode
     for chunk in self._iterencode_dict(o, markers):
   File "C:\Python26\lib\json\encoder.py", line 275, in _iterencode_dict
     for chunk in self._iterencode(value, markers):
   File "C:\Python26\lib\json\encoder.py", line 294, in _iterencode
     yield encoder(o)
 UnicodeDecodeError: 'utf8' codec can't decode byte 0x9c in position 1: invalid start byte

Reason: the following function generates a random id for each request ( jsonrpclib.py):

def random_id(length=8):
    import string
    import random
    random.seed()
    choices = string.lowercase+string.digits
    return_id = ''
    for i in range(length):
        return_id += random.choice(choices)
    return return_id

, where the string.lowercase attribute is used to get the letters of the id. But the
locale settings overwrite this property and the id become invalid.

Solution: use the string.ascii_lowercase attribute which contains only the ASCII letters:

 choices = string.ascii_lowercase+string.digits

Use omnijson for best json

Can I suggest that you use http://pypi.python.org/pypi/omnijson to retrieve the best json?

cjson hasn't been maintained in years (plus doesn't compile on Windows), and ujson beats the pants off it in speed anyway. If nothing else, you really ought to swap cjson for ujson throughout your library. Here's some benchmarks for Python 2.7:

G:\Oxyderkeia>python json_speed_test.py
Please wait ...
Starting json...
done: 9.36400008202
Starting ujson...
done: 1.34500002861
Starting cjson...
done: 3.60399985313
Starting pickle...
done: 10.2590000629

Thanks,
Niall

ImportError routine fixup

The import routine for cjson/json/simplejson doesn't work as expected. As written it will always require simplejson to be installed unless BOTH cjson and json are imported.

This works better:

# JSON library importing
cjson = None
json = None
try:
    import cjson
except ImportError:
    try:
        import json
    except ImportError:
        try:
            import simplejson as json
        except ImportError:
            raise ImportError('You must have the cjson, json, or simplejson ' +
                              'module(s) available.')

Incorrect exception when passing a variable of type set

import jsonrpclib

server = jsonrpclib.Server('http://localhost:5003/api')
server.any_function(any_variable=set()) #  <-- Should fail, but with a better exception

Produces the following exception which makes it difficult to troubleshoot the cause:

---> 63     module_name = inspect.getmodule(obj).__name__
     64     class_name = obj.__class__.__name__
     65     json_class = class_name

AttributeError: 'NoneType' object has no attribute '__name__'

MultiCallIterator incorrectly raises StopIteration

The __iter__ method in MultiCallIterator is a generator, using the yield statement to produce results. As such it should simply return in the end, not raise any exception. Just remove the raise StopIteration line to correct this bug.
In addition, the entire method is unnecessary, as iter() can derive it from __len__ and __getitem__.

About the efficiency for huge data transformation

Sorry for my poor English description.

Anyhow, the problem is:

I used this lib to call a published JSONRPC service, at the beginning, the speed was fast enough. While as the size of transformed data increased, the speed went more and more slowly. And at last, it took inconceivably long time to get the response, like a zombie process.

If I pressed Ctrl+C to terminate it, the result always was like that:

File "/home/work/lib/python2.7/site-packages/jsonrpclib/jsonrpc.py", line 274, in call
return self.__send(self.__name, args)
File "/home/work/lib/python2.7/site-packages/jsonrpclib/jsonrpc.py", line 224, in _request
response = self._run_request(request)
File "/home/work/lib/python2.7/site-packages/jsonrpclib/jsonrpc.py", line 242, in _run_request
verbose=self.__verbose
File "/home/work/lib/python2.7/xmlrpclib.py", line 1264, in request
return self.single_request(host, handler, request_body, verbose)
File "/home/work/lib/python2.7/xmlrpclib.py", line 1294, in single_request
response = h.getresponse(buffering=True)
File "/home/work/lib/python2.7/httplib.py", line 1030, in getresponse
response.begin()
File "/home/work/lib/python2.7/httplib.py", line 407, in begin
version, status, reason = self._read_status()
File "/home/work/lib/python2.7/httplib.py", line 365, in _read_status
line = self.fp.readline()
File "/home/work/lib/python2.7/socket.py", line 447, in readline
data = self._sock.recv(self._rbufsize)
KeyboardInterrupt

Is there any reasonable explanation, for example, buffering size, or sth...?

Thanks very much.

Fix simple typo: tempory -> temporary

Issue Type

[x] Bug (Typo)

Steps to Replicate

  1. Examine tests.py.
  2. Search for tempory.

Expected Behaviour

  1. Should read temporary.

Semi-automated issue generated by
https://github.com/timgates42/meticulous/blob/master/docs/NOTE.md

To avoid wasting CI processing resources a branch with the fix has been
prepared but a pull request has not yet been created. A pull request fixing
the issue can be prepared from the link below, feel free to create it or
request @timgates42 create the PR. Alternatively if the fix is undesired please
close the issue with a small comment about the reasoning.

https://github.com/timgates42/jsonrpclib/pull/new/bugfix_typo_temporary

Thanks.

Obtain data using a 'GET' request?

Hi!
This package looks great.
I don't know if I'm just doing things wrong, but I can't seem to get the server to return any data to me through a standard browser request.

When I go to the address in the bar in my browser that my server is listening on, I get this response:


Error response

Error code 501.

Message: Unsupported method ('GET').

Error code explanation: 501 = Server does not support this operation.


Is this an unsupported action? I need to call functions on the server with an HTTPRequest object from within Flex, ultimately. And I think that the default method of that object is 'GET'.

I hope that was clear.
Thanks!
Murphy

security

Is there a way to secure the connection?
Either with password or encryption

Thanks

Python 3 support

Is there a plan to add support for python 3?

It looks like there only should be slight modifications for that (such as handling import of xmlrpclib).

binary data in return?

We often return binary (actually complete dynamic png/jpeg images), for example:
filestring=self.GetFrame(format,size)
return xmlrpclib.Binary(filestring)
where filestring is the binary data of a full jpg or png.

however when I glue this into jsonrpclib instead of xmlrpclib, it receive end chokes (as it does with the raw binary data).
ProtocolError: (-32603, u"<type 'exceptions.UnicodeDecodeError'>:'utf8' codec can't decode byte 0x89 in position 0: invalid start byte")

There must be some way of getting such data through? from what I see the above base64 encode path should be possible? it would of course be very nice if the dest end auto-decoded it as it possible in xmlrpc. any thoughts?

jsonrpclib.SimpleJSONRPCServer fails because of missing pydoc.py

Hi,
I installed jsonrpclib-pelix 0.4.1 on my yocto system. The mode was by using source code in the tar.gz file, and the yocto build system managed the installation.

When I tried to execute a script with the following import:

from jsonrpclib.SimpleJSONRPCServer import SimpleJSONRPCServer

It failed, because it was missing a pydoc.py at /usr/lib/python3.5/sites.

Could you please help me resolve this issue?

Thank you and Best regards
Shrikumar

duplicating Content-Type header

This wasn't a problem in Python 2 where xmlrpclib used connection.putheader("Content-Type", "text/xml"). But in Python 3, where xmlrpc.client uses headers.append(("Content-Type", "text/xml")), this https://github.com/joshmarshall/jsonrpclib/blob/master/jsonrpclib/jsonrpc.py#L107 connection.putheader("Content-Type", "application/json-rpc") actually creates a second Content-Type header instead of replacing the text/xml one.

This duplicate Content-Type headers generates 400s on lighttpd.

Why must ctor args be a dict or list?

This:

class datetime(object):
    def __init__(self, args):
        self.args = args

    def __str__(self):
        return self.args

jsonrpclib.config.classes.add(datetime)

x = { "__jsonclass__": ["datetime", "2013-01-10T22:22:20"] }
result = jsonclass.load(x)
print "x: %s, result: %s" % (x, result)

returns:

# Traceback (most recent call last):
#   File ".\test.py", line 59, in <module>
#     result = jsonclass.load(x)
#   File "c:\Python27\lib\site-packages\jsonrpclib\jsonclass.py", line 140, in load
#     raise TranslationError('Constructor args must be a dict or list.')
# jsonrpclib.jsonclass.TranslationError: Constructor args must be a dict or list.

Why not this?

diff -u -r1.1 jsonclass.py
--- jsonclass.py        2013/01/14 21:51:58     1.1
+++ jsonclass.py        2013/01/14 21:52:14
@@ -137,7 +137,7 @@
     elif type(params) is types.DictType:
         new_obj = json_class(**params)
     else:
-        raise TranslationError('Constructor args must be a dict or list.')
+        new_obj = json_class(params)
     for key, value in obj.iteritems():
         if key == '__jsonclass__':
             continue

1.0 Specification error field

Spec 1.0 says that "error" must be "An Error object" without precising it.

However library assumes that "error" is returned in 2.0 spec format - with mandatory "code" and "error" keys - even if jsonrpclib.config.version is set to 1.0.

So if you connect to valid 1.0 server and get valid "error":{"reason":"something"} response you get KeyError exception instead of error content.

Lines that cause problem:
https://github.com/joshmarshall/jsonrpclib/blob/master/jsonrpclib/jsonrpc.py#L527-528

should 'history' be enabled by default?

This is basically the same issue as #46.

I too "fixed" the memory leak by adding calls to history.clear(). As far as I can tell the history code is only used for the tests, and the fact that it is enabled by default is likely causing memory leaks for anyone using this library.

Is there any reason the history code couldn't be behind an enable_history=False parameter to ServerProxy ?

Dotted attributes are always allowed

The XMLRPC library has a big warning about allowing dotted attributes:

Warning Enabling the allow_dotted_names option allows intruders to access your module’s global variables and may allow intruders to execute arbitrary code on your machine. Only use this option on a secure, closed network.

But then I see in the code for the dispatcher that you always resolve dotted attributes, potentially creating a security problem without the users knowledge. I think this is pretty grave.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.