Ronald Oussoren avatar 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.

Comments (0)

Files changed (2)

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>

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;
+		}
 	}
 
 	/*
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.