mirror of
				https://github.com/python/cpython.git
				synced 2025-10-30 21:21:22 +00:00 
			
		
		
		
	merge 3.2
This commit is contained in:
		
						commit
						0a9a636302
					
				
					 1 changed files with 31 additions and 20 deletions
				
			
		|  | @ -1356,56 +1356,67 @@ parse_syntax_error(PyObject *err, PyObject **message, const char **filename, | ||||||
|     _Py_IDENTIFIER(offset); |     _Py_IDENTIFIER(offset); | ||||||
|     _Py_IDENTIFIER(text); |     _Py_IDENTIFIER(text); | ||||||
| 
 | 
 | ||||||
|  |     *message = NULL; | ||||||
|  | 
 | ||||||
|     /* new style errors.  `err' is an instance */ |     /* new style errors.  `err' is an instance */ | ||||||
| 
 |     *message = _PyObject_GetAttrId(err, &PyId_msg); | ||||||
|     if (! (v = _PyObject_GetAttrId(err, &PyId_msg))) |     if (!*message) | ||||||
|         goto finally; |  | ||||||
|     *message = v; |  | ||||||
| 
 |  | ||||||
|     if (!(v = _PyObject_GetAttrId(err, &PyId_filename))) |  | ||||||
|         goto finally; |  | ||||||
|     if (v == Py_None) |  | ||||||
|         *filename = NULL; |  | ||||||
|     else if (! (*filename = _PyUnicode_AsString(v))) |  | ||||||
|         goto finally; |         goto finally; | ||||||
| 
 | 
 | ||||||
|  |     v = _PyObject_GetAttrId(err, &PyId_filename); | ||||||
|  |     if (!v) | ||||||
|  |         goto finally; | ||||||
|  |     if (v == Py_None) { | ||||||
|         Py_DECREF(v); |         Py_DECREF(v); | ||||||
|     if (!(v = _PyObject_GetAttrId(err, &PyId_lineno))) |         *filename = NULL; | ||||||
|  |     } | ||||||
|  |     else { | ||||||
|  |         *filename = _PyUnicode_AsString(v); | ||||||
|  |         Py_DECREF(v); | ||||||
|  |         if (!*filename) | ||||||
|  |             goto finally; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     v = _PyObject_GetAttrId(err, &PyId_lineno); | ||||||
|  |     if (!v) | ||||||
|         goto finally; |         goto finally; | ||||||
|     hold = PyLong_AsLong(v); |     hold = PyLong_AsLong(v); | ||||||
|     Py_DECREF(v); |     Py_DECREF(v); | ||||||
|     v = NULL; |  | ||||||
|     if (hold < 0 && PyErr_Occurred()) |     if (hold < 0 && PyErr_Occurred()) | ||||||
|         goto finally; |         goto finally; | ||||||
|     *lineno = (int)hold; |     *lineno = (int)hold; | ||||||
| 
 | 
 | ||||||
|     if (!(v = _PyObject_GetAttrId(err, &PyId_offset))) |     v = _PyObject_GetAttrId(err, &PyId_offset); | ||||||
|  |     if (!v) | ||||||
|         goto finally; |         goto finally; | ||||||
|     if (v == Py_None) { |     if (v == Py_None) { | ||||||
|         *offset = -1; |         *offset = -1; | ||||||
|         Py_DECREF(v); |         Py_DECREF(v); | ||||||
|         v = NULL; |  | ||||||
|     } else { |     } else { | ||||||
|         hold = PyLong_AsLong(v); |         hold = PyLong_AsLong(v); | ||||||
|         Py_DECREF(v); |         Py_DECREF(v); | ||||||
|         v = NULL; |  | ||||||
|         if (hold < 0 && PyErr_Occurred()) |         if (hold < 0 && PyErr_Occurred()) | ||||||
|             goto finally; |             goto finally; | ||||||
|         *offset = (int)hold; |         *offset = (int)hold; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (!(v = _PyObject_GetAttrId(err, &PyId_text))) |     v = _PyObject_GetAttrId(err, &PyId_text); | ||||||
|         goto finally; |     if (!v) | ||||||
|     if (v == Py_None) |  | ||||||
|         *text = NULL; |  | ||||||
|     else if (!PyUnicode_Check(v) || |  | ||||||
|              !(*text = _PyUnicode_AsString(v))) |  | ||||||
|         goto finally; |         goto finally; | ||||||
|  |     if (v == Py_None) { | ||||||
|         Py_DECREF(v); |         Py_DECREF(v); | ||||||
|  |         *text = NULL; | ||||||
|  |     } | ||||||
|  |     else { | ||||||
|  |         *text = _PyUnicode_AsString(v); | ||||||
|  |         Py_DECREF(v); | ||||||
|  |         if (!*text) | ||||||
|  |             goto finally; | ||||||
|  |     } | ||||||
|     return 1; |     return 1; | ||||||
| 
 | 
 | ||||||
| finally: | finally: | ||||||
|     Py_XDECREF(v); |     Py_XDECREF(*message); | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Benjamin Peterson
						Benjamin Peterson