Commits

Ronald Oussoren committed 8e2d80c

- Update HTML files
- Make sure testcases that use the warnings module also work on Python 2.2
- Fix bug #814683. We didn't initialize the memory used to store output
arguments and some API's don't always write data into the output parameters,
the combination is a receipe for disaster.

Comments (0)

Files changed (7)

pyobjc/Doc/index.html

 <p>PyObjC is a bridge between Python and Objective-C. It allows you to write
 Python scripts that use and extend existing Objective-C class libraries,
 most importantly the <a href="http://developer.apple.com/techpubs/macosx/Cocoa/CocoaTopics.html">Cocoa libraries</a> by <a href="http://www.apple.com/">Apple</a>.</p>
+<p>More information can be found on <a href="http://pyobjc.sf.net">our website</a></p>
 <h2><a name="general-user-documentation">General user documentation</a></h2>
 <p>The following documents are usefull when you're interested in developing
 Cocoa applications in Python.</p>

pyobjc/Doc/tutorial/tutorial.html

 <pre>
 $ export PYLIB=/Library/Frameworks/Python.framework/Versions/Current/lib/python2.3
 </pre>
-<p>For Apple's <code><span>/usr/bin/python</span></code> set the variable to <code><span>/usr/lib/python2.2</span></code>.</p>
+<p>For Apple's <code><span>/usr/bin/python</span></code> set the variable to <code><span>/usr/lib/python2.2</span></code>,
+if you are running on MacOS X set it to <code><span>/System/Library/Frameworks/Python.framework/Versions/Current/lib/python2.3</span></code>.</p>
 </li>
 <li>Start Interface Builder, select <i>Cocoa Application</i>
 in the new file dialog, save this file as <code><span>src/MainMenu.nib</span></code>.</li>
 <h2><a name="testing-the-user-interface">Testing the user interface</a></h2>
 <ol start="6" type="1">
 <li>Now we need to create an application framework around our program. Again,
-in the future it could well be that this step is not needed during development,
-or that it becomes simpler, but for now we do the following:<pre>
+in the future it could well be that this step is not needed during 
+development, or that it becomes simpler, but for now we do the following:<pre>
 $ python $PYLIB/site-packages/PyObjC/bundlebuilder.py --link --nib=MainMenu \
         --mainprogram=CurrencyConverter.py --resource=MainMenu.nib build
 </pre>
+<p>If you are using Python 2.3 the script is located in <code><span>plat-mac</span></code> instead
+of <code><span>site-packages</span></code> and the command is:</p>
+<pre>
+$ python2.3 $PYLIB/plat-mac/PyObjC/bundlebuilder.py --link --nib=MainMenu \
+        --mainprogram=CurrencyConverter.py --resource=MainMenu.nib build
+</pre>
 <p>There are a few things to note:</p>
 <ul>
 <li>We use the <code><span>--link</span></code> argument. This creates a <code><span>.app</span></code> bundle which has symlinks

pyobjc/Installer Package/ReadMe.html

 a number of modules that are wrappers for the Cocoa frameworks, such as
 Foundation and AppKit. These modules not only give you access to the classes in
 these frameworks but also to the functions and constants in those modules.</p>
+<p>More information on PyObjC can be found on 
+<a href="http://pyobjc.sf.net">our website</a>.</p>
 <p>To install this package double-click on <code><span>PyObjC.pkg</span></code>. This will install the
 PyObjC python package and some Project Builder templates. The documentation
 and examples are found in  the folder <code><span>PyObjC</span> <span>Documentation</span> <span>and</span> <span>Examples</span></code>. 

pyobjc/Lib/Foundation/test/test_nsautoreleasepool.py

         # The actual test will issue a DeprecationWarning, the warnings code
         # below surpresses that warning.
         import warnings
-        warnings.simplefilter('ignore', category=DeprecationWarning)
+        warnings.filterwarnings('ignore', category=DeprecationWarning)
         try:
             NSAutoreleasePool.pyobjcPushPool()
             bar = NSMutableArray.array()

pyobjc/Lib/objc/test/test_regr.py

         import Foundation
 
         o = Foundation.NSObject.alloc() # Not yet initialized
-        warnings.simplefilter('error', RuntimeWarning)
+        warnings.filterwarnings('error', category=RuntimeWarning)
         try:
             self.assertRaises(RuntimeWarning, o.description)
         finally:
             del warnings.filters[0]
 
+    def testMemoryInit(self):
+        """
+        Regression test for bug #814683, that didn't initialize the memory
+        space for output parameters correctly.
+        """
+        import Foundation
+        plist = 0
+        r = Foundation.NSPropertyListSerialization.dataFromPropertyList_format_errorDescription_(plist, Foundation.NSPropertyListXMLFormat_v1_0)
+        self.assertEquals(r[1], None)
+        r = Foundation.NSPropertyListSerialization.dataFromPropertyList_format_errorDescription_(plist, Foundation.NSPropertyListXMLFormat_v1_0)
+        self.assertEquals(r[1], None)
+
 if __name__ == '__main__':
     unittest.main()

pyobjc/Modules/objc/libffi_support.m

 
 		if (argtype[0] == _C_OUT && argtype[1] == _C_PTR) {
 			/* Just allocate room in argbuf and set that*/
+			int sz;
+
 			argbuf_cur = align(argbuf_cur, 
 				objc_alignof_type(argtype+2));
 			arg = argbuf + argbuf_cur;
 			arglist[arglistOffset + i] = &ffi_type_pointer;
 			values[arglistOffset + i] = byref+i;
 
-			argbuf_cur += objc_sizeof_type(argtype+2);
+			sz = objc_sizeof_type(argtype+2);
+			memset(arg, 0, sz);
+			argbuf_cur += sz;
 		} else {
 			/* Encode argument, maybe after allocating space */
 

pyobjc/Scripts/make_distrib.py

 #!/usr/bin/env python
 
+# Build the distribution. Requires Python2.2 on Jaguar, docutils and DocArticle.
+# 
+# NOTES: Really needs a rewrite!
+
 import sys
 import getopt
 import os
 for ln in fd.xreadlines():
 	sys.stdout.write(ln)
 
+
 print "Running: '%s' setup.py install --prefix='%s/package%s' --install-scripts=%s/package%s/lib/python%s/site-packages/PyObjC/bin"%(
 	escquotes(PYTHON), escquotes(BUILDDIR), escquotes(basedir), escquotes(BUILDDIR), escquotes(basedir), PYTHONVER)
 fd = os.popen("'%s' setup.py install --prefix='%s/package%s' --install-scripts=%s/package%s/lib/python%s/site-packages/PyObjC/bin"%(
 	Relocatable="NO",
         RootVolumeOnly="YES")
 
+#
+# build 'objc_extras.tar.gz', and archive containing stuff not included in
+# the binary PackMan installer (which is built manually)
+#
+print "Running: '%s' setup.py bdist -d '%s'"%(
+			escquotes("python2.3"), escquotes(OUTPUTDIR))
+fd = os.popen("'%s' setup.py bdist -d '%s'"%(
+			escquotes("python2.3"), escquotes(OUTPUTDIR)), 'r')
+for ln in fd.xreadlines():
+	sys.stdout.write(ln)
+
+print 'building "pyobjc_extras-%s.tar.gz"'%(package_version(),)
+OUTPUTDIR='release-dir/extra_work/Applications/MacPython-2.3/Extras/pyobjc-%s'%(
+        package_version(),)
+makeDir(*(OUTPUTDIR.split('/')))
+shutil.copytree(docsDestination, os.path.join(OUTPUTDIR, "Doc"))
+shutil.copytree(examplesDestination, os.path.join(OUTPUTDIR, "Examples"))
+for fn in [ 
+    'HISTORIC.txt', 'Install.html', 'Install.txt', 'License.txt',
+    'NEWS.html', 'ReadMe.html', 'ReadMe.txt' ]:
+
+        shutil.copyfile(fn, os.path.join(OUTPUTDIR, fn))
+
+os.system('cd release-dir/extra_work && tar zcf ../pyobjc_extras-%s.tar.gz Applications/MacPython-2.3/Extras/pyobjc-%s'%(
+        package_version(), package_version()))
+
+
 print "Done. Don't forget to test the output!"