[Python-checkins] r60182 - in python/trunk: Lib/test/test_structmembers.py Modules/_testcapimodule.c

georg.brandl python-checkins at python.org
Mon Jan 21 22:28:32 CET 2008


Author: georg.brandl
Date: Mon Jan 21 22:28:32 2008
New Revision: 60182
Modified:
 python/trunk/Lib/test/test_structmembers.py
 python/trunk/Modules/_testcapimodule.c
Log:
Reformat some ugly code.
Modified: python/trunk/Lib/test/test_structmembers.py
==============================================================================
--- python/trunk/Lib/test/test_structmembers.py	(original)
+++ python/trunk/Lib/test/test_structmembers.py	Mon Jan 21 22:28:32 2008
@@ -8,58 +8,59 @@
 import warnings, exceptions, unittest, sys
 from test import test_support
 
-ts=test_structmembersType(False,1,2,3,4,5,6,7,8,9.99999,10.1010101010)
+ts=test_structmembersType(False, 1, 2, 3, 4, 5, 6, 7, 8,
+ 9.99999, 10.1010101010)
 
 class ReadWriteTests(unittest.TestCase):
 def test_types(self):
- ts.T_BOOL=True
+ ts.T_BOOL = True
 self.assertEquals(ts.T_BOOL, True)
- ts.T_BOOL=False
+ ts.T_BOOL = False
 self.assertEquals(ts.T_BOOL, False)
 self.assertRaises(TypeError, setattr, ts, 'T_BOOL', 1)
 
- ts.T_BYTE=CHAR_MAX
+ ts.T_BYTE = CHAR_MAX
 self.assertEquals(ts.T_BYTE, CHAR_MAX)
- ts.T_BYTE=CHAR_MIN
+ ts.T_BYTE = CHAR_MIN
 self.assertEquals(ts.T_BYTE, CHAR_MIN)
- ts.T_UBYTE=UCHAR_MAX
+ ts.T_UBYTE = UCHAR_MAX
 self.assertEquals(ts.T_UBYTE, UCHAR_MAX)
 
- ts.T_SHORT=SHRT_MAX
+ ts.T_SHORT = SHRT_MAX
 self.assertEquals(ts.T_SHORT, SHRT_MAX)
- ts.T_SHORT=SHRT_MIN
+ ts.T_SHORT = SHRT_MIN
 self.assertEquals(ts.T_SHORT, SHRT_MIN)
- ts.T_USHORT=USHRT_MAX
+ ts.T_USHORT = USHRT_MAX
 self.assertEquals(ts.T_USHORT, USHRT_MAX)
 
- ts.T_INT=INT_MAX
+ ts.T_INT = INT_MAX
 self.assertEquals(ts.T_INT, INT_MAX)
- ts.T_INT=INT_MIN
+ ts.T_INT = INT_MIN
 self.assertEquals(ts.T_INT, INT_MIN)
- ts.T_UINT=UINT_MAX
+ ts.T_UINT = UINT_MAX
 self.assertEquals(ts.T_UINT, UINT_MAX)
 
- ts.T_LONG=LONG_MAX
+ ts.T_LONG = LONG_MAX
 self.assertEquals(ts.T_LONG, LONG_MAX)
- ts.T_LONG=LONG_MIN
+ ts.T_LONG = LONG_MIN
 self.assertEquals(ts.T_LONG, LONG_MIN)
- ts.T_ULONG=ULONG_MAX
+ ts.T_ULONG = ULONG_MAX
 self.assertEquals(ts.T_ULONG, ULONG_MAX)
 
 ## T_LONGLONG and T_ULONGLONG may not be present on some platforms
 if hasattr(ts, 'T_LONGLONG'):
- ts.T_LONGLONG=LLONG_MAX
+ ts.T_LONGLONG = LLONG_MAX
 self.assertEquals(ts.T_LONGLONG, LLONG_MAX)
- ts.T_LONGLONG=LLONG_MIN
+ ts.T_LONGLONG = LLONG_MIN
 self.assertEquals(ts.T_LONGLONG, LLONG_MIN)
 
- ts.T_ULONGLONG=ULLONG_MAX
+ ts.T_ULONGLONG = ULLONG_MAX
 self.assertEquals(ts.T_ULONGLONG, ULLONG_MAX)
 
 ## make sure these will accept a plain int as well as a long
- ts.T_LONGLONG=3
+ ts.T_LONGLONG = 3
 self.assertEquals(ts.T_LONGLONG, 3)
- ts.T_ULONGLONG=4
+ ts.T_ULONGLONG = 4
 self.assertEquals(ts.T_ULONGLONG, 4)
 
 
@@ -69,32 +70,32 @@
 
 def test_byte_max(self):
 with test_support.catch_warning() as w:
- ts.T_BYTE=CHAR_MAX+1
+ ts.T_BYTE = CHAR_MAX+1
 self.has_warned(w)
 
 def test_byte_min(self):
 with test_support.catch_warning() as w:
- ts.T_BYTE=CHAR_MIN-1
+ ts.T_BYTE = CHAR_MIN-1
 self.has_warned(w)
 
 def test_ubyte_max(self):
 with test_support.catch_warning() as w:
- ts.T_UBYTE=UCHAR_MAX+1
+ ts.T_UBYTE = UCHAR_MAX+1
 self.has_warned(w)
 
 def test_short_max(self):
 with test_support.catch_warning() as w:
- ts.T_SHORT=SHRT_MAX+1
+ ts.T_SHORT = SHRT_MAX+1
 self.has_warned(w)
 
 def test_short_min(self):
 with test_support.catch_warning() as w:
- ts.T_SHORT=SHRT_MIN-1
+ ts.T_SHORT = SHRT_MIN-1
 self.has_warned(w)
 
 def test_ushort_max(self):
 with test_support.catch_warning() as w:
- ts.T_USHORT=USHRT_MAX+1
+ ts.T_USHORT = USHRT_MAX+1
 self.has_warned(w)
 
 
Modified: python/trunk/Modules/_testcapimodule.c
==============================================================================
--- python/trunk/Modules/_testcapimodule.c	(original)
+++ python/trunk/Modules/_testcapimodule.c	Mon Jan 21 22:28:32 2008
@@ -804,40 +804,53 @@
 };
 
 
-static PyObject *test_structmembers_new(PyTypeObject *type, PyObject *args, PyObject *kwargs){
-	static char *keywords[]={"T_BOOL", "T_BYTE", "T_UBYTE", "T_SHORT", "T_USHORT", "T_INT", "T_UINT",
-		"T_LONG", "T_ULONG", "T_FLOAT", "T_DOUBLE",
-		#ifdef HAVE_LONG_LONG	
+static PyObject *
+test_structmembers_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
+{
+	static char *keywords[] = {
+		"T_BOOL", "T_BYTE", "T_UBYTE", "T_SHORT", "T_USHORT",
+		"T_INT", "T_UINT", "T_LONG", "T_ULONG",
+		"T_FLOAT", "T_DOUBLE",
+#ifdef HAVE_LONG_LONG	
 		"T_LONGLONG", "T_ULONGLONG",
-		#endif
+#endif
 		NULL};
-	static char *fmt="|bbBhHiIlkfd"
-		#ifdef HAVE_LONG_LONG
+	static char *fmt = "|bbBhHiIlkfd"
+#ifdef HAVE_LONG_LONG
 		"LK"
-		#endif
+#endif
 		;
-	test_structmembers *ob=PyObject_New(test_structmembers, type);
-	if (ob==NULL)
+	test_structmembers *ob;
+	ob = PyObject_New(test_structmembers, type);
+	if (ob == NULL)
 		return NULL;
 	memset(&ob->structmembers, 0, sizeof(all_structmembers));
 	if (!PyArg_ParseTupleAndKeywords(args, kwargs, fmt, keywords,
-		&ob->structmembers.bool_member,
-		&ob->structmembers.byte_member, &ob->structmembers.ubyte_member,
-		&ob->structmembers.short_member, &ob->structmembers.ushort_member,
-		&ob->structmembers.int_member, &ob->structmembers.uint_member, 
-		&ob->structmembers.long_member, &ob->structmembers.ulong_member,
-		&ob->structmembers.float_member, &ob->structmembers.double_member
-		#ifdef HAVE_LONG_LONG
-		,&ob->structmembers.longlong_member, &ob->structmembers.ulonglong_member
-		#endif
-		)){
+					 &ob->structmembers.bool_member,
+					 &ob->structmembers.byte_member,
+					 &ob->structmembers.ubyte_member,
+					 &ob->structmembers.short_member,
+					 &ob->structmembers.ushort_member,
+					 &ob->structmembers.int_member,
+					 &ob->structmembers.uint_member, 
+					 &ob->structmembers.long_member,
+					 &ob->structmembers.ulong_member,
+					 &ob->structmembers.float_member,
+					 &ob->structmembers.double_member
+#ifdef HAVE_LONG_LONG
+					 , &ob->structmembers.longlong_member,
+					 &ob->structmembers.ulonglong_member
+#endif
+		)) {
 		Py_DECREF(ob);
 		return NULL;
-		}
+	}
 	return (PyObject *)ob;
 }
 
-static void test_structmembers_free(PyObject *ob){
+static void
+test_structmembers_free(PyObject *ob)
+{
 	PyObject_FREE(ob);
 }
 
@@ -858,8 +871,8 @@
 	0,				/* tp_hash */
 	0,				/* tp_call */
 	0,				/* tp_str */
-	PyObject_GenericGetAttr,
-	PyObject_GenericSetAttr,
+	PyObject_GenericGetAttr,	/* tp_getattro */
+	PyObject_GenericSetAttr,	/* tp_setattro */
 	0,				/* tp_as_buffer */
 	0,				/* tp_flags */
 	"Type containing all structmember types",
@@ -870,7 +883,7 @@
 	0,				/* tp_iter */
 	0,				/* tp_iternext */
 	0,				/* tp_methods */
-	test_members,	/* tp_members */
+	test_members,			/* tp_members */
 	0,
 	0,
 	0,
@@ -879,7 +892,7 @@
 	0,
 	0,
 	0,
-	test_structmembers_new,			/* tp_new */
+	test_structmembers_new,	 	/* tp_new */
 };
 
 


More information about the Python-checkins mailing list

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