comparison Python/pythonrun.c @ 87072:518e3b174120

Issue #19515: Remove identifiers duplicated in the same file. Patch written by Andrei Dorian Duma.
author Victor Stinner <victor.stinner@gmail.com>
date Tue, 12 Nov 2013 21:39:02 +0100
parents 10a8e676b87b
children 58ffd70d02b6
comparison
equal deleted inserted replaced
87071:10a8e676b87b 87072:518e3b174120
35 #define PATH_MAX MAXPATHLEN 35 #define PATH_MAX MAXPATHLEN
36 #endif 36 #endif
37 37
38 _Py_IDENTIFIER(builtins); 38 _Py_IDENTIFIER(builtins);
39 _Py_IDENTIFIER(excepthook); 39 _Py_IDENTIFIER(excepthook);
40 _Py_IDENTIFIER(flush);
40 _Py_IDENTIFIER(last_traceback); 41 _Py_IDENTIFIER(last_traceback);
41 _Py_IDENTIFIER(last_type); 42 _Py_IDENTIFIER(last_type);
42 _Py_IDENTIFIER(last_value); 43 _Py_IDENTIFIER(last_value);
44 _Py_IDENTIFIER(name);
43 _Py_IDENTIFIER(ps1); 45 _Py_IDENTIFIER(ps1);
44 _Py_IDENTIFIER(ps2); 46 _Py_IDENTIFIER(ps2);
45 _Py_IDENTIFIER(stdin); 47 _Py_IDENTIFIER(stdin);
46 _Py_IDENTIFIER(stdout); 48 _Py_IDENTIFIER(stdout);
47 _Py_IDENTIFIER(stderr); 49 _Py_IDENTIFIER(stderr);
213 static char* 215 static char*
214 get_codec_name(const char *encoding) 216 get_codec_name(const char *encoding)
215 { 217 {
216 char *name_utf8, *name_str; 218 char *name_utf8, *name_str;
217 PyObject *codec, *name = NULL; 219 PyObject *codec, *name = NULL;
218 _Py_IDENTIFIER(name);
219 220
220 codec = _PyCodec_Lookup(encoding); 221 codec = _PyCodec_Lookup(encoding);
221 if (!codec) 222 if (!codec)
222 goto error; 223 goto error;
223 224
510 flush_std_files(void) 511 flush_std_files(void)
511 { 512 {
512 PyObject *fout = _PySys_GetObjectId(&PyId_stdout); 513 PyObject *fout = _PySys_GetObjectId(&PyId_stdout);
513 PyObject *ferr = _PySys_GetObjectId(&PyId_stderr); 514 PyObject *ferr = _PySys_GetObjectId(&PyId_stderr);
514 PyObject *tmp; 515 PyObject *tmp;
515 _Py_IDENTIFIER(flush);
516 516
517 if (fout != NULL && fout != Py_None && !file_is_closed(fout)) { 517 if (fout != NULL && fout != Py_None && !file_is_closed(fout)) {
518 tmp = _PyObject_CallMethodId(fout, &PyId_flush, ""); 518 tmp = _PyObject_CallMethodId(fout, &PyId_flush, "");
519 if (tmp == NULL) 519 if (tmp == NULL)
520 PyErr_WriteUnraisable(fout); 520 PyErr_WriteUnraisable(fout);
1007 PyObject *line_buffering; 1007 PyObject *line_buffering;
1008 int buffering, isatty; 1008 int buffering, isatty;
1009 _Py_IDENTIFIER(open); 1009 _Py_IDENTIFIER(open);
1010 _Py_IDENTIFIER(isatty); 1010 _Py_IDENTIFIER(isatty);
1011 _Py_IDENTIFIER(TextIOWrapper); 1011 _Py_IDENTIFIER(TextIOWrapper);
1012 _Py_IDENTIFIER(name);
1013 _Py_IDENTIFIER(mode); 1012 _Py_IDENTIFIER(mode);
1014 1013
1015 /* stdin is always opened in buffered mode, first because it shouldn't 1014 /* stdin is always opened in buffered mode, first because it shouldn't
1016 make a difference in common use cases, second because TextIOWrapper 1015 make a difference in common use cases, second because TextIOWrapper
1017 depends on the presence of a read1() method which only exists on 1016 depends on the presence of a read1() method which only exists on
2128 static void 2127 static void
2129 flush_io(void) 2128 flush_io(void)
2130 { 2129 {
2131 PyObject *f, *r; 2130 PyObject *f, *r;
2132 PyObject *type, *value, *traceback; 2131 PyObject *type, *value, *traceback;
2133 _Py_IDENTIFIER(flush);
2134 2132
2135 /* Save the current exception */ 2133 /* Save the current exception */
2136 PyErr_Fetch(&type, &value, &traceback); 2134 PyErr_Fetch(&type, &value, &traceback);
2137 2135
2138 f = _PySys_GetObjectId(&PyId_stderr); 2136 f = _PySys_GetObjectId(&PyId_stderr);