浏览代码

Merge pull request #3736 from jleni/fix_rbpi

Fix: Truncated Message due to "TypeError: unhashable type: 'bytearray'"
Jisi Liu 8 年之前
父节点
当前提交
30bfe36b6a
共有 2 个文件被更改,包括 2 次插入2 次删除
  1. 1 1
      python/google/protobuf/internal/decoder.py
  2. 1 1
      python/google/protobuf/internal/encoder.py

+ 1 - 1
python/google/protobuf/internal/decoder.py

@@ -181,7 +181,7 @@ def ReadTag(buffer, pos):
   while six.indexbytes(buffer, pos) & 0x80:
   while six.indexbytes(buffer, pos) & 0x80:
     pos += 1
     pos += 1
   pos += 1
   pos += 1
-  return (buffer[start:pos], pos)
+  return (six.binary_type(buffer[start:pos]), pos)
 
 
 
 
 # --------------------------------------------------------------------
 # --------------------------------------------------------------------

+ 1 - 1
python/google/protobuf/internal/encoder.py

@@ -418,7 +418,7 @@ def _VarintBytes(value):
 def TagBytes(field_number, wire_type):
 def TagBytes(field_number, wire_type):
   """Encode the given tag and return the bytes.  Only called at startup."""
   """Encode the given tag and return the bytes.  Only called at startup."""
 
 
-  return _VarintBytes(wire_format.PackTag(field_number, wire_type))
+  return six.binary_type( _VarintBytes(wire_format.PackTag(field_number, wire_type)) )
 
 
 # --------------------------------------------------------------------
 # --------------------------------------------------------------------
 # As with sizers (see above), we have a number of common encoder
 # As with sizers (see above), we have a number of common encoder