Alternate fixes for jython and legacy c python.#310
Conversation
Python 3.4 is not supported officially. But keep running test for a while, to know when msgpack-python stop working on Python 3.4 actually.
casting. The current patches did not work under jython-2.7.1 where implicit casting of buffer or memoryview doesn't work. It may also be the jython is a little pickier about string casting non string bytes due to the underlying strong typing of java. See issues msgpack#303 & msgpack#304. Rolls back / replaces: aa41e2f 5f684ae b10cf78
Replace jython and legacy cpython fixes with explicit type casting.
msgpack/fallback.py
Outdated
| _unpack_from = staticmethod( | ||
| struct.unpack_from if sys.version_info >= (2, 7, 6) | ||
| else lambda f,b,o=0: struct.unpack_from(f, b[:o+2].tobytes(),o) | ||
| ) |
There was a problem hiding this comment.
Use global function instead of staticmethod.
There was a problem hiding this comment.
Sorry it took so many tries. I have a head cold so it was like typing three lines of code with my toes this morning.
msgpack/fallback.py
Outdated
| process(o) | ||
| """ | ||
|
|
||
msgpack/fallback.py
Outdated
| self._buf_checkpoint = 0 | ||
|
|
||
| self._buffer += view | ||
| self._buffer += bytearray(view) |
There was a problem hiding this comment.
Doesn't this increase data copy?
There was a problem hiding this comment.
That is an interesting question. My assumption is that the inplace add / concatenation operator is doing an implicit typecast for you in the background rather than throwing TypeError in newer python, so an explicit typecast was just replacing a step that had to happen implicitly somewhere anyway. I don't actually want to read a bunch of code to verify that assumption though. I figured out that .extend() works reliably with implicit typecasting in old and new which should be about an even trade.
…rows TypeError, but .extend triggers implicit typecasting.
The original batch wasn't working for jython and seemed to be more a lack of implicit type casting in older objects and alternate implementation pythons. This seems less intrusive, more straightforward and works on jython-2.7.1.