Commits

Ronald Oussoren  committed 41ae778

- The comment in NSAutoreleasePoolSupport.m was no longer up-to-date
- Issue a warning instead of always printing something when someone calls a
method of uninitialized object.

  • Participants
  • Parent commits 1f38862

Comments (0)

Files changed (2)

File pyobjc/Modules/Foundation/NSAutoreleasePoolSupport.m

  * A category for working with NSAutoreleasePools. This was needed when 
  * PyObjC couldn't be used to create autoreleasepools in the regular way,
  * that is no longer a problem.
- *
- * Should we post a deprication warning?
  */
 #import <Foundation/Foundation.h>
 #include <Python.h>

File pyobjc/Modules/objc/selector.m

 	if (self->sel_self && PyObjCObject_Check(self->sel_self) 
 	    && (((PyObjCObject*)self->sel_self)->flags & PyObjCObject_kUNINITIALIZED)
 	    && !(self->sel_flags & PyObjCSelector_kINITIALIZER)) {
+		char buf[1024];
 
-		PySys_WriteStderr(
+		snprintf(buf, sizeof(buf), 
 			"Calling method (%s) on unitialized object %p of class %s\n",
 			SELNAME(self->sel_selector),
 			(void*)PyObjCObject_GetObject(self->sel_self),
 			GETISA(PyObjCObject_GetObject(self->sel_self))->name);
+
+		if (PyErr_Warn(PyExc_RuntimeWarning, buf) < 0) {
+			return NULL;
+		}
 	}
 
 
 	if ( !(self->sel_flags & PyObjCSelector_kINITIALIZER)
 	     && (self->sel_self) && (PyObjCObject_Check(self->sel_self)) &&
 	     ((PyObjCObject*)self->sel_self)->flags & PyObjCObject_kUNINITIALIZED) {
+		char buf[1024];
 
-		PySys_WriteStderr(
-		    "Calling method (%s) on unitialized object %p of class %s\n",
-		    SELNAME(self->sel_selector),
-		    (void*)PyObjCObject_GetObject(self->sel_self),
-		    GETISA(PyObjCObject_GetObject(self->sel_self))->name);
+		snprintf(buf, sizeof(buf), 
+		   "Calling method (%s) on unitialized object %p of class %s\n",
+		   SELNAME(self->sel_selector),
+		   (void*)PyObjCObject_GetObject(self->sel_self),
+		   GETISA(PyObjCObject_GetObject(self->sel_self))->name);
 
+		if (PyErr_Warn(PyExc_RuntimeWarning, buf) < 0) {
+			return NULL;
+		}
 	}
 
 	/*