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

Fix test_session with msgpack-1 #594

Merged
merged 1 commit into from
Dec 22, 2020
Merged

Conversation

mgorny
Copy link
Contributor

@mgorny mgorny commented Dec 22, 2020

Replace the encoding parameter with raw=False to fix test_session
with msgpack-1.0.0+. The encoding parameter was already deprecated
in msgpack-0.6.2, and raw=False is compatible with that version too.

Replace the encoding parameter with raw=False to fix test_session
with msgpack-1.0.0+.  The encoding parameter was already deprecated
in msgpack-0.6.2, and raw=False is compatible with that version too.
@davidbrochart
Copy link
Member

Thanks @mgorny. In the breaking changes in msgpack 1.0 I can see:

encoding option is removed. You can use raw=True to support old format.

Should we use raw=True?

@mgorny
Copy link
Contributor Author

mgorny commented Dec 22, 2020

That's weird. The old version said:

jupyter_client/tests/test_session.py::TestSession::test_datetimes_msgpack
  /var/tmp/jupyter_client/jupyter_client/tests/test_session.py:307: DeprecationWarning: encoding is deprecated, Use raw=False instead.
    unpack=lambda buf: msgpack.unpackb(buf, encoding='utf8'),

... and this sounds logical to me -- encoded = non-raw.

@mgorny
Copy link
Contributor Author

mgorny commented Dec 22, 2020

Also in the (old) code:

        if typ == TYPE_RAW:
            if self._encoding is not None:
                obj = obj.decode(self._encoding, self._unicode_errors)
            elif self._raw:
                obj = bytes(obj)
            else:
                obj = obj.decode('utf_8')

so raw = False is equivalent to utf-8 encoding.

@davidbrochart
Copy link
Member

Yes, they also say:

`raw=False` by default. It assumes str types are valid UTF-8 string and decode them to Python str (unicode) object.

which seems to be what we were expecting previously.
Thanks!

@davidbrochart davidbrochart merged commit 284914b into jupyter:master Dec 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants