comparison Python/Python-ast.c @ 66254:350898e095aa 3.1

Merged revisions 86538 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r86538 | benjamin.peterson | 2010-11-19 19:38:49 -0600 (Fri, 19 Nov 2010) | 1 line use %R format code; fixes invalid dereferencing #10391 ........
author Benjamin Peterson <benjamin@python.org>
date Sat, 20 Nov 2010 01:48:38 +0000
parents 1558dc69aacf
children 51f72c5fe28e
comparison
equal deleted inserted replaced
66249:420301400403 66254:350898e095aa
3377 3377
3378 int 3378 int
3379 obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena) 3379 obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena)
3380 { 3380 {
3381 PyObject* tmp = NULL; 3381 PyObject* tmp = NULL;
3382 tmp = tmp;
3382 int isinstance; 3383 int isinstance;
3383 3384
3384 3385
3385 if (obj == Py_None) { 3386 if (obj == Py_None) {
3386 *out = NULL; 3387 *out = NULL;
3516 *out = Suite(body, arena); 3517 *out = Suite(body, arena);
3517 if (*out == NULL) goto failed; 3518 if (*out == NULL) goto failed;
3518 return 0; 3519 return 0;
3519 } 3520 }
3520 3521
3521 tmp = PyObject_Repr(obj); 3522 PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %R", obj);
3522 if (tmp == NULL) goto failed; 3523 failed:
3523 PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %.400s", PyBytes_AS_STRING(tmp));
3524 failed:
3525 Py_XDECREF(tmp);
3526 return 1; 3524 return 1;
3527 } 3525 }
3528 3526
3529 int 3527 int
3530 obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena) 3528 obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
3531 { 3529 {
3532 PyObject* tmp = NULL; 3530 PyObject* tmp = NULL;
3531 tmp = tmp;
3533 int isinstance; 3532 int isinstance;
3534 3533
3535 int lineno; 3534 int lineno;
3536 int col_offset; 3535 int col_offset;
3537 3536
4715 *out = Continue(lineno, col_offset, arena); 4714 *out = Continue(lineno, col_offset, arena);
4716 if (*out == NULL) goto failed; 4715 if (*out == NULL) goto failed;
4717 return 0; 4716 return 0;
4718 } 4717 }
4719 4718
4720 tmp = PyObject_Repr(obj); 4719 PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %R", obj);
4721 if (tmp == NULL) goto failed; 4720 failed:
4722 PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %.400s", PyBytes_AS_STRING(tmp));
4723 failed:
4724 Py_XDECREF(tmp);
4725 return 1; 4721 return 1;
4726 } 4722 }
4727 4723
4728 int 4724 int
4729 obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena) 4725 obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
4730 { 4726 {
4731 PyObject* tmp = NULL; 4727 PyObject* tmp = NULL;
4728 tmp = tmp;
4732 int isinstance; 4729 int isinstance;
4733 4730
4734 int lineno; 4731 int lineno;
4735 int col_offset; 4732 int col_offset;
4736 4733
5833 *out = Tuple(elts, ctx, lineno, col_offset, arena); 5830 *out = Tuple(elts, ctx, lineno, col_offset, arena);
5834 if (*out == NULL) goto failed; 5831 if (*out == NULL) goto failed;
5835 return 0; 5832 return 0;
5836 } 5833 }
5837 5834
5838 tmp = PyObject_Repr(obj); 5835 PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %R", obj);
5839 if (tmp == NULL) goto failed; 5836 failed:
5840 PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %.400s", PyBytes_AS_STRING(tmp));
5841 failed:
5842 Py_XDECREF(tmp);
5843 return 1; 5837 return 1;
5844 } 5838 }
5845 5839
5846 int 5840 int
5847 obj2ast_expr_context(PyObject* obj, expr_context_ty* out, PyArena* arena) 5841 obj2ast_expr_context(PyObject* obj, expr_context_ty* out, PyArena* arena)
5848 { 5842 {
5849 PyObject* tmp = NULL; 5843 PyObject* tmp = NULL;
5844 tmp = tmp;
5850 int isinstance; 5845 int isinstance;
5851 5846
5852 isinstance = PyObject_IsInstance(obj, (PyObject *)Load_type); 5847 isinstance = PyObject_IsInstance(obj, (PyObject *)Load_type);
5853 if (isinstance == -1) { 5848 if (isinstance == -1) {
5854 return 1; 5849 return 1;
5896 if (isinstance) { 5891 if (isinstance) {
5897 *out = Param; 5892 *out = Param;
5898 return 0; 5893 return 0;
5899 } 5894 }
5900 5895
5901 tmp = PyObject_Repr(obj); 5896 PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %R", obj);
5902 if (tmp == NULL) goto failed;
5903 PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %.400s", PyBytes_AS_STRING(tmp));
5904 failed:
5905 Py_XDECREF(tmp);
5906 return 1; 5897 return 1;
5907 } 5898 }
5908 5899
5909 int 5900 int
5910 obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena) 5901 obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena)
5911 { 5902 {
5912 PyObject* tmp = NULL; 5903 PyObject* tmp = NULL;
5904 tmp = tmp;
5913 int isinstance; 5905 int isinstance;
5914 5906
5915 5907
5916 if (obj == Py_None) { 5908 if (obj == Py_None) {
5917 *out = NULL; 5909 *out = NULL;
6021 *out = Index(value, arena); 6013 *out = Index(value, arena);
6022 if (*out == NULL) goto failed; 6014 if (*out == NULL) goto failed;
6023 return 0; 6015 return 0;
6024 } 6016 }
6025 6017
6026 tmp = PyObject_Repr(obj); 6018 PyErr_Format(PyExc_TypeError, "expected some sort of slice, but got %R", obj);
6027 if (tmp == NULL) goto failed; 6019 failed:
6028 PyErr_Format(PyExc_TypeError, "expected some sort of slice, but got %.400s", PyBytes_AS_STRING(tmp));
6029 failed:
6030 Py_XDECREF(tmp);
6031 return 1; 6020 return 1;
6032 } 6021 }
6033 6022
6034 int 6023 int
6035 obj2ast_boolop(PyObject* obj, boolop_ty* out, PyArena* arena) 6024 obj2ast_boolop(PyObject* obj, boolop_ty* out, PyArena* arena)
6036 { 6025 {
6037 PyObject* tmp = NULL; 6026 PyObject* tmp = NULL;
6027 tmp = tmp;
6038 int isinstance; 6028 int isinstance;
6039 6029
6040 isinstance = PyObject_IsInstance(obj, (PyObject *)And_type); 6030 isinstance = PyObject_IsInstance(obj, (PyObject *)And_type);
6041 if (isinstance == -1) { 6031 if (isinstance == -1) {
6042 return 1; 6032 return 1;
6052 if (isinstance) { 6042 if (isinstance) {
6053 *out = Or; 6043 *out = Or;
6054 return 0; 6044 return 0;
6055 } 6045 }
6056 6046
6057 tmp = PyObject_Repr(obj); 6047 PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %R", obj);
6058 if (tmp == NULL) goto failed;
6059 PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %.400s", PyBytes_AS_STRING(tmp));
6060 failed:
6061 Py_XDECREF(tmp);
6062 return 1; 6048 return 1;
6063 } 6049 }
6064 6050
6065 int 6051 int
6066 obj2ast_operator(PyObject* obj, operator_ty* out, PyArena* arena) 6052 obj2ast_operator(PyObject* obj, operator_ty* out, PyArena* arena)
6067 { 6053 {
6068 PyObject* tmp = NULL; 6054 PyObject* tmp = NULL;
6055 tmp = tmp;
6069 int isinstance; 6056 int isinstance;
6070 6057
6071 isinstance = PyObject_IsInstance(obj, (PyObject *)Add_type); 6058 isinstance = PyObject_IsInstance(obj, (PyObject *)Add_type);
6072 if (isinstance == -1) { 6059 if (isinstance == -1) {
6073 return 1; 6060 return 1;
6163 if (isinstance) { 6150 if (isinstance) {
6164 *out = FloorDiv; 6151 *out = FloorDiv;
6165 return 0; 6152 return 0;
6166 } 6153 }
6167 6154
6168 tmp = PyObject_Repr(obj); 6155 PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %R", obj);
6169 if (tmp == NULL) goto failed;
6170 PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %.400s", PyBytes_AS_STRING(tmp));
6171 failed:
6172 Py_XDECREF(tmp);
6173 return 1; 6156 return 1;
6174 } 6157 }
6175 6158
6176 int 6159 int
6177 obj2ast_unaryop(PyObject* obj, unaryop_ty* out, PyArena* arena) 6160 obj2ast_unaryop(PyObject* obj, unaryop_ty* out, PyArena* arena)
6178 { 6161 {
6179 PyObject* tmp = NULL; 6162 PyObject* tmp = NULL;
6163 tmp = tmp;
6180 int isinstance; 6164 int isinstance;
6181 6165
6182 isinstance = PyObject_IsInstance(obj, (PyObject *)Invert_type); 6166 isinstance = PyObject_IsInstance(obj, (PyObject *)Invert_type);
6183 if (isinstance == -1) { 6167 if (isinstance == -1) {
6184 return 1; 6168 return 1;
6210 if (isinstance) { 6194 if (isinstance) {
6211 *out = USub; 6195 *out = USub;
6212 return 0; 6196 return 0;
6213 } 6197 }
6214 6198
6215 tmp = PyObject_Repr(obj); 6199 PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %R", obj);
6216 if (tmp == NULL) goto failed;
6217 PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %.400s", PyBytes_AS_STRING(tmp));
6218 failed:
6219 Py_XDECREF(tmp);
6220 return 1; 6200 return 1;
6221 } 6201 }
6222 6202
6223 int 6203 int
6224 obj2ast_cmpop(PyObject* obj, cmpop_ty* out, PyArena* arena) 6204 obj2ast_cmpop(PyObject* obj, cmpop_ty* out, PyArena* arena)
6225 { 6205 {
6226 PyObject* tmp = NULL; 6206 PyObject* tmp = NULL;
6207 tmp = tmp;
6227 int isinstance; 6208 int isinstance;
6228 6209
6229 isinstance = PyObject_IsInstance(obj, (PyObject *)Eq_type); 6210 isinstance = PyObject_IsInstance(obj, (PyObject *)Eq_type);
6230 if (isinstance == -1) { 6211 if (isinstance == -1) {
6231 return 1; 6212 return 1;
6305 if (isinstance) { 6286 if (isinstance) {
6306 *out = NotIn; 6287 *out = NotIn;
6307 return 0; 6288 return 0;
6308 } 6289 }
6309 6290
6310 tmp = PyObject_Repr(obj); 6291 PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %R", obj);
6311 if (tmp == NULL) goto failed;
6312 PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %.400s", PyBytes_AS_STRING(tmp));
6313 failed:
6314 Py_XDECREF(tmp);
6315 return 1; 6292 return 1;
6316 } 6293 }
6317 6294
6318 int 6295 int
6319 obj2ast_comprehension(PyObject* obj, comprehension_ty* out, PyArena* arena) 6296 obj2ast_comprehension(PyObject* obj, comprehension_ty* out, PyArena* arena)
6381 6358
6382 int 6359 int
6383 obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena) 6360 obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena)
6384 { 6361 {
6385 PyObject* tmp = NULL; 6362 PyObject* tmp = NULL;
6363 tmp = tmp;
6386 int isinstance; 6364 int isinstance;
6387 6365
6388 int lineno; 6366 int lineno;
6389 int col_offset; 6367 int col_offset;
6390 6368
6476 arena); 6454 arena);
6477 if (*out == NULL) goto failed; 6455 if (*out == NULL) goto failed;
6478 return 0; 6456 return 0;
6479 } 6457 }
6480 6458
6481 tmp = PyObject_Repr(obj); 6459 PyErr_Format(PyExc_TypeError, "expected some sort of excepthandler, but got %R", obj);
6482 if (tmp == NULL) goto failed; 6460 failed:
6483 PyErr_Format(PyExc_TypeError, "expected some sort of excepthandler, but got %.400s", PyBytes_AS_STRING(tmp));
6484 failed:
6485 Py_XDECREF(tmp);
6486 return 1; 6461 return 1;
6487 } 6462 }
6488 6463
6489 int 6464 int
6490 obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena) 6465 obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena)