[Python-checkins] python/dist/src/Python ceval.c,2.411,2.412

mwh at users.sourceforge.net mwh at users.sourceforge.net
Mon Aug 2 16:50:48 CEST 2004


Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22346/Python
Modified Files:
	ceval.c 
Log Message:
Fix for the unfortunate fact that PyDict_GetItem and PyObject_GetItem
have differing refcount semantics. If anyone sees a prettier way to 
acheive the same ends, then please go for it.
I think this is the first time I've ever used Py_XINCREF.
Index: ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.411
retrieving revision 2.412
diff -C2 -d -r2.411 -r2.412
*** ceval.c	2 Aug 2004 08:30:07 -0000	2.411
--- ceval.c	2 Aug 2004 14:50:43 -0000	2.412
***************
*** 1743,1748 ****
 				break;
 			}
! 			if (PyDict_CheckExact(v))
 				x = PyDict_GetItem(v, w);
 			else {
 				x = PyObject_GetItem(v, w);
--- 1743,1750 ----
 				break;
 			}
! 			if (PyDict_CheckExact(v)) {
 				x = PyDict_GetItem(v, w);
+ 				Py_XINCREF(x);
+ 			}
 			else {
 				x = PyObject_GetItem(v, w);
***************
*** 1764,1769 ****
 					}
 				}
 			}
- 			Py_INCREF(x);
 			PUSH(x);
 			continue;
--- 1766,1771 ----
 					}
 				}
+ 				Py_INCREF(x);
 			}
 			PUSH(x);
 			continue;


More information about the Python-checkins mailing list

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