Skip to content

Commit f98bc1b

Browse files
LNT: Fix Perf profiling support
In Python3 the C interface has changed. [1] During the upgrade the Creation of the perf interface was upgraded to Python3 but the initialization itself was not. As a consequence the module was not actually registered and trying to use perf results in an error. This would not be noticed as the import in the Python module has the import in a try: .. except: pass block presumably because perf support is optional. [1] http://python3porting.com/cextensions.html Reviewed By: thopre Differential Revision: https://reviews.llvm.org/D93117
1 parent 51cae4e commit f98bc1b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lnt/testing/profile/cPerf.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -824,13 +824,15 @@ static PyModuleDef cPerfModuleDef = {PyModuleDef_HEAD_INIT,
824824
nullptr};
825825
#endif
826826

827-
PyMODINIT_FUNC initcPerf(void) {
828827
#if PY_MAJOR_VERSION >= 3
828+
PyMODINIT_FUNC PyInit_cPerf(void) {
829829
return PyModule_Create(&cPerfModuleDef);
830+
}
830831
#else
832+
PyMODINIT_FUNC initcPerf(void) {
831833
(void)Py_InitModule("cPerf", cPerfMethods);
832-
#endif
833834
}
835+
#endif
834836

835837
#else // STANDALONE
836838

lnt/testing/profile/perf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import traceback
88

99
try:
10-
import cPerf
10+
from . import cPerf
1111
except Exception:
1212
pass
1313

0 commit comments

Comments
 (0)