diff Python/peephole.c @ 56830:97d7cd365dd5 2.6

Merged revisions 73206,73232,73299,73683,74020,74185,74544,74643,74647,74817,74838-74839,74865,74946,75402,75459,75604,75696 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r73206 | georg.brandl | 2009-06-04 11:15:12 +0200 (Do, 04 Jun 2009) | 1 line #3584: ignore trailing newlines when placing the caret for a SyntaxError location. ........ r73232 | georg.brandl | 2009-06-04 20:59:58 +0200 (Do, 04 Jun 2009) | 1 line Add test for #3684. ........ r73299 | georg.brandl | 2009-06-08 20:41:36 +0200 (Mo, 08 Jun 2009) | 1 line Typo fix. ........ r73683 | georg.brandl | 2009-06-29 16:44:49 +0200 (Mo, 29 Jun 2009) | 1 line Fix error handling in PyCode_Optimize, by Alexander Schremmer at EuroPython sprint. ........ r74020 | georg.brandl | 2009-07-16 09:18:07 +0200 (Do, 16 Jul 2009) | 1 line #5910: fix kqueue for calls with more than one event. ........ r74185 | georg.brandl | 2009-07-23 11:17:09 +0200 (Do, 23 Jul 2009) | 1 line Fix the "pylocals" gdb command. ........ r74544 | georg.brandl | 2009-08-24 19:12:30 +0200 (Mo, 24 Aug 2009) | 1 line #6775: fix python.org URLs in README. ........ r74643 | georg.brandl | 2009-09-04 08:59:20 +0200 (Fr, 04 Sep 2009) | 2 lines Issue #2666: Handle BROWSER environment variable properly for unknown browser names in the webbrowser module. ........ r74647 | georg.brandl | 2009-09-04 10:17:04 +0200 (Fr, 04 Sep 2009) | 2 lines Issue #5275: In Cookie's Cookie.load(), properly handle non-string arguments as documented. ........ r74817 | georg.brandl | 2009-09-16 11:05:11 +0200 (Mi, 16 Sep 2009) | 1 line Make deprecation notices as visible as warnings are right now. ........ r74838 | georg.brandl | 2009-09-16 18:22:12 +0200 (Mi, 16 Sep 2009) | 1 line Remove some more boilerplate from the actual tests in test_pdb. ........ r74839 | georg.brandl | 2009-09-16 18:36:39 +0200 (Mi, 16 Sep 2009) | 1 line Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that. ........ r74865 | georg.brandl | 2009-09-17 09:49:37 +0200 (Do, 17 Sep 2009) | 1 line #6912: add "with" block support to pindent. ........ r74946 | georg.brandl | 2009-09-19 10:43:16 +0200 (Sa, 19 Sep 2009) | 1 line Update bug tracker reference. ........ r75402 | georg.brandl | 2009-10-14 17:51:48 +0200 (Mi, 14 Okt 2009) | 1 line #7125: fix typo. ........ r75459 | georg.brandl | 2009-10-17 10:57:43 +0200 (Sa, 17 Okt 2009) | 1 line Fix refleaks in _ctypes PyCSimpleType_New, which fixes the refleak seen in test___all__. ........ r75604 | georg.brandl | 2009-10-22 13:36:50 +0200 (Do, 22 Okt 2009) | 1 line Fix stylesheet for multi-paragraph impl-details. ........ r75696 | georg.brandl | 2009-10-25 21:25:43 +0100 (So, 25 Okt 2009) | 1 line Fix a demo. ........
author Georg Brandl <georg@python.org>
date Tue, 27 Oct 2009 15:39:53 +0000
parents 52294af4b663
children e38335d4df91
line wrap: on
line diff
--- a/Python/peephole.c	Tue Oct 27 15:10:48 2009 +0000
+++ b/Python/peephole.c	Tue Oct 27 15:39:53 2009 +0000
@@ -297,7 +297,7 @@
 
 	/* Bail out if an exception is set */
 	if (PyErr_Occurred())
-		goto exitUnchanged;
+		goto exitError;
 
 	/* Bypass optimization when the lineno table is too complex */
 	assert(PyString_Check(lineno_obj));
@@ -315,7 +315,7 @@
 	/* Make a modifiable copy of the code string */
 	codestr = (unsigned char *)PyMem_Malloc(codelen);
 	if (codestr == NULL)
-		goto exitUnchanged;
+		goto exitError;
 	codestr = (unsigned char *)memcpy(codestr, 
 					  PyString_AS_STRING(code), codelen);
 
@@ -330,11 +330,11 @@
 	/* Mapping to new jump targets after NOPs are removed */
 	addrmap = (int *)PyMem_Malloc(codelen * sizeof(int));
 	if (addrmap == NULL)
-		goto exitUnchanged;
+		goto exitError;
 
 	blocks = markblocks(codestr, codelen);
 	if (blocks == NULL)
-		goto exitUnchanged;
+		goto exitError;
 	assert(PyList_Check(consts));
 
 	for (i=0 ; i<codelen ; i += CODESIZE(codestr[i])) {
@@ -391,7 +391,7 @@
 				}
 				if (j == PyList_GET_SIZE(consts)) {
 					if (PyList_Append(consts, Py_None) == -1)
-					        goto exitUnchanged;                                        
+					        goto exitError;
 				}
 				assert(PyList_GET_ITEM(consts, j) == Py_None);
 				codestr[i] = LOAD_CONST;
@@ -618,6 +618,9 @@
 	PyMem_Free(blocks);
 	return code;
 
+ exitError:
+	code = NULL;
+
  exitUnchanged:
 	if (blocks != NULL)
 		PyMem_Free(blocks);
@@ -625,6 +628,6 @@
 		PyMem_Free(addrmap);
 	if (codestr != NULL)
 		PyMem_Free(codestr);
-	Py_INCREF(code);
+	Py_XINCREF(code);
 	return code;
 }