comparison Python/pythonrun.c @ 72925:7109f31300fb

Rename _Py_identifier to _Py_IDENTIFIER.
author Martin v. Löwis <martin@v.loewis.de>
date Fri, 14 Oct 2011 10:20:37 +0200
parents 81380082d216
children db4aa878cea2
comparison
equal deleted inserted replaced
72924:158430b2b552 72925:7109f31300fb
139 static char* 139 static char*
140 get_codec_name(const char *encoding) 140 get_codec_name(const char *encoding)
141 { 141 {
142 char *name_utf8, *name_str; 142 char *name_utf8, *name_str;
143 PyObject *codec, *name = NULL; 143 PyObject *codec, *name = NULL;
144 _Py_identifier(name); 144 _Py_IDENTIFIER(name);
145 145
146 codec = _PyCodec_Lookup(encoding); 146 codec = _PyCodec_Lookup(encoding);
147 if (!codec) 147 if (!codec)
148 goto error; 148 goto error;
149 149
351 flush_std_files(void) 351 flush_std_files(void)
352 { 352 {
353 PyObject *fout = PySys_GetObject("stdout"); 353 PyObject *fout = PySys_GetObject("stdout");
354 PyObject *ferr = PySys_GetObject("stderr"); 354 PyObject *ferr = PySys_GetObject("stderr");
355 PyObject *tmp; 355 PyObject *tmp;
356 _Py_identifier(flush); 356 _Py_IDENTIFIER(flush);
357 357
358 if (fout != NULL && fout != Py_None) { 358 if (fout != NULL && fout != Py_None) {
359 tmp = _PyObject_CallMethodId(fout, &PyId_flush, ""); 359 tmp = _PyObject_CallMethodId(fout, &PyId_flush, "");
360 if (tmp == NULL) 360 if (tmp == NULL)
361 PyErr_WriteUnraisable(fout); 361 PyErr_WriteUnraisable(fout);
805 PyObject *buf = NULL, *stream = NULL, *text = NULL, *raw = NULL, *res; 805 PyObject *buf = NULL, *stream = NULL, *text = NULL, *raw = NULL, *res;
806 const char* mode; 806 const char* mode;
807 const char* newline; 807 const char* newline;
808 PyObject *line_buffering; 808 PyObject *line_buffering;
809 int buffering, isatty; 809 int buffering, isatty;
810 _Py_identifier(open); 810 _Py_IDENTIFIER(open);
811 _Py_identifier(isatty); 811 _Py_IDENTIFIER(isatty);
812 _Py_identifier(TextIOWrapper); 812 _Py_IDENTIFIER(TextIOWrapper);
813 813
814 /* stdin is always opened in buffered mode, first because it shouldn't 814 /* stdin is always opened in buffered mode, first because it shouldn't
815 make a difference in common use cases, second because TextIOWrapper 815 make a difference in common use cases, second because TextIOWrapper
816 depends on the presence of a read1() method which only exists on 816 depends on the presence of a read1() method which only exists on
817 buffered streams. 817 buffered streams.
829 Py_None, Py_None, Py_None, 0); 829 Py_None, Py_None, Py_None, 0);
830 if (buf == NULL) 830 if (buf == NULL)
831 goto error; 831 goto error;
832 832
833 if (buffering) { 833 if (buffering) {
834 _Py_identifier(raw); 834 _Py_IDENTIFIER(raw);
835 raw = _PyObject_GetAttrId(buf, &PyId_raw); 835 raw = _PyObject_GetAttrId(buf, &PyId_raw);
836 if (raw == NULL) 836 if (raw == NULL)
837 goto error; 837 goto error;
838 } 838 }
839 else { 839 else {
1115 PyObject *m, *d, *v, *w, *oenc = NULL; 1115 PyObject *m, *d, *v, *w, *oenc = NULL;
1116 mod_ty mod; 1116 mod_ty mod;
1117 PyArena *arena; 1117 PyArena *arena;
1118 char *ps1 = "", *ps2 = "", *enc = NULL; 1118 char *ps1 = "", *ps2 = "", *enc = NULL;
1119 int errcode = 0; 1119 int errcode = 0;
1120 _Py_identifier(encoding); 1120 _Py_IDENTIFIER(encoding);
1121 1121
1122 if (fp == stdin) { 1122 if (fp == stdin) {
1123 /* Fetch encoding from sys.stdin */ 1123 /* Fetch encoding from sys.stdin */
1124 v = PySys_GetObject("stdin"); 1124 v = PySys_GetObject("stdin");
1125 if (v == NULL || v == Py_None) 1125 if (v == NULL || v == Py_None)
1319 parse_syntax_error(PyObject *err, PyObject **message, const char **filename, 1319 parse_syntax_error(PyObject *err, PyObject **message, const char **filename,
1320 int *lineno, int *offset, const char **text) 1320 int *lineno, int *offset, const char **text)
1321 { 1321 {
1322 long hold; 1322 long hold;
1323 PyObject *v; 1323 PyObject *v;
1324 _Py_identifier(msg); 1324 _Py_IDENTIFIER(msg);
1325 _Py_identifier(filename); 1325 _Py_IDENTIFIER(filename);
1326 _Py_identifier(lineno); 1326 _Py_IDENTIFIER(lineno);
1327 _Py_identifier(offset); 1327 _Py_IDENTIFIER(offset);
1328 _Py_identifier(text); 1328 _Py_IDENTIFIER(text);
1329 1329
1330 /* old style errors */ 1330 /* old style errors */
1331 if (PyTuple_Check(err)) 1331 if (PyTuple_Check(err))
1332 return PyArg_ParseTuple(err, "O(ziiz)", message, filename, 1332 return PyArg_ParseTuple(err, "O(ziiz)", message, filename,
1333 lineno, offset, text); 1333 lineno, offset, text);
1437 fflush(stdout); 1437 fflush(stdout);
1438 if (value == NULL || value == Py_None) 1438 if (value == NULL || value == Py_None)
1439 goto done; 1439 goto done;
1440 if (PyExceptionInstance_Check(value)) { 1440 if (PyExceptionInstance_Check(value)) {
1441 /* The error code should be in the `code' attribute. */ 1441 /* The error code should be in the `code' attribute. */
1442 _Py_identifier(code); 1442 _Py_IDENTIFIER(code);
1443 PyObject *code = _PyObject_GetAttrId(value, &PyId_code); 1443 PyObject *code = _PyObject_GetAttrId(value, &PyId_code);
1444 if (code) { 1444 if (code) {
1445 Py_DECREF(value); 1445 Py_DECREF(value);
1446 value = code; 1446 value = code;
1447 if (value == Py_None) 1447 if (value == Py_None)
1595 /* Don't do anything else */ 1595 /* Don't do anything else */
1596 } 1596 }
1597 else { 1597 else {
1598 PyObject* moduleName; 1598 PyObject* moduleName;
1599 char* className; 1599 char* className;
1600 _Py_identifier(__module__); 1600 _Py_IDENTIFIER(__module__);
1601 assert(PyExceptionClass_Check(type)); 1601 assert(PyExceptionClass_Check(type));
1602 className = PyExceptionClass_Name(type); 1602 className = PyExceptionClass_Name(type);
1603 if (className != NULL) { 1603 if (className != NULL) {
1604 char *dot = strrchr(className, '.'); 1604 char *dot = strrchr(className, '.');
1605 if (dot != NULL) 1605 if (dot != NULL)
1771 static void 1771 static void
1772 flush_io(void) 1772 flush_io(void)
1773 { 1773 {
1774 PyObject *f, *r; 1774 PyObject *f, *r;
1775 PyObject *type, *value, *traceback; 1775 PyObject *type, *value, *traceback;
1776 _Py_identifier(flush); 1776 _Py_IDENTIFIER(flush);
1777 1777
1778 /* Save the current exception */ 1778 /* Save the current exception */
1779 PyErr_Fetch(&type, &value, &traceback); 1779 PyErr_Fetch(&type, &value, &traceback);
1780 1780
1781 f = PySys_GetObject("stderr"); 1781 f = PySys_GetObject("stderr");
2218 "threading" threads have completed. */ 2218 "threading" threads have completed. */
2219 static void 2219 static void
2220 wait_for_thread_shutdown(void) 2220 wait_for_thread_shutdown(void)
2221 { 2221 {
2222 #ifdef WITH_THREAD 2222 #ifdef WITH_THREAD
2223 _Py_identifier(_shutdown); 2223 _Py_IDENTIFIER(_shutdown);
2224 PyObject *result; 2224 PyObject *result;
2225 PyThreadState *tstate = PyThreadState_GET(); 2225 PyThreadState *tstate = PyThreadState_GET();
2226 PyObject *threading = PyMapping_GetItemString(tstate->interp->modules, 2226 PyObject *threading = PyMapping_GetItemString(tstate->interp->modules,
2227 "threading"); 2227 "threading");
2228 if (threading == NULL) { 2228 if (threading == NULL) {