Skip to content

Commit f04e72a

Browse files
author
gvanrossum
committed
Patch supplied by Burton Radons for his own SF bug #487390: Modifying
type.__module__ behavior. This adds the module name and a dot in front of the type name in every type object initializer, except for built-in types (and those that already had this). Note that it touches lots of Mac modules -- I have no way to test these but the changes look right. Apologies if they're not. This also touches the weakref docs, which contains a sample type object initializer. It also touches the mmap test output, because the mmap type's repr is included in that output. It touches object.h to put the correct description in a comment. git-svn-id: http://svn.python.org/projects/python/trunk@24626 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 39c048c commit f04e72a

68 files changed

Lines changed: 116 additions & 113 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Doc/lib/libweakref.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ \subsection{Weak References in Extension Types
234234
PyTypeObject PyInstance_Type = {
235235
PyObject_HEAD_INIT(&PyType_Type)
236236
0,
237-
"instance",
237+
"module.instance",
238238
239239
/* Lots of stuff omitted for brevity... */
240240

Include/object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ typedef PyObject *(*allocfunc)(struct _typeobject *, int);
219219

220220
typedef struct _typeobject {
221221
PyObject_VAR_HEAD
222-
char *tp_name; /* For printing */
222+
char *tp_name; /* For printing, in format "<module>.<name>" */
223223
int tp_basicsize, tp_itemsize; /* For allocation */
224224

225225
/* Methods to implement standard operations */

Lib/test/output/test_mmap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
test_mmap
2-
<type 'mmap'>
2+
<type 'mmap.mmap'>
33
Position of foo: 1.0 pages
44
Length of file: 2.0 pages
55
Contents of byte 0: '\x00'

Mac/Lib/test/mkcwproj/mkcwtestmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ statichere PyTypeObject Xxo_Type = {
9898
* to be portable to Windows without using C++. */
9999
PyObject_HEAD_INIT(NULL)
100100
0, /*ob_size*/
101-
"Xxo", /*tp_name*/
101+
"Xxmodule.Xxo", /*tp_name*/
102102
sizeof(XxoObject), /*tp_basicsize*/
103103
0, /*tp_itemsize*/
104104
/* methods */

Mac/Modules/Nav.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ static char Navrrtype__doc__[] =
387387
static PyTypeObject Navrrtype = {
388388
PyObject_HEAD_INIT(&PyType_Type)
389389
0, /*ob_size*/
390-
"NavReplyRecord", /*tp_name*/
390+
"Nav.NavReplyRecord", /*tp_name*/
391391
sizeof(navrrobject), /*tp_basicsize*/
392392
0, /*tp_itemsize*/
393393
/* methods */

Mac/Modules/ae/_AEmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ static PyObject *AEDesc_getattr(AEDescObject *self, char *name)
782782
PyTypeObject AEDesc_Type = {
783783
PyObject_HEAD_INIT(NULL)
784784
0, /*ob_size*/
785-
"AEDesc", /*tp_name*/
785+
"_AE.AEDesc", /*tp_name*/
786786
sizeof(AEDescObject), /*tp_basicsize*/
787787
0, /*tp_itemsize*/
788788
/* methods */

Mac/Modules/calldll.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ static char Cdrtype__doc__[] =
565565
static PyTypeObject Cdrtype = {
566566
PyObject_HEAD_INIT(&PyType_Type)
567567
0, /*ob_size*/
568-
"routine", /*tp_name*/
568+
"calldll.routine", /*tp_name*/
569569
sizeof(cdrobject), /*tp_basicsize*/
570570
0, /*tp_itemsize*/
571571
/* methods */
@@ -755,7 +755,7 @@ static char Cdctype__doc__[] =
755755
static PyTypeObject Cdctype = {
756756
PyObject_HEAD_INIT(&PyType_Type)
757757
0, /*ob_size*/
758-
"callable", /*tp_name*/
758+
"calldll.callable", /*tp_name*/
759759
sizeof(cdcobject), /*tp_basicsize*/
760760
0, /*tp_itemsize*/
761761
/* methods */
@@ -964,7 +964,7 @@ static char Cdftype__doc__[] =
964964
static PyTypeObject Cdftype = {
965965
PyObject_HEAD_INIT(&PyType_Type)
966966
0, /*ob_size*/
967-
"fragment", /*tp_name*/
967+
"calldll.fragment", /*tp_name*/
968968
sizeof(cdfobject), /*tp_basicsize*/
969969
0, /*tp_itemsize*/
970970
/* methods */

Mac/Modules/carbonevt/_CarbonEvt.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ static PyObject *EventRef_getattr(EventRefObject *self, char *name)
356356
PyTypeObject EventRef_Type = {
357357
PyObject_HEAD_INIT(&PyType_Type)
358358
0, /*ob_size*/
359-
"EventRef", /*tp_name*/
359+
"CarbonEvents.EventRef", /*tp_name*/
360360
sizeof(EventRefObject), /*tp_basicsize*/
361361
0, /*tp_itemsize*/
362362
/* methods */
@@ -539,7 +539,7 @@ static PyObject *EventQueueRef_getattr(EventQueueRefObject *self, char *name)
539539
PyTypeObject EventQueueRef_Type = {
540540
PyObject_HEAD_INIT(&PyType_Type)
541541
0, /*ob_size*/
542-
"EventQueueRef", /*tp_name*/
542+
"CarbonEvents.EventQueueRef", /*tp_name*/
543543
sizeof(EventQueueRefObject), /*tp_basicsize*/
544544
0, /*tp_itemsize*/
545545
/* methods */
@@ -631,7 +631,7 @@ static PyObject *EventLoopRef_getattr(EventLoopRefObject *self, char *name)
631631
PyTypeObject EventLoopRef_Type = {
632632
PyObject_HEAD_INIT(&PyType_Type)
633633
0, /*ob_size*/
634-
"EventLoopRef", /*tp_name*/
634+
"CarbonEvents.EventLoopRef", /*tp_name*/
635635
sizeof(EventLoopRefObject), /*tp_basicsize*/
636636
0, /*tp_itemsize*/
637637
/* methods */
@@ -741,7 +741,7 @@ static PyObject *EventLoopTimerRef_getattr(EventLoopTimerRefObject *self, char *
741741
PyTypeObject EventLoopTimerRef_Type = {
742742
PyObject_HEAD_INIT(&PyType_Type)
743743
0, /*ob_size*/
744-
"EventLoopTimerRef", /*tp_name*/
744+
"CarbonEvents.EventLoopTimerRef", /*tp_name*/
745745
sizeof(EventLoopTimerRefObject), /*tp_basicsize*/
746746
0, /*tp_itemsize*/
747747
/* methods */
@@ -875,7 +875,7 @@ static PyObject *EventHandlerRef_getattr(EventHandlerRefObject *self, char *name
875875
PyTypeObject EventHandlerRef_Type = {
876876
PyObject_HEAD_INIT(&PyType_Type)
877877
0, /*ob_size*/
878-
"EventHandlerRef", /*tp_name*/
878+
"CarbonEvents.EventHandlerRef", /*tp_name*/
879879
sizeof(EventHandlerRefObject), /*tp_basicsize*/
880880
0, /*tp_itemsize*/
881881
/* methods */
@@ -970,7 +970,7 @@ static PyObject *EventHandlerCallRef_getattr(EventHandlerCallRefObject *self, ch
970970
PyTypeObject EventHandlerCallRef_Type = {
971971
PyObject_HEAD_INIT(&PyType_Type)
972972
0, /*ob_size*/
973-
"EventHandlerCallRef", /*tp_name*/
973+
"CarbonEvents.EventHandlerCallRef", /*tp_name*/
974974
sizeof(EventHandlerCallRefObject), /*tp_basicsize*/
975975
0, /*tp_itemsize*/
976976
/* methods */
@@ -1085,7 +1085,7 @@ static PyObject *EventTargetRef_getattr(EventTargetRefObject *self, char *name)
10851085
PyTypeObject EventTargetRef_Type = {
10861086
PyObject_HEAD_INIT(&PyType_Type)
10871087
0, /*ob_size*/
1088-
"EventTargetRef", /*tp_name*/
1088+
"CarbonEvents.EventTargetRef", /*tp_name*/
10891089
sizeof(EventTargetRefObject), /*tp_basicsize*/
10901090
0, /*tp_itemsize*/
10911091
/* methods */
@@ -1162,7 +1162,7 @@ static PyObject *EventHotKeyRef_getattr(EventHotKeyRefObject *self, char *name)
11621162
PyTypeObject EventHotKeyRef_Type = {
11631163
PyObject_HEAD_INIT(&PyType_Type)
11641164
0, /*ob_size*/
1165-
"EventHotKeyRef", /*tp_name*/
1165+
"CarbonEvents.EventHotKeyRef", /*tp_name*/
11661166
sizeof(EventHotKeyRefObject), /*tp_basicsize*/
11671167
0, /*tp_itemsize*/
11681168
/* methods */

Mac/Modules/cf/_CFmodule.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ static int CFTypeRefObj_hash(CFTypeRefObject *self)
336336
PyTypeObject CFTypeRef_Type = {
337337
PyObject_HEAD_INIT(NULL)
338338
0, /*ob_size*/
339-
"CFTypeRef", /*tp_name*/
339+
"_CF.CFTypeRef", /*tp_name*/
340340
sizeof(CFTypeRefObject), /*tp_basicsize*/
341341
0, /*tp_itemsize*/
342342
/* methods */
@@ -488,7 +488,7 @@ static int CFArrayRefObj_hash(CFArrayRefObject *self)
488488
PyTypeObject CFArrayRef_Type = {
489489
PyObject_HEAD_INIT(NULL)
490490
0, /*ob_size*/
491-
"CFArrayRef", /*tp_name*/
491+
"_CF.CFArrayRef", /*tp_name*/
492492
sizeof(CFArrayRefObject), /*tp_basicsize*/
493493
0, /*tp_itemsize*/
494494
/* methods */
@@ -647,7 +647,7 @@ static int CFMutableArrayRefObj_hash(CFMutableArrayRefObject *self)
647647
PyTypeObject CFMutableArrayRef_Type = {
648648
PyObject_HEAD_INIT(NULL)
649649
0, /*ob_size*/
650-
"CFMutableArrayRef", /*tp_name*/
650+
"_CF.CFMutableArrayRef", /*tp_name*/
651651
sizeof(CFMutableArrayRefObject), /*tp_basicsize*/
652652
0, /*tp_itemsize*/
653653
/* methods */
@@ -781,7 +781,7 @@ static int CFDictionaryRefObj_hash(CFDictionaryRefObject *self)
781781
PyTypeObject CFDictionaryRef_Type = {
782782
PyObject_HEAD_INIT(NULL)
783783
0, /*ob_size*/
784-
"CFDictionaryRef", /*tp_name*/
784+
"_CF.CFDictionaryRef", /*tp_name*/
785785
sizeof(CFDictionaryRefObject), /*tp_basicsize*/
786786
0, /*tp_itemsize*/
787787
/* methods */
@@ -899,7 +899,7 @@ static int CFMutableDictionaryRefObj_hash(CFMutableDictionaryRefObject *self)
899899
PyTypeObject CFMutableDictionaryRef_Type = {
900900
PyObject_HEAD_INIT(NULL)
901901
0, /*ob_size*/
902-
"CFMutableDictionaryRef", /*tp_name*/
902+
"_CF.CFMutableDictionaryRef", /*tp_name*/
903903
sizeof(CFMutableDictionaryRefObject), /*tp_basicsize*/
904904
0, /*tp_itemsize*/
905905
/* methods */
@@ -1051,7 +1051,7 @@ static int CFDataRefObj_hash(CFDataRefObject *self)
10511051
PyTypeObject CFDataRef_Type = {
10521052
PyObject_HEAD_INIT(NULL)
10531053
0, /*ob_size*/
1054-
"CFDataRef", /*tp_name*/
1054+
"_CF.CFDataRef", /*tp_name*/
10551055
sizeof(CFDataRefObject), /*tp_basicsize*/
10561056
0, /*tp_itemsize*/
10571057
/* methods */
@@ -1257,7 +1257,7 @@ static int CFMutableDataRefObj_hash(CFMutableDataRefObject *self)
12571257
PyTypeObject CFMutableDataRef_Type = {
12581258
PyObject_HEAD_INIT(NULL)
12591259
0, /*ob_size*/
1260-
"CFMutableDataRef", /*tp_name*/
1260+
"_CF.CFMutableDataRef", /*tp_name*/
12611261
sizeof(CFMutableDataRefObject), /*tp_basicsize*/
12621262
0, /*tp_itemsize*/
12631263
/* methods */
@@ -1890,7 +1890,7 @@ static int CFStringRefObj_hash(CFStringRefObject *self)
18901890
PyTypeObject CFStringRef_Type = {
18911891
PyObject_HEAD_INIT(NULL)
18921892
0, /*ob_size*/
1893-
"CFStringRef", /*tp_name*/
1893+
"_CF.CFStringRef", /*tp_name*/
18941894
sizeof(CFStringRefObject), /*tp_basicsize*/
18951895
0, /*tp_itemsize*/
18961896
/* methods */
@@ -2197,7 +2197,7 @@ static int CFMutableStringRefObj_hash(CFMutableStringRefObject *self)
21972197
PyTypeObject CFMutableStringRef_Type = {
21982198
PyObject_HEAD_INIT(NULL)
21992199
0, /*ob_size*/
2200-
"CFMutableStringRef", /*tp_name*/
2200+
"_CF.CFMutableStringRef", /*tp_name*/
22012201
sizeof(CFMutableStringRefObject), /*tp_basicsize*/
22022202
0, /*tp_itemsize*/
22032203
/* methods */
@@ -2601,7 +2601,7 @@ static int CFURLRefObj_hash(CFURLRefObject *self)
26012601
PyTypeObject CFURLRef_Type = {
26022602
PyObject_HEAD_INIT(NULL)
26032603
0, /*ob_size*/
2604-
"CFURLRef", /*tp_name*/
2604+
"_CF.CFURLRef", /*tp_name*/
26052605
sizeof(CFURLRefObject), /*tp_basicsize*/
26062606
0, /*tp_itemsize*/
26072607
/* methods */

Mac/Modules/cm/_Cmmodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ static PyObject *CmpInstObj_getattr(ComponentInstanceObject *self, char *name)
289289
PyTypeObject ComponentInstance_Type = {
290290
PyObject_HEAD_INIT(NULL)
291291
0, /*ob_size*/
292-
"ComponentInstance", /*tp_name*/
292+
"_Cm.ComponentInstance", /*tp_name*/
293293
sizeof(ComponentInstanceObject), /*tp_basicsize*/
294294
0, /*tp_itemsize*/
295295
/* methods */
@@ -616,7 +616,7 @@ static PyObject *CmpObj_getattr(ComponentObject *self, char *name)
616616
PyTypeObject Component_Type = {
617617
PyObject_HEAD_INIT(NULL)
618618
0, /*ob_size*/
619-
"Component", /*tp_name*/
619+
"_Cm.Component", /*tp_name*/
620620
sizeof(ComponentObject), /*tp_basicsize*/
621621
0, /*tp_itemsize*/
622622
/* methods */

0 commit comments

Comments
 (0)