comparison src/if_python.c @ 10722:7598ce51bf2a v8.0.0251

patch 8.0.0251: not easy to select Python 2 or 3 commit https://github.com/vim/vim/commit/f42dd3c3901ea0ba38e67a616aea9953cae81b8d Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 28 16:06:38 2017 +0100 patch 8.0.0251: not easy to select Python 2 or 3 Problem: It is not so easy to write a script that works with both Python 2 and Python 3, even when the Python code works with both. Solution: Add 'pyxversion', :pyx, etc. (Marc Weber, Ken Takata)
author Christian Brabandt <cb@256bit.org>
date Sat, 28 Jan 2017 16:15:04 +0100
parents df5f9284fcba
children 3b53bb2a0e39
comparison
equal deleted inserted replaced
10721:9177c4f6a229 10722:7598ce51bf2a
1112 void 1112 void
1113 ex_python(exarg_T *eap) 1113 ex_python(exarg_T *eap)
1114 { 1114 {
1115 char_u *script; 1115 char_u *script;
1116 1116
1117 if (p_pyx == 0)
1118 p_pyx = 2;
1119
1117 script = script_get(eap, eap->arg); 1120 script = script_get(eap, eap->arg);
1118 if (!eap->skip) 1121 if (!eap->skip)
1119 { 1122 {
1120 DoPyCommand(script == NULL ? (char *) eap->arg : (char *) script, 1123 DoPyCommand(script == NULL ? (char *) eap->arg : (char *) script,
1121 (rangeinitializer) init_range_cmd, 1124 (rangeinitializer) init_range_cmd,
1134 ex_pyfile(exarg_T *eap) 1137 ex_pyfile(exarg_T *eap)
1135 { 1138 {
1136 static char buffer[BUFFER_SIZE]; 1139 static char buffer[BUFFER_SIZE];
1137 const char *file = (char *)eap->arg; 1140 const char *file = (char *)eap->arg;
1138 char *p; 1141 char *p;
1142
1143 if (p_pyx == 0)
1144 p_pyx = 2;
1139 1145
1140 /* Have to do it like this. PyRun_SimpleFile requires you to pass a 1146 /* Have to do it like this. PyRun_SimpleFile requires you to pass a
1141 * stdio file pointer, but Vim and the Python DLL are compiled with 1147 * stdio file pointer, but Vim and the Python DLL are compiled with
1142 * different options under Windows, meaning that stdio pointers aren't 1148 * different options under Windows, meaning that stdio pointers aren't
1143 * compatible between the two. Yuk. 1149 * compatible between the two. Yuk.
1173 } 1179 }
1174 1180
1175 void 1181 void
1176 ex_pydo(exarg_T *eap) 1182 ex_pydo(exarg_T *eap)
1177 { 1183 {
1184 if (p_pyx == 0)
1185 p_pyx = 2;
1186
1178 DoPyCommand((char *)eap->arg, 1187 DoPyCommand((char *)eap->arg,
1179 (rangeinitializer) init_range_cmd, 1188 (rangeinitializer) init_range_cmd,
1180 (runner)run_do, 1189 (runner)run_do,
1181 (void *)eap); 1190 (void *)eap);
1182 } 1191 }