diff options
author | Jie Luo <anandolee@gmail.com> | 2018-02-07 12:41:20 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-07 12:41:20 -0800 |
commit | 7b44b6d1a08d0b408311e36fdb81874a3e297c30 (patch) | |
tree | 40e401511794581f8a9ff148cffb0babd647b640 | |
parent | 2bb3b2472509e0ba7bc7614050ac354078767b95 (diff) | |
download | protobuf-cython_protobuf.tar.gz protobuf-cython_protobuf.tar.bz2 protobuf-cython_protobuf.zip |
Update descriptor.cccython_protobuf
-rw-r--r-- | python/google/protobuf/pyext/descriptor.cc | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/python/google/protobuf/pyext/descriptor.cc b/python/google/protobuf/pyext/descriptor.cc index 036be3b2..6bbc92b9 100644 --- a/python/google/protobuf/pyext/descriptor.cc +++ b/python/google/protobuf/pyext/descriptor.cc @@ -101,7 +101,13 @@ bool _CalledFromGeneratedFile(int stacklevel) { if (frame == NULL) { return false; } - + while (stacklevel-- > 0) { + frame = frame->f_back; + if (frame == NULL) { + return false; + } + } + if (frame->f_code->co_filename == NULL) { return false; } @@ -113,12 +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; @@ -128,12 +132,6 @@ bool _CalledFromGeneratedFile(int stacklevel) { return false; } - while (stacklevel-- > 0) { - frame = frame->f_back; - if (frame == NULL) { - return false; - } - } if (frame->f_globals != frame->f_locals) { // Not at global module scope return false; |