Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WhichOneof does not work after CopyFrom in Python #147

Closed
nadavsr opened this issue Dec 26, 2014 · 4 comments
Closed

WhichOneof does not work after CopyFrom in Python #147

nadavsr opened this issue Dec 26, 2014 · 4 comments

Comments

@nadavsr
Copy link

nadavsr commented Dec 26, 2014

Test case: compile this message

message FooOrBar {
  oneof test {
    int32 foo = 1;
    int32 bar = 2;
  }
}

Run this script:

from test_pb2 import FooOrBar

a = FooOrBar()
a.foo = 3
b = FooOrBar()
b.CopyFrom(a)

assert a.WhichOneof('test') == 'foo'
assert a.HasField('foo')
assert b.HasField('foo')
assert b.WhichOneof('test') == 'foo'   # fails in 2.6.1

The last assertion should pass. We are using Python 2.7.8, Protobuf 2.6.1 installed from PyPI on Linux.

This is similar to http://code.google.com/p/protobuf/issues/detail?id=671

@xfxyjwf
Copy link
Contributor

xfxyjwf commented Dec 27, 2014

Hi, could you check if this problem persist in the current master branch? I remember it was already fixed some time ago.

@nadavsr
Copy link
Author

nadavsr commented Dec 27, 2014

Just checked. It is fixed in master. Can the fix be backported to 2.6.x?

@xfxyjwf
Copy link
Contributor

xfxyjwf commented Dec 29, 2014

No, we don't have any planned 2.6.x releases.

@ninowalker
Copy link

It looks like there is a 2.6.1 git tag in the repo: v2.6.0...v2.6.1, which includes the fix: v2.6.0...v2.6.1#diff-ce002779e95ca597120c8b0bacc0f448

While it's tagged, it seems nobody has bothered to release it. A DIY cheat sheet for PIP users:

git clone https://github.com/google/protobuf.git
cd protobuf
./autogen.sh
./configure
make
sudo make install
cd python
python setup.py build
python setup.py google_test
python setup.py sdist
pip install .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants