python - Python2 and Python3 compatibility -


i reading filename , run pyrun_simplefile function. below logic not recommended because if there compiler mismatch below code may crash in windows.

not recommended :-

file *fp = fopen(filename, "r"); if (!fp)     return; if (pyrun_simplefile(fp, filename) != 0)     return;         

so above logic, have implemented in python 2 (as per below) working fine. how implemend in python 3 (# else part in below code) because pyfile_fromstring , pyfile_asfile not supported in python 3.

#ifdef python2     pyobject* pyfileobject = pyfile_fromstring(filename, (char *)"r");     if (pyrun_simplefile(pyfile_asfile(pyfileobject), filename) != 0)         return; #else     //how implement in python3 above logic.. pyfile_fromstring ,        //pyfile_asfile not supported in python 3. #endif 

can suggest how implement in python 3?


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -