aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJie Luo <anandolee@gmail.com>2018-01-31 11:54:57 -0800
committerGitHub <noreply@github.com>2018-01-31 11:54:57 -0800
commit5fcc8e39949799e2fdbeaa1237c0e55f1716449a (patch)
tree3257c887b0f7598544adc2d9d781d1ed6c2458d9
parentd83837ded558bc2fd2b61a5f51ed52e4606345aa (diff)
downloadprotobuf-5fcc8e39949799e2fdbeaa1237c0e55f1716449a.tar.gz
protobuf-5fcc8e39949799e2fdbeaa1237c0e55f1716449a.tar.bz2
protobuf-5fcc8e39949799e2fdbeaa1237c0e55f1716449a.zip
Cython is not using .py file. Only check filenames when end with .py for _CalledFromGeneratedFile()
-rw-r--r--python/google/protobuf/pyext/descriptor.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/python/google/protobuf/pyext/descriptor.cc b/python/google/protobuf/pyext/descriptor.cc
index 9634ea05..3526fc1c 100644
--- a/python/google/protobuf/pyext/descriptor.cc
+++ b/python/google/protobuf/pyext/descriptor.cc
@@ -127,9 +127,12 @@ bool _CalledFromGeneratedFile(int stacklevel) {
// filename is too short.
return false;
}
- if (strcmp(&filename[filename_size - 7], "_pb2.py") != 0) {
- // Filename is not ending with _pb2.
- return false;
+ // Cython is not using .py file. Only check filenames when end with .py
+ if (strcmp(&filename[filename_size - 3], ".py") == 0) {
+ if (strcmp(&filename[filename_size - 7], "_pb2.py") != 0) {
+ // Filename is not ending with _pb2.
+ return false;
+ }
}
#endif
return true;