kidok / protobuf

Automatically exported from code.google.com/p/protobuf
0 stars 0 forks source link

Python pickling depends on the path used during compilaton #680

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Extract the test files
2. Run make in the root directory followed by python test.py. It should raise 
an exception.
3. Run make in the libs directory followed by python test.py. It should work 
fine.
4. Run make in the libs/pblib directory followed by python test.py. It should 
raise an exception.

What is the expected output? What do you see instead?

I would expect the test.py script to run without exception each time.

What version of the product are you using? On what operating system?

* protobuf 2.6.0
* py27-protobuf 2.6.0
* python 2.7.8
* FreeBSD 10.0

Please provide any additional information below.

The path used during compilation seems to be convertible to a valid import 
statement in the Python application using the protobuf. For example, if the 
protobuf is compiled with 'protoc --python_out=. obj.proto' then 'import 
obj_pb2' must be valid in the python application using it.

Original issue reported on code.google.com by dbertoui...@gmail.com on 24 Nov 2014 at 9:10

Attachments:

GoogleCodeExporter commented 9 years ago
Can you post the exception stack trace?

Original comment by xiaof...@google.com on 24 Nov 2014 at 11:28

GoogleCodeExporter commented 9 years ago
In the first case (Step 2).

Traceback (most recent call last):
  File "test.py", line 11, in <module>
    cPickle.dumps(obj)
cPickle.PicklingError: Can't pickle <class 'libs.pblib.obj_pb2.ObjectA'>: 
import of module libs.pblib.obj_pb2 failed

In the third case (Step 4)

Traceback (most recent call last):
  File "test.py", line 11, in <module>
    cPickle.dumps(obj)
cPickle.PicklingError: Can't pickle <class 'obj_pb2.ObjectA'>: import of module 
obj_pb2 failed

I should also note that this seemed to be introduced in 2.6. No exceptions are 
raised when using 2.5.

Original comment by dbertoui...@gmail.com on 24 Nov 2014 at 11:36