aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorAdam Cozzette <acozzette@google.com>2018-03-13 16:54:31 -0700
committerAdam Cozzette <acozzette@google.com>2018-03-13 16:54:31 -0700
commitafe96b6d4235b9d9fbfce2465f5c6d82c2611f48 (patch)
treed509cb3cc3f2b25b58a75563758d2092103ca19a /python
parent0400cca3236de1ca303af38bf81eab332d042b7c (diff)
parent89b5333ad0f10058d5af62701c5ebea0db376c5b (diff)
downloadprotobuf-afe96b6d4235b9d9fbfce2465f5c6d82c2611f48.tar.gz
protobuf-afe96b6d4235b9d9fbfce2465f5c6d82c2611f48.tar.bz2
protobuf-afe96b6d4235b9d9fbfce2465f5c6d82c2611f48.zip
Merge branch 'master' into down-integrate
Diffstat (limited to 'python')
-rw-r--r--python/google/protobuf/pyext/descriptor.cc13
1 files changed, 9 insertions, 4 deletions
diff --git a/python/google/protobuf/pyext/descriptor.cc b/python/google/protobuf/pyext/descriptor.cc
index bacaaf31..8af0cb12 100644
--- a/python/google/protobuf/pyext/descriptor.cc
+++ b/python/google/protobuf/pyext/descriptor.cc
@@ -107,10 +107,6 @@ bool _CalledFromGeneratedFile(int stacklevel) {
return false;
}
}
- if (frame->f_globals != frame->f_locals) {
- // Not at global module scope
- return false;
- }
if (frame->f_code->co_filename == NULL) {
return false;
@@ -123,6 +119,10 @@ bool _CalledFromGeneratedFile(int stacklevel) {
PyErr_Clear();
return false;
}
+ if ((filename_size < 3) || (strcmp(&filename[filename_size - 3], ".py") != 0)) {
+ // Cython's stack does not have .py file name and is not at global module scope.
+ return true;
+ }
if (filename_size < 7) {
// filename is too short.
return false;
@@ -131,6 +131,11 @@ bool _CalledFromGeneratedFile(int stacklevel) {
// Filename is not ending with _pb2.
return false;
}
+
+ if (frame->f_globals != frame->f_locals) {
+ // Not at global module scope
+ return false;
+ }
#endif
return true;
}