comparison Python/Python-ast.c @ 71459:d3f0f72c31f8

merge 3.2
author Benjamin Peterson <benjamin@python.org>
date Fri, 22 Jul 2011 11:10:43 -0500
parents 34d0b02a01e4 c9ebae3285e3
children f578ca44193d
comparison
equal deleted inserted replaced
71457:34d0b02a01e4 71459:d3f0f72c31f8
590 Py_XINCREF(obj); 590 Py_XINCREF(obj);
591 *out = obj; 591 *out = obj;
592 return 0; 592 return 0;
593 } 593 }
594 594
595 static int obj2ast_stringlike(PyObject* obj, PyObject** out, PyArena* arena, 595 static int obj2ast_identifier(PyObject* obj, PyObject** out, PyArena* arena)
596 const char *name) 596 {
597 { 597 if (!PyUnicode_CheckExact(obj) && obj != Py_None) {
598 if (!PyUnicode_CheckExact(name)) { 598 PyErr_SetString(PyExc_TypeError, "AST identifier must be of type str");
599 PyErr_Format(PyExc_TypeError, "AST %s must be of type str", name);
600 return 1; 599 return 1;
601 } 600 }
602 return obj2ast_object(obj, out, arena); 601 return obj2ast_object(obj, out, arena);
603 } 602 }
604 603
605 static int obj2ast_identifier(PyObject* obj, PyObject** out, PyArena* arena)
606 {
607 return obj2ast_stringlike(obj, out, arena, "identifier");
608 }
609
610 static int obj2ast_string(PyObject* obj, PyObject** out, PyArena* arena) 604 static int obj2ast_string(PyObject* obj, PyObject** out, PyArena* arena)
611 { 605 {
612 return obj2ast_stringlike(obj, out, arena, "string"); 606 if (!PyUnicode_CheckExact(obj)) {
607 PyErr_SetString(PyExc_TypeError, "AST string must be of type str");
608 return 1;
609 }
610 return obj2ast_object(obj, out, arena);
613 } 611 }
614 612
615 static int obj2ast_int(PyObject* obj, int* out, PyArena* arena) 613 static int obj2ast_int(PyObject* obj, int* out, PyArena* arena)
616 { 614 {
617 int i; 615 int i;