Skip to content

Commit 301a8db

Browse files
author
georg.brandl
committed
Reformat some ugly code.
git-svn-id: http://svn.python.org/projects/python/trunk@60182 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 61f813e commit 301a8db

2 files changed

Lines changed: 66 additions & 52 deletions

File tree

Lib/test/test_structmembers.py

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,58 +8,59 @@
88
import warnings, exceptions, unittest, sys
99
from test import test_support
1010

11-
ts=test_structmembersType(False,1,2,3,4,5,6,7,8,9.99999,10.1010101010)
11+
ts=test_structmembersType(False, 1, 2, 3, 4, 5, 6, 7, 8,
12+
9.99999, 10.1010101010)
1213

1314
class ReadWriteTests(unittest.TestCase):
1415
def test_types(self):
15-
ts.T_BOOL=True
16+
ts.T_BOOL = True
1617
self.assertEquals(ts.T_BOOL, True)
17-
ts.T_BOOL=False
18+
ts.T_BOOL = False
1819
self.assertEquals(ts.T_BOOL, False)
1920
self.assertRaises(TypeError, setattr, ts, 'T_BOOL', 1)
2021

21-
ts.T_BYTE=CHAR_MAX
22+
ts.T_BYTE = CHAR_MAX
2223
self.assertEquals(ts.T_BYTE, CHAR_MAX)
23-
ts.T_BYTE=CHAR_MIN
24+
ts.T_BYTE = CHAR_MIN
2425
self.assertEquals(ts.T_BYTE, CHAR_MIN)
25-
ts.T_UBYTE=UCHAR_MAX
26+
ts.T_UBYTE = UCHAR_MAX
2627
self.assertEquals(ts.T_UBYTE, UCHAR_MAX)
2728

28-
ts.T_SHORT=SHRT_MAX
29+
ts.T_SHORT = SHRT_MAX
2930
self.assertEquals(ts.T_SHORT, SHRT_MAX)
30-
ts.T_SHORT=SHRT_MIN
31+
ts.T_SHORT = SHRT_MIN
3132
self.assertEquals(ts.T_SHORT, SHRT_MIN)
32-
ts.T_USHORT=USHRT_MAX
33+
ts.T_USHORT = USHRT_MAX
3334
self.assertEquals(ts.T_USHORT, USHRT_MAX)
3435

35-
ts.T_INT=INT_MAX
36+
ts.T_INT = INT_MAX
3637
self.assertEquals(ts.T_INT, INT_MAX)
37-
ts.T_INT=INT_MIN
38+
ts.T_INT = INT_MIN
3839
self.assertEquals(ts.T_INT, INT_MIN)
39-
ts.T_UINT=UINT_MAX
40+
ts.T_UINT = UINT_MAX
4041
self.assertEquals(ts.T_UINT, UINT_MAX)
4142

42-
ts.T_LONG=LONG_MAX
43+
ts.T_LONG = LONG_MAX
4344
self.assertEquals(ts.T_LONG, LONG_MAX)
44-
ts.T_LONG=LONG_MIN
45+
ts.T_LONG = LONG_MIN
4546
self.assertEquals(ts.T_LONG, LONG_MIN)
46-
ts.T_ULONG=ULONG_MAX
47+
ts.T_ULONG = ULONG_MAX
4748
self.assertEquals(ts.T_ULONG, ULONG_MAX)
4849

4950
## T_LONGLONG and T_ULONGLONG may not be present on some platforms
5051
if hasattr(ts, 'T_LONGLONG'):
51-
ts.T_LONGLONG=LLONG_MAX
52+
ts.T_LONGLONG = LLONG_MAX
5253
self.assertEquals(ts.T_LONGLONG, LLONG_MAX)
53-
ts.T_LONGLONG=LLONG_MIN
54+
ts.T_LONGLONG = LLONG_MIN
5455
self.assertEquals(ts.T_LONGLONG, LLONG_MIN)
5556

56-
ts.T_ULONGLONG=ULLONG_MAX
57+
ts.T_ULONGLONG = ULLONG_MAX
5758
self.assertEquals(ts.T_ULONGLONG, ULLONG_MAX)
5859

5960
## make sure these will accept a plain int as well as a long
60-
ts.T_LONGLONG=3
61+
ts.T_LONGLONG = 3
6162
self.assertEquals(ts.T_LONGLONG, 3)
62-
ts.T_ULONGLONG=4
63+
ts.T_ULONGLONG = 4
6364
self.assertEquals(ts.T_ULONGLONG, 4)
6465

6566

@@ -69,32 +70,32 @@ def has_warned(self, w):
6970

7071
def test_byte_max(self):
7172
with test_support.catch_warning() as w:
72-
ts.T_BYTE=CHAR_MAX+1
73+
ts.T_BYTE = CHAR_MAX+1
7374
self.has_warned(w)
7475

7576
def test_byte_min(self):
7677
with test_support.catch_warning() as w:
77-
ts.T_BYTE=CHAR_MIN-1
78+
ts.T_BYTE = CHAR_MIN-1
7879
self.has_warned(w)
7980

8081
def test_ubyte_max(self):
8182
with test_support.catch_warning() as w:
82-
ts.T_UBYTE=UCHAR_MAX+1
83+
ts.T_UBYTE = UCHAR_MAX+1
8384
self.has_warned(w)
8485

8586
def test_short_max(self):
8687
with test_support.catch_warning() as w:
87-
ts.T_SHORT=SHRT_MAX+1
88+
ts.T_SHORT = SHRT_MAX+1
8889
self.has_warned(w)
8990

9091
def test_short_min(self):
9192
with test_support.catch_warning() as w:
92-
ts.T_SHORT=SHRT_MIN-1
93+
ts.T_SHORT = SHRT_MIN-1
9394
self.has_warned(w)
9495

9596
def test_ushort_max(self):
9697
with test_support.catch_warning() as w:
97-
ts.T_USHORT=USHRT_MAX+1
98+
ts.T_USHORT = USHRT_MAX+1
9899
self.has_warned(w)
99100

100101

Modules/_testcapimodule.c

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -804,40 +804,53 @@ static struct PyMemberDef test_members[] = {
804804
};
805805

806806

807-
static PyObject *test_structmembers_new(PyTypeObject *type, PyObject *args, PyObject *kwargs){
808-
static char *keywords[]={"T_BOOL", "T_BYTE", "T_UBYTE", "T_SHORT", "T_USHORT", "T_INT", "T_UINT",
809-
"T_LONG", "T_ULONG", "T_FLOAT", "T_DOUBLE",
810-
#ifdef HAVE_LONG_LONG
807+
static PyObject *
808+
test_structmembers_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
809+
{
810+
static char *keywords[] = {
811+
"T_BOOL", "T_BYTE", "T_UBYTE", "T_SHORT", "T_USHORT",
812+
"T_INT", "T_UINT", "T_LONG", "T_ULONG",
813+
"T_FLOAT", "T_DOUBLE",
814+
#ifdef HAVE_LONG_LONG
811815
"T_LONGLONG", "T_ULONGLONG",
812-
#endif
816+
#endif
813817
NULL};
814-
static char *fmt="|bbBhHiIlkfd"
815-
#ifdef HAVE_LONG_LONG
818+
static char *fmt = "|bbBhHiIlkfd"
819+
#ifdef HAVE_LONG_LONG
816820
"LK"
817-
#endif
821+
#endif
818822
;
819-
test_structmembers *ob=PyObject_New(test_structmembers, type);
820-
if (ob==NULL)
823+
test_structmembers *ob;
824+
ob = PyObject_New(test_structmembers, type);
825+
if (ob == NULL)
821826
return NULL;
822827
memset(&ob->structmembers, 0, sizeof(all_structmembers));
823828
if (!PyArg_ParseTupleAndKeywords(args, kwargs, fmt, keywords,
824-
&ob->structmembers.bool_member,
825-
&ob->structmembers.byte_member, &ob->structmembers.ubyte_member,
826-
&ob->structmembers.short_member, &ob->structmembers.ushort_member,
827-
&ob->structmembers.int_member, &ob->structmembers.uint_member,
828-
&ob->structmembers.long_member, &ob->structmembers.ulong_member,
829-
&ob->structmembers.float_member, &ob->structmembers.double_member
830-
#ifdef HAVE_LONG_LONG
831-
,&ob->structmembers.longlong_member, &ob->structmembers.ulonglong_member
832-
#endif
833-
)){
829+
&ob->structmembers.bool_member,
830+
&ob->structmembers.byte_member,
831+
&ob->structmembers.ubyte_member,
832+
&ob->structmembers.short_member,
833+
&ob->structmembers.ushort_member,
834+
&ob->structmembers.int_member,
835+
&ob->structmembers.uint_member,
836+
&ob->structmembers.long_member,
837+
&ob->structmembers.ulong_member,
838+
&ob->structmembers.float_member,
839+
&ob->structmembers.double_member
840+
#ifdef HAVE_LONG_LONG
841+
, &ob->structmembers.longlong_member,
842+
&ob->structmembers.ulonglong_member
843+
#endif
844+
)) {
834845
Py_DECREF(ob);
835846
return NULL;
836-
}
847+
}
837848
return (PyObject *)ob;
838849
}
839850

840-
static void test_structmembers_free(PyObject *ob){
851+
static void
852+
test_structmembers_free(PyObject *ob)
853+
{
841854
PyObject_FREE(ob);
842855
}
843856

@@ -858,8 +871,8 @@ static PyTypeObject test_structmembersType = {
858871
0, /* tp_hash */
859872
0, /* tp_call */
860873
0, /* tp_str */
861-
PyObject_GenericGetAttr,
862-
PyObject_GenericSetAttr,
874+
PyObject_GenericGetAttr, /* tp_getattro */
875+
PyObject_GenericSetAttr, /* tp_setattro */
863876
0, /* tp_as_buffer */
864877
0, /* tp_flags */
865878
"Type containing all structmember types",
@@ -870,7 +883,7 @@ static PyTypeObject test_structmembersType = {
870883
0, /* tp_iter */
871884
0, /* tp_iternext */
872885
0, /* tp_methods */
873-
test_members, /* tp_members */
886+
test_members, /* tp_members */
874887
0,
875888
0,
876889
0,
@@ -879,7 +892,7 @@ static PyTypeObject test_structmembersType = {
879892
0,
880893
0,
881894
0,
882-
test_structmembers_new, /* tp_new */
895+
test_structmembers_new, /* tp_new */
883896
};
884897

885898

0 commit comments

Comments
 (0)