From 0c88eefadaafcf7e7f32117cdbdde08852d97272 Mon Sep 17 00:00:00 2001 From: Corentin Henry Date: Tue, 10 May 2016 16:51:45 +0200 Subject: [PATCH] python: force relative imports fix https://github.com/google/protobuf/issues/1491 --- src/google/protobuf/compiler/python/python_generator.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/google/protobuf/compiler/python/python_generator.cc b/src/google/protobuf/compiler/python/python_generator.cc index 0553dd0d9d37..2018baee1e44 100644 --- a/src/google/protobuf/compiler/python/python_generator.cc +++ b/src/google/protobuf/compiler/python/python_generator.cc @@ -116,7 +116,7 @@ string ModuleImportStatement(const string& filename) { if (last_dot_pos == string::npos) { // NOTE(petya): this is not tested as it would require a protocol buffer // outside of any package, and I don't think that is easily achievable. - return "import " + module_name; + return "from . import " + module_name; } else { return "from " + module_name.substr(0, last_dot_pos) + " import " + module_name.substr(last_dot_pos + 1);