bumptech/palm — pull request #12 by dowski (2012-06-07 14:31:06+00:00)
Title: Fix For False Modifying Bug

The bug is that the `_evermod` flag gets set to `True` whenever a repeated field is accessed. See the test in the first commit. It was failing.

This leads to extra work when calling `.dumps()` on truly unmodified protobufs (there's an optimization that just uses the bytes if `_evermod == False`) and also false information when applications make the `modified()` API call on proto objects.

The fix involves a change to the `_set_` method on generated code and the `ProtoBase._get_repeated` method.

The `_set_` method now takes a `modifying` keyword argument that defaults to `True`. That passes through to `_evermod` so that standard `setattr/__setattr__` behavior continues to set `_evermod = True`.

`ProtoBase._get_repeated` now calls `_set_` with `modifying=False` since it is simply initiating the state for that field and not doing any modifying of the data.