{"action":"created","issue":{"url":"https://api.github.com/repos/tgalal/python-axolotl/issues/14","repository_url":"https://api.github.com/repos/tgalal/python-axolotl","labels_url":"https://api.github.com/repos/tgalal/python-axolotl/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/tgalal/python-axolotl/issues/14/comments","events_url":"https://api.github.com/repos/tgalal/python-axolotl/issues/14/events","html_url":"https://github.com/tgalal/python-axolotl/issues/14","id":173164517,"number":14,"title":"Use the _pb2 suffix in the file name for protocol files generated with protoc","user":{"login":"ao2","id":1249395,"avatar_url":"https://avatars.githubusercontent.com/u/1249395?v=3","gravatar_id":"","url":"https://api.github.com/users/ao2","html_url":"https://github.com/ao2","followers_url":"https://api.github.com/users/ao2/followers","following_url":"https://api.github.com/users/ao2/following{/other_user}","gists_url":"https://api.github.com/users/ao2/gists{/gist_id}","starred_url":"https://api.github.com/users/ao2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ao2/subscriptions","organizations_url":"https://api.github.com/users/ao2/orgs","repos_url":"https://api.github.com/users/ao2/repos","events_url":"https://api.github.com/users/ao2/events{/privacy}","received_events_url":"https://api.github.com/users/ao2/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-08-25T10:10:57Z","updated_at":"2017-02-12T05:52:28Z","closed_at":null,"body":"Hi,\n\nsince python-protobuf 3.0.0 landed in Debian, programs using `python-axolotl` fail with a message like this:\n\n```\n$ gajim\nTraceback (most recent call last):\n  File \"gajim.py\", line 533, in <module>\n    interface.run()\n  File \"/usr/share/gajim/src/gui_interface.py\", line 2733, in run\n    gajim.plugin_manager = plugins.PluginManager()\n  File \"/usr/share/gajim/src/plugins/helpers.py\", line 129, in __call__\n    cls.instance=super(Singleton, cls).__call__(*args,**kw)\n  File \"/usr/share/gajim/src/plugins/pluginmanager.py\", line 104, in __init__\n    pc = PluginManager.scan_dir_for_plugins(path)\n  File \"/usr/share/gajim/src/plugins/helpers.py\", line 114, in wrapper\n    result = f(*args, **kwargs)\n  File \"/usr/share/gajim/src/plugins/pluginmanager.py\", line 454, in scan_dir_for_plugins\n    module = __import__(module_name)\n  File \"/usr/share/gajim/src/common/demandimport.py\", line 95, in _demandimport\n    return _import(name, globals, locals, fromlist, level)\n  File \"/home/ao2/.local/share/gajim/plugins/omemo/__init__.py\", line 50, in <module>\n    from omemo.state import OmemoState\n  File \"/usr/share/gajim/src/common/demandimport.py\", line 114, in _demandimport\n    mod = _origimport(name, globals, locals)\n  File \"/home/ao2/.local/share/gajim/plugins/omemo/omemo/state.py\", line 29, in <module>\n    from axolotl.protocol.prekeywhispermessage import PreKeyWhisperMessage\n  File \"/usr/share/gajim/src/common/demandimport.py\", line 114, in _demandimport\n    mod = _origimport(name, globals, locals)\n  File \"/usr/lib/python2.7/dist-packages/axolotl/protocol/prekeywhispermessage.py\", line 5, in <module>\n    from .whispermessage import WhisperMessage\n  File \"/usr/share/gajim/src/common/demandimport.py\", line 112, in _demandimport\n    return _origimport(name, globals, locals, fromlist, level)\n  File \"/usr/lib/python2.7/dist-packages/axolotl/protocol/whispermessage.py\", line 4, in <module>\n    from . import whisperprotos\n  File \"/usr/share/gajim/src/common/demandimport.py\", line 112, in _demandimport\n    return _origimport(name, globals, locals, fromlist, level)\n  File \"/usr/lib/python2.7/dist-packages/axolotl/protocol/whisperprotos.py\", line 41, in <module>\n    options=None),\n  File \"/usr/lib/python2.7/dist-packages/google/protobuf/descriptor.py\", line 501, in __new__\n    _message.Message._CheckCalledFromGeneratedFile()\nTypeError: Descriptors should not be created directly, but only retrieved from their parent.\n```\n\nThe same happens when running the tests with `python2.7 -m unittest discover -v`.\n\nAs analyzed in Debian bug #835271 (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=835271) it looks like this is an issue in `python-axolotl` rather than in `python-protobuf` itself, basically the newer protobuf code checks that the generated protocol files have the `_pb2.py` suffix in their names, and this does not happen in `python-axolotl`.\n\nThe issue happens only when PyPy is not used (https://github.com/google/protobuf/blob/2fe0556c7abbe31c02147b9171397737a35bfe3b/python/google/protobuf/pyext/descriptor.cc#L94) which apparently is the case for the `python-protobuf` Debian package.\n\nThis behavior also looks consistent with the protbuf documentation: https://developers.google.com/protocol-buffers/docs/pythontutorial#compiling-your-protocol-buffers even if the doc does not state clearly that having the `_pb2` suffix is a requirement.\n\nAnyway, renaming the generated protbuf files fixes the issue, see this patch:\nhttps://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=835271;filename=0001-Keep-the-_pb2-suffix-in-the-name-for-protobuf-genera.patch;msg=22\n\nShould I submit a pull request? Against the develop branch?\n\nAnother question: the protobuf documentation suggests to use the same base name used for the .proto files also in the generated files, in `python-axolotl` that would mean having `WhisperTextProtocol_pb2.py` instead of `whisperprotos.py` and `LocalStorageProtocol_pb2.py` instead of `storageprotos.py`; or alternatively have the protocol files named `whisperprotos.proto` and `storageprotos.proto`.\n\nDo you want to follow this scheme that makes it clear what the generated files are, or do you want to keep the current names?\n\nThanks,\n   Antonio\n"},"comment":{"url":"https://api.github.com/repos/tgalal/python-axolotl/issues/comments/279198800","html_url":"https://github.com/tgalal/python-axolotl/issues/14#issuecomment-279198800","issue_url":"https://api.github.com/repos/tgalal/python-axolotl/issues/14","id":279198800,"user":{"login":"rafaelsilverioit","id":7604541,"avatar_url":"https://avatars.githubusercontent.com/u/7604541?v=3","gravatar_id":"","url":"https://api.github.com/users/rafaelsilverioit","html_url":"https://github.com/rafaelsilverioit","followers_url":"https://api.github.com/users/rafaelsilverioit/followers","following_url":"https://api.github.com/users/rafaelsilverioit/following{/other_user}","gists_url":"https://api.github.com/users/rafaelsilverioit/gists{/gist_id}","starred_url":"https://api.github.com/users/rafaelsilverioit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rafaelsilverioit/subscriptions","organizations_url":"https://api.github.com/users/rafaelsilverioit/orgs","repos_url":"https://api.github.com/users/rafaelsilverioit/repos","events_url":"https://api.github.com/users/rafaelsilverioit/events{/privacy}","received_events_url":"https://api.github.com/users/rafaelsilverioit/received_events","type":"User","site_admin":false},"created_at":"2017-02-12T05:52:28Z","updated_at":"2017-02-12T05:52:28Z","body":"I have sent a pull request to master branch, since another people may face the same issue. https://github.com/tgalal/python-axolotl/pull/17\r\n\r\nWhile it is not merged here, you can clone my master branch.\r\n"}}
{"actor":{"display_login":"rafaelsilverioit"}}