##// END OF EJS Templates
Add check to skip work in versions past 3.4
Jason Grout -
Show More
@@ -8,6 +8,7 b' import os'
8 import json
8 import json
9 import struct
9 import struct
10 import warnings
10 import warnings
11 import sys
11
12
12 try:
13 try:
13 from urllib.parse import urlparse # Py 3
14 from urllib.parse import urlparse # Py 3
@@ -43,7 +44,7 b' def serialize_binary_message(msg):'
43 # don't modify msg or buffer list in-place
44 # don't modify msg or buffer list in-place
44 msg = msg.copy()
45 msg = msg.copy()
45 buffers = list(msg.pop('buffers'))
46 buffers = list(msg.pop('buffers'))
46 # for python 2, copy the buffer memoryviews to byte strings
47 if sys.version_info < (3, 4):
47 buffers = [x.tobytes() for x in buffers]
48 buffers = [x.tobytes() for x in buffers]
48 bmsg = json.dumps(msg, default=date_default).encode('utf8')
49 bmsg = json.dumps(msg, default=date_default).encode('utf8')
49 buffers.insert(0, bmsg)
50 buffers.insert(0, bmsg)
General Comments 0
You need to be logged in to leave comments. Login now