[CRIU] [PATCH 1/2] python lib: rename rpc.py to rpc_pb2.py

Tycho Andersen tycho.andersen at canonical.com
Fri Sep 30 08:15:47 PDT 2016


Unfortunately, newer versions of protobuf check that the file suffix ends
in _pb2.py:

sudo ./zdtm.py run -t zdtm/static/apparmor_stacking
Traceback (most recent call last):
  File "./zdtm.py", line 23, in <module>
    import criu as crpc
  File "/home/ubuntu/criu/test/criu.py", line 12, in <module>
    import rpc
  File "/home/ubuntu/criu/test/rpc.py", line 36, in <module>
    type=None),
  File "/usr/lib/python2.7/dist-packages/google/protobuf/descriptor.py", line 652, in __new__
    _message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors should not be created directly, but only retrieved from their parent.

Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
 lib/py/Makefile | 1 -
 lib/py/criu.py  | 2 +-
 test/rpc.py     | 1 -
 test/rpc_pb2.py | 1 +
 4 files changed, 2 insertions(+), 3 deletions(-)
 delete mode 120000 test/rpc.py
 create mode 120000 test/rpc_pb2.py

diff --git a/lib/py/Makefile b/lib/py/Makefile
index 582cc93..770ff88 100644
--- a/lib/py/Makefile
+++ b/lib/py/Makefile
@@ -9,7 +9,6 @@ images:
 # it is safe to rename it, dropping ugly _pb2 suffix.
 rpc.py:
 	$(Q) protoc -I=$(SRC_DIR)/images/ --python_out=./ $(SRC_DIR)/images/$(@:.py=.proto)
-	$(Q) mv $(@:.py=_pb2.py) $@
 
 clean:
 	$(Q) $(MAKE) -C images clean
diff --git a/lib/py/criu.py b/lib/py/criu.py
index 84dcefe..0ae204a 100644
--- a/lib/py/criu.py
+++ b/lib/py/criu.py
@@ -9,7 +9,7 @@ import signal
 import sys
 import struct
 
-import rpc
+import rpc_pb2 as rpc
 
 class _criu_comm:
 	"""
diff --git a/test/rpc.py b/test/rpc.py
deleted file mode 120000
index 62fc609..0000000
--- a/test/rpc.py
+++ /dev/null
@@ -1 +0,0 @@
-../lib/py/rpc.py
\ No newline at end of file
diff --git a/test/rpc_pb2.py b/test/rpc_pb2.py
new file mode 120000
index 0000000..49648ae
--- /dev/null
+++ b/test/rpc_pb2.py
@@ -0,0 +1 @@
+../lib/py/rpc_pb2.py
\ No newline at end of file
-- 
2.9.3



More information about the CRIU mailing list