]> granicus.if.org Git - python/commitdiff
merge 3.2
authorBenjamin Peterson <benjamin@python.org>
Tue, 3 Apr 2012 04:35:36 +0000 (00:35 -0400)
committerBenjamin Peterson <benjamin@python.org>
Tue, 3 Apr 2012 04:35:36 +0000 (00:35 -0400)
1  2 
Python/pythonrun.c

index f4e7e7b9b253138631a1be46798632b6335fe74f,5a96bae059ee99ad171cf46dcbe4e14dc8940f9f..b68bf9db06854371b93ccb4fbf7658e1d16b61e7
@@@ -1350,27 -1329,35 +1350,35 @@@ parse_syntax_error(PyObject *err, PyObj
  {
      long hold;
      PyObject *v;
 -
 -    /* old style errors */
 -    if (PyTuple_Check(err))
 -        return PyArg_ParseTuple(err, "O(ziiz)", message, filename,
 -                                lineno, offset, text);
 +    _Py_IDENTIFIER(msg);
 +    _Py_IDENTIFIER(filename);
 +    _Py_IDENTIFIER(lineno);
 +    _Py_IDENTIFIER(offset);
 +    _Py_IDENTIFIER(text);
  
-     /* new style errors.  `err' is an instance */
+     *message = NULL;
  
-     if (! (v = _PyObject_GetAttrId(err, &PyId_msg)))
+     /* new style errors.  `err' is an instance */
 -    *message = PyObject_GetAttrString(err, "msg");
++    *message = _PyObject_GetAttrId(err, &PyId_msg);
+     if (!*message)
          goto finally;
-     *message = v;
  
-     if (!(v = _PyObject_GetAttrId(err, &PyId_filename)))
 -    v = PyObject_GetAttrString(err, "filename");
++    v = _PyObject_GetAttrId(err, &PyId_filename);
+     if (!v)
          goto finally;
-     if (v == Py_None)
+     if (v == Py_None) {
+         Py_DECREF(v);
          *filename = NULL;
-     else if (! (*filename = _PyUnicode_AsString(v)))
-         goto finally;
+     }
+     else {
+         *filename = _PyUnicode_AsString(v);
+         Py_DECREF(v);
+         if (!*filename)
+             goto finally;
+     }
  
-     Py_DECREF(v);
-     if (!(v = _PyObject_GetAttrId(err, &PyId_lineno)))
 -    v = PyObject_GetAttrString(err, "lineno");
++    v = _PyObject_GetAttrId(err, &PyId_lineno);
+     if (!v)
          goto finally;
      hold = PyLong_AsLong(v);
      Py_DECREF(v);
          goto finally;
      *lineno = (int)hold;
  
-     if (!(v = _PyObject_GetAttrId(err, &PyId_offset)))
 -    v = PyObject_GetAttrString(err, "offset");
++    v = _PyObject_GetAttrId(err, &PyId_offset);
+     if (!v)
          goto finally;
      if (v == Py_None) {
          *offset = -1;
          *offset = (int)hold;
      }
  
-     if (!(v = _PyObject_GetAttrId(err, &PyId_text)))
 -    v = PyObject_GetAttrString(err, "text");
++    v = _PyObject_GetAttrId(err, &PyId_text);
+     if (!v)
          goto finally;
-     if (v == Py_None)
+     if (v == Py_None) {
+         Py_DECREF(v);
          *text = NULL;
-     else if (!PyUnicode_Check(v) ||
-              !(*text = _PyUnicode_AsString(v)))
-         goto finally;
-     Py_DECREF(v);
+     }
+     else {
+         *text = _PyUnicode_AsString(v);
+         Py_DECREF(v);
+         if (!*text)
+             goto finally;
+     }
      return 1;
  
  finally: