Two patches for the Python code

2 views
Skip to first unread message

ku...@deine-taler.de

unread,
Jul 25, 2008, 4:55:04 PM7/25/08
to Protocol Buffers
What is the official way to submit patches? Here are two small ones
that I would like to suggest:

--- a/python/google/protobuf/internal/output_stream.py
+++ b/python/google/protobuf/internal/output_stream.py
@@ -101,11 +101,10 @@ class OutputStream(object):
while True:
bits = unsigned_value & 0x7f
unsigned_value >>= 7
- if unsigned_value:
- bits |= 0x80
- self._buffer.append(bits)
if not unsigned_value:
+ self._buffer.append(bits)
break
+ self._buffer.append(0x80|bits)


The two tests inside the loop are doing actually the same, by calling
the append at two separate places, only one test is required.

--- a/python/google/protobuf/internal/wire_format.py
+++ b/python/google/protobuf/internal/wire_format.py
@@ -87,7 +87,7 @@ def ZigZagEncode(value):
"""
if value >= 0:
return value << 1
- return ((value << 1) ^ (~0)) | 0x1
+ return (value << 1) ^ (~0)

The adding of the 0x1 bit is unnecessary because the xor operation
already sets the bit.

Both patches have been applied to revision 24 of the svn trunk and
tested using the unit tests provided with the code.

Uli

Kenton Varda

unread,
Jul 25, 2008, 5:11:04 PM7/25/08
to ku...@deine-taler.de, Protocol Buffers
Thanks for the patches.  Before I can apply them, I need you to sign the Contributor License Agreement.  If you did this work on your own time, you can sign the individual license electronically by just filling out the web form at the bottom of this page:

If you did it on your employer's time, they will need to sign the corporate agreement and fax or e-mail it to us:


Yes, the red tape is silly for such a small patch but law is, well, law.

Kenton Varda

unread,
Jul 27, 2008, 2:43:25 PM7/27/08
to ku...@deine-taler.de, Protocol Buffers
(this patches have been applied and committed)

On Fri, Jul 25, 2008 at 1:55 PM, <ku...@deine-taler.de> wrote:
Reply all
Reply to author
Forward
0 new messages