MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / GetPythonVersion

Function GetPythonVersion

pydevd_attach_to_process/common/py_version.hpp:47–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45typedef const char* (*GetVersionFunc) ();
46
47static PythonVersion GetPythonVersion(void *module) {
48 GetVersionFunc versionFunc;
49 *(void**)(&versionFunc) = dlsym(module, "Py_GetVersion");
50 if(versionFunc == nullptr) {
51 return PythonVersion_Unknown;
52 }
53 const char* version = versionFunc();
54
55#endif //_WIN32
56
57 if (version != nullptr && strlen(version) >= 3 && version[1] == '.') {
58 if (version[0] == '2') {
59 switch (version[2]) {
60 case '5': return PythonVersion_25;
61 case '6': return PythonVersion_26;
62 case '7': return PythonVersion_27;
63 }
64 }
65 else if (version[0] == '3') {
66 switch (version[2]) {
67 case '0': return PythonVersion_30;
68 case '1':
69 if(strlen(version) >= 4){
70 if(version[3] == '0'){
71 return PythonVersion_310;
72 }
73 if(version[3] == '1'){
74 return PythonVersion_311;
75 }
76 if(version[3] == '2'){
77 return PythonVersion_312;
78 }
79 if(version[3] == '3'){
80 return PythonVersion_313;
81 }
82 if(version[3] == '4'){
83 return PythonVersion_314;
84 }
85 }
86 return PythonVersion_Unknown; // we don't care about 3.1 anymore...
87
88 case '2': return PythonVersion_32;
89 case '3': return PythonVersion_33;
90 case '4': return PythonVersion_34;
91 case '5': return PythonVersion_35;
92 case '6': return PythonVersion_36;
93 case '7': return PythonVersion_37;
94 case '8': return PythonVersion_38;
95 case '9': return PythonVersion_39;
96 }
97 }
98 }
99 return PythonVersion_Unknown;
100}
101
102#endif

Callers 4

helloFunction · 0.85
DoAttachFunction · 0.85
attach.cppFile · 0.85
py_settrace.hppFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected