On Wed, 24 Aug 2016 13:29:01 +0200
Antonio Ospite <a...@ao2.it> wrote:

> Package: python-protobuf
> Followup-For: Bug #835271
> 
> Dear Maintainer,
> 
> this bug affects also all the software using python-axolotl like for
> instance gajim.
> 
> For now I worked around the issue by downgrading to python-protobuf_2.6.1-2
> which is still available in the archives:
> http://debian.sil.at/debian/pool/main/p/protobuf/
> 
> The reason why the OP does not see the issue in PyPy is in the code:
> https://github.com/google/protobuf/blob/2fe0556c7abbe31c02147b9171397737a35bfe3b/python/google/protobuf/pyext/descriptor.cc#L94
> 
> These new checks in 3.0.x (mainly that the file ends with "_pb2.py") are
> not executed when the module is compiled for PyPy.
> 
> The problem may as well be in python-axolotl, I see that in
> /usr/lib/python2.7/dist-packages/axolotl/protocol/whisperprotos.py both
> descriptor and descriptor_pb2 are imported, but apparently with protobuf
> 3.0.x only the second one is supposed to be used directly.
> 
> Any idea about how to proceed from here?

OK, the issue is not directly about descriptor_pb2, but about the code
which uses protobuf in axolotl.

Basically newer protobuf version (when NOT using PyPy) check that the
generated protocol files still have the _pb2 suffix, in the case of
axolotl these are the files generated from axolotl/protobuf/*.proto,
namely axolotl/protocol/whisperprotos.py and
axolotl/state/storageprotos.py; renaming these to keep the _pb2
suffix fixes the issue.

See the attached patch, it's against
https://github.com/tgalal/python-axolotl.git and after applying it the
tests pass again.

I am going to submit a bug report to upstream python-axolotl as soon as
you confirm that the fix works for you too.

Thanks,
   Antonio

-- 
Antonio Ospite
http://ao2.it

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?
>From 79146a47d21c826d4c3aee8a6af5a6004a670677 Mon Sep 17 00:00:00 2001
From: Antonio Ospite <a...@ao2.it>
Date: Thu, 25 Aug 2016 09:53:26 +0200
Subject: [PATCH] Keep the _pb2 suffix in the name for protobuf generated files
X-Face: z*RaLf`X<@C75u6Ig9}{oW$H;1_\2t5)({*|jhM<pyWR#k60!#=#>/Vb;]yA5<GWI5`6u&+
 ;6b'@y|8w"wB;4/e!7wYYrcqdJFY,~%Gk_4]cq$Ei/7<j&N3ah(m`ku?pX.&+~:_/wC~dwn^)MizBG
 !pE^+iDQQ1yC6^,)YDKkxDd!T>\I~93>J<_`<4)A{':UrE

In protobuf 3+ there is a check to verify that the files generated by
protoc still have the _pb2 prefix:
https://github.com/google/protobuf/blob/2fe0556c7abbe31c02147b9171397737a35bfe3b/python/google/protobuf/pyext/descriptor.cc#L94

When the suffix is not there, trying to use the generated protocols
fails with this message:

  File "/usr/lib/python2.7/dist-packages/google/protobuf/descriptor.py", line 501, in __new__
      _message.Message._CheckCalledFromGeneratedFile()
  TypeError: Descriptors should not be created directly, but only retrieved from their parent.

So rename the generated files to keep the suffix, and adjust the user
code accordingly.
---
 axolotl/groups/state/senderkeyrecord.py                     | 2 +-
 axolotl/groups/state/senderkeystate.py                      | 2 +-
 axolotl/identitykeypair.py                                  | 2 +-
 axolotl/protocol/keyexchangemessage.py                      | 2 +-
 axolotl/protocol/prekeywhispermessage.py                    | 2 +-
 axolotl/protocol/senderkeydistributionmessage.py            | 2 +-
 axolotl/protocol/senderkeymessage.py                        | 2 +-
 axolotl/protocol/whispermessage.py                          | 2 +-
 axolotl/protocol/{whisperprotos.py => whisperprotos_pb2.py} | 0
 axolotl/state/prekeyrecord.py                               | 2 +-
 axolotl/state/sessionrecord.py                              | 2 +-
 axolotl/state/sessionstate.py                               | 2 +-
 axolotl/state/signedprekeyrecord.py                         | 2 +-
 axolotl/state/{storageprotos.py => storageprotos_pb2.py}    | 0
 14 files changed, 12 insertions(+), 12 deletions(-)
 rename axolotl/protocol/{whisperprotos.py => whisperprotos_pb2.py} (100%)
 rename axolotl/state/{storageprotos.py => storageprotos_pb2.py} (100%)

diff --git a/axolotl/groups/state/senderkeyrecord.py b/axolotl/groups/state/senderkeyrecord.py
index 1f74887..6adf7a2 100644
--- a/axolotl/groups/state/senderkeyrecord.py
+++ b/axolotl/groups/state/senderkeyrecord.py
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-from ...state.storageprotos import SenderKeyRecordStructure
+from ...state.storageprotos_pb2 import SenderKeyRecordStructure
 from .senderkeystate import SenderKeyState
 from ...invalidkeyidexception import InvalidKeyIdException
 
diff --git a/axolotl/groups/state/senderkeystate.py b/axolotl/groups/state/senderkeystate.py
index c70129a..c247fca 100644
--- a/axolotl/groups/state/senderkeystate.py
+++ b/axolotl/groups/state/senderkeystate.py
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-from ...state import storageprotos
+from ...state import storageprotos_pb2 as storageprotos
 from ..ratchet.senderchainkey import SenderChainKey
 from ..ratchet.sendermessagekey import SenderMessageKey
 from ...ecc.curve import Curve
diff --git a/axolotl/identitykeypair.py b/axolotl/identitykeypair.py
index 47a318c..c577f08 100644
--- a/axolotl/identitykeypair.py
+++ b/axolotl/identitykeypair.py
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-from .state.storageprotos import IdentityKeyPairStructure
+from .state.storageprotos_pb2 import IdentityKeyPairStructure
 from .identitykey import IdentityKey
 from .ecc.curve import Curve
 
diff --git a/axolotl/protocol/keyexchangemessage.py b/axolotl/protocol/keyexchangemessage.py
index 3966f51..3cd789d 100644
--- a/axolotl/protocol/keyexchangemessage.py
+++ b/axolotl/protocol/keyexchangemessage.py
@@ -2,7 +2,7 @@
 
 from .ciphertextmessage import CiphertextMessage
 from ..util.byteutil import ByteUtil
-from . import whisperprotos
+from . import whisperprotos_pb2 as whisperprotos
 from ..legacymessageexception import LegacyMessageException
 from ..invalidversionexception import InvalidVersionException
 from ..invalidmessageexception import InvalidMessageException
diff --git a/axolotl/protocol/prekeywhispermessage.py b/axolotl/protocol/prekeywhispermessage.py
index 9ce3663..4b63278 100644
--- a/axolotl/protocol/prekeywhispermessage.py
+++ b/axolotl/protocol/prekeywhispermessage.py
@@ -11,7 +11,7 @@ from ..invalidversionexception import InvalidVersionException
 from ..invalidmessageexception import InvalidMessageException
 from ..legacymessageexception import LegacyMessageException
 from ..invalidkeyexception import InvalidKeyException
-from . import whisperprotos
+from . import whisperprotos_pb2 as whisperprotos
 
 
 class PreKeyWhisperMessage(CiphertextMessage):
diff --git a/axolotl/protocol/senderkeydistributionmessage.py b/axolotl/protocol/senderkeydistributionmessage.py
index 6a47445..326fb45 100644
--- a/axolotl/protocol/senderkeydistributionmessage.py
+++ b/axolotl/protocol/senderkeydistributionmessage.py
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 
 from .ciphertextmessage import CiphertextMessage
-from . import whisperprotos
+from . import whisperprotos_pb2 as whisperprotos
 from ..util.byteutil import ByteUtil
 from ..legacymessageexception import LegacyMessageException
 from ..invalidmessageexception import InvalidMessageException
diff --git a/axolotl/protocol/senderkeymessage.py b/axolotl/protocol/senderkeymessage.py
index 70f3bb5..d2a9d44 100644
--- a/axolotl/protocol/senderkeymessage.py
+++ b/axolotl/protocol/senderkeymessage.py
@@ -6,7 +6,7 @@ from ..legacymessageexception import LegacyMessageException
 from ..invalidmessageexception import InvalidMessageException
 from ..invalidkeyexception import InvalidKeyException
 from ..ecc.curve import Curve
-from . import whisperprotos
+from . import whisperprotos_pb2 as whisperprotos
 
 
 class SenderKeyMessage(CiphertextMessage):
diff --git a/axolotl/protocol/whispermessage.py b/axolotl/protocol/whispermessage.py
index e965d51..b2e4c12 100644
--- a/axolotl/protocol/whispermessage.py
+++ b/axolotl/protocol/whispermessage.py
@@ -6,7 +6,7 @@ import hashlib
 from .ciphertextmessage import CiphertextMessage
 from ..util.byteutil import ByteUtil
 from ..ecc.curve import Curve
-from . import whisperprotos
+from . import whisperprotos_pb2 as whisperprotos
 from ..legacymessageexception import LegacyMessageException
 from ..invalidmessageexception import InvalidMessageException
 from ..invalidkeyexception import InvalidKeyException
diff --git a/axolotl/protocol/whisperprotos.py b/axolotl/protocol/whisperprotos_pb2.py
similarity index 100%
rename from axolotl/protocol/whisperprotos.py
rename to axolotl/protocol/whisperprotos_pb2.py
diff --git a/axolotl/state/prekeyrecord.py b/axolotl/state/prekeyrecord.py
index 5e428d6..8bdbd0d 100644
--- a/axolotl/state/prekeyrecord.py
+++ b/axolotl/state/prekeyrecord.py
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-from .storageprotos import PreKeyRecordStructure
+from .storageprotos_pb2 import PreKeyRecordStructure
 from ..ecc.curve import Curve
 from ..ecc.eckeypair import ECKeyPair
 
diff --git a/axolotl/state/sessionrecord.py b/axolotl/state/sessionrecord.py
index e5ecb7e..b53701e 100644
--- a/axolotl/state/sessionrecord.py
+++ b/axolotl/state/sessionrecord.py
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-from . import storageprotos
+from . import storageprotos_pb2 as storageprotos
 from .sessionstate import SessionState
 
 
diff --git a/axolotl/state/sessionstate.py b/axolotl/state/sessionstate.py
index 5ef86be..b7c1277 100644
--- a/axolotl/state/sessionstate.py
+++ b/axolotl/state/sessionstate.py
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-from . import storageprotos
+from . import storageprotos_pb2 as storageprotos
 from ..identitykeypair import IdentityKey, IdentityKeyPair
 from ..ratchet.rootkey import RootKey
 from ..kdf.hkdf import HKDF
diff --git a/axolotl/state/signedprekeyrecord.py b/axolotl/state/signedprekeyrecord.py
index 5942456..727cc1d 100644
--- a/axolotl/state/signedprekeyrecord.py
+++ b/axolotl/state/signedprekeyrecord.py
@@ -1,6 +1,6 @@
 # -*- coding; utf-8 -*-
 
-from .storageprotos import SignedPreKeyRecordStructure
+from .storageprotos_pb2 import SignedPreKeyRecordStructure
 from ..ecc.curve import Curve
 from ..ecc.eckeypair import ECKeyPair
 
diff --git a/axolotl/state/storageprotos.py b/axolotl/state/storageprotos_pb2.py
similarity index 100%
rename from axolotl/state/storageprotos.py
rename to axolotl/state/storageprotos_pb2.py
-- 
2.9.3

Reply via email to