Skip to content

JSONRPCError.error_respond maybe missing underscore? #116

Description

@mike-hart
Python 3.11.1 (main, Dec 16 2022, 10:08:20) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tinyrpc.protocols.jsonrpc as jrpc
>>> response = jrpc.JSONRPCErrorResponse()
>>> response.error = "something went wrong"
>>> response._jsonrpc_error_code = -3
>>> response.unique_id = 1
>>> err = jrpc.JSONRPCError(response)
>>> err.error_respond()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".venv/lib/python3.11/site-packages/tinyrpc/protocols/jsonrpc.py", line 114, in error_respond
    response._jsonrpc_error_code = self.jsonrpc_error_code
                                   ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'JSONRPCError' object has no attribute 'jsonrpc_error_code'. Did you mean: '_jsonrpc_error_code'?

Is it that https://github.com/mbr/tinyrpc/blob/master/tinyrpc/protocols/jsonrpc.py#L174 (and line 180) need to lose the leading _ on assignment to self._jsonrpc_error_code so that JSONRPCError is aligned with the existing exception types above it (like JSONRPCServerError) which have a jsonrpc_error_code class attribute?

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