[Python-checkins] cpython (merge 3.2 -> default): merge 3.2

benjamin.peterson python-checkins at python.org
Fri Jul 22 18:10:41 CEST 2011


http://hg.python.org/cpython/rev/d3f0f72c31f8
changeset: 71459:d3f0f72c31f8
parent: 71457:34d0b02a01e4
parent: 71458:c9ebae3285e3
user: Benjamin Peterson <benjamin at python.org>
date: Fri Jul 22 11:10:43 2011 -0500
summary:
 merge 3.2
files:
 Parser/asdl_c.py | 18 ++++++++----------
 Python/Python-ast.c | 18 ++++++++----------
 2 files changed, 16 insertions(+), 20 deletions(-)
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -795,24 +795,22 @@
 return 0;
 }
 
-static int obj2ast_stringlike(PyObject* obj, PyObject** out, PyArena* arena,
- const char *name)
+static int obj2ast_identifier(PyObject* obj, PyObject** out, PyArena* arena)
 {
- if (!PyUnicode_CheckExact(name)) {
- PyErr_Format(PyExc_TypeError, "AST %s must be of type str", name);
+ if (!PyUnicode_CheckExact(obj) && obj != Py_None) {
+ PyErr_SetString(PyExc_TypeError, "AST identifier must be of type str");
 return 1;
 }
 return obj2ast_object(obj, out, arena);
 }
 
-static int obj2ast_identifier(PyObject* obj, PyObject** out, PyArena* arena)
-{
- return obj2ast_stringlike(obj, out, arena, "identifier");
-}
-
 static int obj2ast_string(PyObject* obj, PyObject** out, PyArena* arena)
 {
- return obj2ast_stringlike(obj, out, arena, "string");
+ if (!PyUnicode_CheckExact(obj)) {
+ PyErr_SetString(PyExc_TypeError, "AST string must be of type str");
+ return 1;
+ }
+ return obj2ast_object(obj, out, arena);
 }
 
 static int obj2ast_int(PyObject* obj, int* out, PyArena* arena)
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -592,24 +592,22 @@
 return 0;
 }
 
-static int obj2ast_stringlike(PyObject* obj, PyObject** out, PyArena* arena,
- const char *name)
+static int obj2ast_identifier(PyObject* obj, PyObject** out, PyArena* arena)
 {
- if (!PyUnicode_CheckExact(name)) {
- PyErr_Format(PyExc_TypeError, "AST %s must be of type str", name);
+ if (!PyUnicode_CheckExact(obj) && obj != Py_None) {
+ PyErr_SetString(PyExc_TypeError, "AST identifier must be of type str");
 return 1;
 }
 return obj2ast_object(obj, out, arena);
 }
 
-static int obj2ast_identifier(PyObject* obj, PyObject** out, PyArena* arena)
-{
- return obj2ast_stringlike(obj, out, arena, "identifier");
-}
-
 static int obj2ast_string(PyObject* obj, PyObject** out, PyArena* arena)
 {
- return obj2ast_stringlike(obj, out, arena, "string");
+ if (!PyUnicode_CheckExact(obj)) {
+ PyErr_SetString(PyExc_TypeError, "AST string must be of type str");
+ return 1;
+ }
+ return obj2ast_object(obj, out, arena);
 }
 
 static int obj2ast_int(PyObject* obj, int* out, PyArena* arena)
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /