[PyObjC-svn] r2599 - in branches/pyobjc-2.3.x: . pyobjc-framework-Cocoa/Modules pyobjc-framework-Cocoa/PyObjCTest
[email protected] Tue, 05 Oct 2010 07:18:29 -0500
| Newsgroups | gmane.comp.python.pyobjc.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: ronaldoussoren
Date: Tue Oct 5 07:18:29 2010
New Revision: 2599
Log:
Merged revisions 2597 via svnmerge from
https://svn.red-bean.com/pyobjc/trunk/pyobjc
........
r2597 | ronaldoussoren | 2010-10-05 14:15:27 +0200 (Tue, 05 Oct 2010) | 3 lines
- Small tweaks for the nsdata tests
- Ensure nsbitmap wrappers work with python2.6
........
Modified:
branches/pyobjc-2.3.x/ (props changed)
branches/pyobjc-2.3.x/pyobjc-framework-Cocoa/Modules/_AppKit_nsbitmap.m
branches/pyobjc-2.3.x/pyobjc-framework-Cocoa/PyObjCTest/test_nsdata.py
Modified: branches/pyobjc-2.3.x/pyobjc-framework-Cocoa/Modules/_AppKit_nsbitmap.m
==============================================================================
--- branches/pyobjc-2.3.x/pyobjc-framework-Cocoa/Modules/_AppKit_nsbitmap.m (original)
+++ branches/pyobjc-2.3.x/pyobjc-framework-Cocoa/Modules/_AppKit_nsbitmap.m Tue Oct 5 07:18:29 2010
@@ -403,7 +403,7 @@
if (result != NULL) {
for(i=0; i<5; i++) {
if (dataPlanes[i]) {
-#if PY_VERSION_HEX <= 0x02069900
+#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 6
PyObject* buffer = PyBuffer_FromReadWriteMemory(dataPlanes[i], bytesPerPlane);
#else
Py_buffer info;
@@ -465,7 +465,7 @@
return NULL;
}
-#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 6
+#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 6
result = PyBuffer_FromReadWriteMemory(bitmapData, bytesPerPlane);
#else
@@ -473,16 +473,6 @@
* interface, therefore create a mutable bytes object to do that for us.
*/
Py_buffer info;
-#if 0
- NSMutableData* data = [[NSMutableData alloc] initWithBytesNoCopy:bitmapData length: bytesPerPlane freeWhenDone:NO];
- PyObject* bytesBuf = PyObjC_ObjCToPython("@", &data);
- [data release];
- if (bytesBuf == NULL) {
- return NULL;
- }
-
- if (PyBuffer_FillInfo(&info, bytesBuf, bitmapData, bytesPerPlane, 0, PyBUF_FULL) < 0) {
-#endif
if (PyBuffer_FillInfo(&info, NULL, bitmapData, bytesPerPlane, 0, PyBUF_FULL) < 0) {
return NULL;
}
Modified: branches/pyobjc-2.3.x/pyobjc-framework-Cocoa/PyObjCTest/test_nsdata.py
==============================================================================
--- branches/pyobjc-2.3.x/pyobjc-framework-Cocoa/PyObjCTest/test_nsdata.py (original)
+++ branches/pyobjc-2.3.x/pyobjc-framework-Cocoa/PyObjCTest/test_nsdata.py Tue Oct 5 07:18:29 2010
@@ -99,7 +99,11 @@
bytesValue = data.bytes()
self.assertEqual(len(bytesValue), len(rawBytes), "bytes() and rawBytes not equal length.")
- self.assertEquals(rawBytes, bytesValue)
+ if sys.version_info[:2] <= (2,6):
+ self.assertEquals(buffer(rawBytes), bytesValue)
+
+ else:
+ self.assertEquals(rawBytes, bytesValue)
try:
bytesValue[3] = b'\xAE'
@@ -281,7 +285,17 @@
self.assertEqual(buffer(m)[:], m[:])
+class TestRegressions (TestCase):
+ def testDataStr(self):
+ if sys.version_info[0] == 2:
+ input = buffer("hello")
+ input_str = "hello"
+ else:
+ input = b"hello"
+ input_str = str(input)
+ buf = NSData.dataWithData_(input)
+ self.assertEquals(str(buf), input_str)
if __name__ == '__main__':
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb