[Python-bugs-list] [ python-Bugs-487390 ] Modifying type.__module__ behavior

noreply@sourceforge.net noreply@sourceforge.net
Thu, 29 Nov 2001 21:10:32 -0800


Bugs item #487390, was opened at 2001-11-29 21:10
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=487390&group_id=5470

Category: Python Library
Group: Feature Request
Status: Open
Resolution: None
Priority: 5
Submitted By: Burton Radons (loth)
Assigned to: Nobody/Anonymous (nobody)
Summary: Modifying type.__module__ behavior

Initial Comment:
A __module__ attribute request on a C type will return
__builtin__ if the typeobject.c code cannot find a
period in the type name.  This is always incorrect for
extension libraries, and can be a _very_ confusing
error when trying to pickle your types (as the error
makes it seem as if you're supposed to register your
type in __builtin__).  I propose that:

A) All builtin Python types have a "__builtin__."
prefixed to their type declaration's name.

B) If the __module__ code cannot find a period, it
raises AttributeError with a somewhat descriptive
message.  This would be in the place where it returns
__builtin__.

C) The tp_name comment in Include/object.h describe the
special semantics.  "/* 'module.typename' */", for example.

This is a lot of files to change, I know, but it's only
one or two line changes each file.  The only code this
should affect is code which is written incorrectly; it
may not understand the name semantics, or it may
actually be registering itself in __builtin__ (as I did
before I figured out what it was doing).  Otherwise
we're golden.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=487390&group_id=5470