Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

msgpack 1.0.0 error #648

Open
bgermann opened this issue Oct 30, 2020 · 12 comments
Open

msgpack 1.0.0 error #648

bgermann opened this issue Oct 30, 2020 · 12 comments
Assignees
Labels

Comments

@bgermann
Copy link

Running the tests with Python 3.9 gives:

self = <spyne.protocol.msgpack.MessagePackDocument object at 0x7f7bcdf3d940>
ctx = MessagePackMethodContext(
oob_ctx=None,
call_start=1603801847.689902,
call_end=None,
is_closed=False,
app=<sp...t_protocol=<spyne.protocol.msgpack.MessagePackDocument object at 0x7f7bcdf3d670>,
pusher_stack=[],
frozen=True,
))

def gen_method_request_string(self, ctx):
    """Uses information in context object to return a method_request_string.

    Returns a string in the form of "{namespaces}method name".
    """

    mrs, = ctx.in_body_doc.keys()
    if not six.PY2:
      mrs = mrs.decode('utf8')

E AttributeError: 'str' object has no attribute 'decode'

spyne/protocol/msgpack.py:152: AttributeError

See also https://bugs.debian.org/973211

@plq plq self-assigned this Oct 30, 2020
@plq plq added the Defect label Oct 30, 2020
plq added a commit to plq/spyne that referenced this issue Oct 30, 2020
@plq plq mentioned this issue Oct 30, 2020
plq added a commit to plq/spyne that referenced this issue Oct 30, 2020
@plq
Copy link
Member

plq commented Oct 30, 2020

I can't reproduce this locally with 2.3.15 code. This is probably due to a patch in debian sid's msgpack package. 21c80dd ought to fix this nevertheless.

@bgermann bgermann changed the title Python 3.9 error msgpack 1.0.0 error Oct 30, 2020
@bgermann
Copy link
Author

It is caused by the newer msgpack version 1.0.0 in sid. There are no patches involved but that version has some breaking changes. I think you can work around that by following the 1.0.0 update advise.

@plq
Copy link
Member

plq commented Oct 30, 2020

Ah, thanks for letting me know about that. The msgpack package in PyPI seems to have changed names as well, that's why Spyne CI did not catch anything.

I'll fix this and release 2.13.16 as soon as possible.

@plq
Copy link
Member

plq commented Oct 30, 2020

35edacd (master) and da03cce (2.13) should fix this

would it be possible to test the latest patches before committing to a release?

@bgermann
Copy link
Author

sure, I will give it a try. should take ~15min

@bgermann
Copy link
Author

bgermann commented Oct 30, 2020

TestMessagePackServer.test_roundtrip _______________________________________________________________________________________

self = <spyne.test.transport.test_msgpack.TestMessagePackServer testMethod=test_roundtrip>

    def test_roundtrip(self):
       v = "yaaay!"
       class SomeService(Service):
           @rpc(Unicode, _returns=Unicode)
           def yay(ctx, u):
               return u
    
       app = Application([SomeService], 'tns',
                               in_protocol=MessagePackDocument(),
                               out_protocol=MessagePackDocument())
    
       prot = self.gen_prot(app)
       request = msgpack.packb({'yay': [v]})
       prot.dataReceived(msgpack.packb([1, request]))
       val = prot.transport.value()
       print(repr(val))
       val = msgpack.unpackb(val)
       print(repr(val))
    
>      self.assertEqual(val, [0, msgpack.packb(v)])

spyne/test/transport/test_msgpack.py:61: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3/dist-packages/twisted/trial/_synctest.py:434: in assertEqual
    super(_Assertions, self).assertEqual(first, second, msg)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <spyne.test.transport.test_msgpack.TestMessagePackServer testMethod=test_roundtrip>
msg = "Lists differ: [1, b'\\x92\\xa6Server\\xaeInternal Error'] != [0, b'\\xa6yaaay!']\n\nFirst differing element 0:\n1\n0\n\n- [1, b'\\x92\\xa6Server\\xaeInternal Error']\n+ [0, b'\\xa6yaaay!']"

    def fail(self, msg=None):
        """
        Absolutely fail the test.  Do not pass go, do not collect $200.
    
        @param msg: the message that will be displayed as the reason for the
        failure
        """
>       raise self.failureException(msg)
E       twisted.trial.unittest.FailTest: Lists differ: [1, b'\x92\xa6Server\xaeInternal Error'] != [0, b'\xa6yaaay!']
E       
E       First differing element 0:
E       1
E       0
E       
E       - [1, b'\x92\xa6Server\xaeInternal Error']
E       + [0, b'\xa6yaaay!']

/usr/lib/python3/dist-packages/twisted/trial/_synctest.py:377: FailTest
---------------------------------------------------------------------------------------------- Captured stdout call -----------------------------------------------------------------------------------------------
b'\x92\x01\xc4\x17\x92\xa6Server\xaeInternal Error'
[1, b'\x92\xa6Server\xaeInternal Error']
---------------------------------------------------------------------------------------------- Captured stderr call -----------------------------------------------------------------------------------------------
DEBUG:spyne.model.complex:Got bases for yay from meta: (<class 'spyne.model.complex.ComplexModel'>,)
DEBUG:spyne.model.complex:Got bases for yayResponse from meta: (<class 'spyne.model.complex.ComplexModel'>,)
INFO:spyne.application:Initializing application {tns}Application...
DEBUG:spyne.interface._base:populating spyne.test.transport.test_msgpack.SomeService types...
DEBUG:spyne.interface._base:  enumerating classes for method 'yay'
DEBUG:spyne.interface._base:    adding class "<class 'spyne.model.complex.yay'>" for '{tns}yay'
DEBUG:spyne.interface._base:    adding yay.u = <class 'spyne.model.primitive.string.Unicode'>
DEBUG:spyne.interface._base:    adding class "<class 'spyne.model.primitive.string.Unicode'>" for '{http://www.w3.org/2001/XMLSchema}string'
DEBUG:spyne.interface._base:    adding class "<class 'spyne.model.complex.yayResponse'>" for '{tns}yayResponse'
DEBUG:spyne.interface._base:    adding yayResponse.yayResult = <class 'spyne.model.primitive.string.Unicode'>
DEBUG:spyne.interface._base:populating 'spyne.test.transport.test_msgpack.SomeService' routes...
DEBUG:spyne.interface._base:  adding method SomeService.yay to match '{tns}yay' tag.
DEBUG:spyne.interface._base:From this point on, you're not supposed to make any changes to the class and method structure of the exposed services.
WARNING:spyne.util.appreg:Overwriting application ('tns', 'Application')(<spyne.application.Application object at 0x7fbe75a4c640>).
DEBUG:spyne.server.twisted.msgpack:7fbe79fbcac0 connection made
CRITICAL:spyne.application.server:yay() missing 1 required positional argument: 'u'
Traceback (most recent call last):
  File "/home/bage/Downloads/spyne/spyne/application.py", line 165, in process_request
    ctx.out_object = self.call_wrapper(ctx)
  File "/home/bage/Downloads/spyne/spyne/application.py", line 234, in call_wrapper
    return ctx.descriptor.service_class.call_wrapper(ctx)
  File "/home/bage/Downloads/spyne/spyne/service.py", line 194, in call_wrapper
    return ctx.function(*args)
TypeError: yay() missing 1 required positional argument: 'u'

@plq
Copy link
Member

plq commented Nov 1, 2020

☹️

Can you refer me to a document that explains how to set up this testing environment? Spyne test suite is as green as it gets.

@bgermann
Copy link
Author

bgermann commented Nov 1, 2020

The error that I posted is from a Debian sid which has all of the spyne package's Build-Dependencies installed.
Tests are then run via python3 -m pytest --ignore=spyne/test/interop --ignore=examples

@bgermann
Copy link
Author

bgermann commented Nov 1, 2020

TestMessagePackServer.test_roundtrip_deferred triggers the same error.

plq added a commit to plq/spyne that referenced this issue Nov 9, 2020
debian sid test using spyne test scripts worked, switched to
debian packages. this works as well save for missing packages.
@bgermann
Copy link
Author

If you cannot reproduce the issue I suggest to release anyway. The Debian package does not have too many users and most of them do not use msgpack with it, I guess. But they will need the other Python 3 compatibility changes.

@plq
Copy link
Member

plq commented Nov 19, 2020

Sorry about the late reply

I did reproduce the bug but it gets weirder. The errors appear only when the test suite is run with

python3 -m pytest --ignore=spyne/test/interop --ignore=examples

and not the official (ie python setup.py test) way. I was not able to spend enough time to figure out why.

I'll nevertheless push a release as soon as I can manage.

@plq
Copy link
Member

plq commented Dec 19, 2020

Seems I totally forgot to post an update here.

2.13.16 was released on Nov 23rd that contains fixes made so far. I'll finalize this as soon as I have time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants