소스 검색

Cython is not using .py file. Only check filenames when end with .py for _CalledFromGeneratedFile()

Jie Luo 7 년 전
부모
커밋
5fcc8e3994
1개의 변경된 파일6개의 추가작업 그리고 3개의 파일을 삭제
  1. 6 3
      python/google/protobuf/pyext/descriptor.cc

+ 6 - 3
python/google/protobuf/pyext/descriptor.cc

@@ -127,9 +127,12 @@ bool _CalledFromGeneratedFile(int stacklevel) {
     // filename is too short.
     // filename is too short.
     return false;
     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
 #endif
   return true;
   return true;