<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,26 @@
+2009/04/30 22:10:15  phil
+%DefaultSupertype now only changes the default for the current module.
+(%DefaultMetatype still affects importing modules.)  This should mean that
+modules that extend PyQt4 will continue to work without having to make
+super-type or meta-type changes.
+
+
+2009/04/24 18:29:38  phil
+Fixed the lookup of generated slot functions in sub-types.
+Moved some assertions to more appropriate places when a generated slot function
+isn't found.
+
+
+2009/04/20 19:54:57  phil
+Disabled the new implicit copying of const reference results where the class
+doesn't have a public copy ctor.
+
+
+2009/04/18 16:53:34  phil
+Fixed a problem handling __setitem__ when being used to support
+multi-dimensional mappings.
+
+
 2009/04/09 13:00:09  phil
 Print any exception raised by __dtor__.
 </diff>
      <filename>ChangeLog</filename>
    </modified>
    <modified>
      <diff>@@ -22,7 +22,7 @@ import siputils
 
 # Initialise the globals.
 sip_version = 0x040800
-sip_version_str = &quot;4.8-snapshot-20090409&quot;
+sip_version_str = &quot;4.8-snapshot-20090430&quot;
 py_version = sys.hexversion &gt;&gt; 8
 plat_py_site_dir = None
 plat_py_inc_dir = None</diff>
      <filename>configure.py</filename>
    </modified>
    <modified>
      <diff>@@ -301,7 +301,7 @@ ul.auto-toc {
 &lt;tr&gt;&lt;th class=&quot;docinfo-name&quot;&gt;Contact:&lt;/th&gt;
 &lt;td&gt;&lt;a class=&quot;first last reference&quot; href=&quot;mailto:info&amp;#64;riverbankcomputing.com&quot;&gt;info&amp;#64;riverbankcomputing.com&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
 &lt;tr&gt;&lt;th class=&quot;docinfo-name&quot;&gt;Version:&lt;/th&gt;
-&lt;td&gt;4.8-snapshot-20090409&lt;/td&gt;&lt;/tr&gt;
+&lt;td&gt;4.8-snapshot-20090430&lt;/td&gt;&lt;/tr&gt;
 &lt;tr&gt;&lt;th class=&quot;docinfo-name&quot;&gt;Copyright:&lt;/th&gt;
 &lt;td&gt;Copyright (c) 2009 Riverbank Computing Limited&lt;/td&gt;&lt;/tr&gt;
 &lt;/tbody&gt;
@@ -595,7 +595,7 @@ ul.auto-toc {
 &lt;/div&gt;
 &lt;div class=&quot;section&quot;&gt;
 &lt;h1&gt;&lt;a class=&quot;toc-backref&quot; href=&quot;#id25&quot; id=&quot;introduction&quot; name=&quot;introduction&quot;&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;Introduction&lt;/a&gt;&lt;/h1&gt;
-&lt;p&gt;This is the reference guide for SIP 4.8-snapshot-20090409.  SIP is a tool for
+&lt;p&gt;This is the reference guide for SIP 4.8-snapshot-20090430.  SIP is a tool for
 automatically generating &lt;a class=&quot;reference&quot; href=&quot;http://www.python.org&quot;&gt;Python&lt;/a&gt; bindings for C and
 C++ libraries.  SIP was originally developed in 1998 for
 &lt;a class=&quot;reference&quot; href=&quot;http://www.riverbankcomputing.com/software/pyqt/&quot;&gt;PyQt&lt;/a&gt; - the Python
@@ -1450,7 +1450,8 @@ memory.&lt;/p&gt;
 &lt;p&gt;SIP allows a class's meta-type and super-type to be explicitly specified using
 the &lt;a class=&quot;reference&quot; href=&quot;#metatype&quot;&gt;Metatype&lt;/a&gt; and &lt;a class=&quot;reference&quot; href=&quot;#supertype&quot;&gt;Supertype&lt;/a&gt; class annotations.&lt;/p&gt;
 &lt;p&gt;SIP also allows the default meta-type and super-type to be changed for a module
-using the &lt;a class=&quot;reference&quot; href=&quot;#defaultmetatype&quot;&gt;%DefaultMetatype&lt;/a&gt; and &lt;a class=&quot;reference&quot; href=&quot;#defaultsupertype&quot;&gt;%DefaultSupertype&lt;/a&gt; directives.&lt;/p&gt;
+using the &lt;a class=&quot;reference&quot; href=&quot;#defaultmetatype&quot;&gt;%DefaultMetatype&lt;/a&gt; and &lt;a class=&quot;reference&quot; href=&quot;#defaultsupertype&quot;&gt;%DefaultSupertype&lt;/a&gt; directives.  Unlike the
+default super-type, the default meta-type is inherited by importing modules.&lt;/p&gt;
 &lt;p&gt;If you want to use your own meta-type or super-type then they must be
 sub-classed from one of the SIP provided types.  Your types must be registered
 using &lt;a class=&quot;reference&quot; href=&quot;#sipregisterpytype&quot;&gt;sipRegisterPyType()&lt;/a&gt;.  This is normally done in code specified using
@@ -2587,7 +2588,8 @@ specified then &lt;tt class=&quot;docutils literal&quot;&gt;&lt;span class=&quot;pre&quot;&gt;&amp;quot;None&amp;quot;&lt;/
 %DefaultMetatype &lt;em&gt;dotted-name&lt;/em&gt;
 &lt;/pre&gt;
 &lt;p&gt;This directive is used to specify the Python type that should be used as the
-meta-type for any C/C++ data type that doesn't have an explicit super-type.&lt;/p&gt;
+meta-type for any C/C++ data type defined in the same module, and by importing
+modules, that doesn't have an explicit super-type.&lt;/p&gt;
 &lt;p&gt;If this is not specified then &lt;tt class=&quot;docutils literal&quot;&gt;&lt;span class=&quot;pre&quot;&gt;sip.wrappertype&lt;/span&gt;&lt;/tt&gt; is used.&lt;/p&gt;
 &lt;p&gt;You can also use the &lt;a class=&quot;reference&quot; href=&quot;#metatype&quot;&gt;Metatype&lt;/a&gt; class annotation to specify the meta-type
 used by a particular C/C++ type.&lt;/p&gt;
@@ -2603,7 +2605,8 @@ used by a particular C/C++ type.&lt;/p&gt;
 %DefaultSupertype &lt;em&gt;dotted-name&lt;/em&gt;
 &lt;/pre&gt;
 &lt;p&gt;This directive is used to specify the Python type that should be used as the
-super-type for any C/C++ data type that doesn't have an explicit super-type.&lt;/p&gt;
+super-type for any C/C++ data type defined in the same module that doesn't have
+an explicit super-type.&lt;/p&gt;
 &lt;p&gt;If this is not specified then &lt;tt class=&quot;docutils literal&quot;&gt;&lt;span class=&quot;pre&quot;&gt;sip.wrapper&lt;/span&gt;&lt;/tt&gt; is used.&lt;/p&gt;
 &lt;p&gt;You can also use the &lt;a class=&quot;reference&quot; href=&quot;#supertype&quot;&gt;Supertype&lt;/a&gt; class annotation to specify the super-type
 used by a particular C/C++ type.&lt;/p&gt;</diff>
      <filename>doc/sipref.html</filename>
    </modified>
    <modified>
      <diff>@@ -7,7 +7,7 @@
 -----------------
 
 :Contact:   info@riverbankcomputing.com
-:Version:   4.8-snapshot-20090409
+:Version:   4.8-snapshot-20090430
 :Copyright: Copyright (c) 2009 Riverbank Computing Limited
 
 .. contents::
@@ -17,7 +17,7 @@
 Introduction
 ============
 
-This is the reference guide for SIP 4.8-snapshot-20090409.  SIP is a tool for
+This is the reference guide for SIP 4.8-snapshot-20090430.  SIP is a tool for
 automatically generating `Python &lt;http://www.python.org&gt;`__ bindings for C and
 C++ libraries.  SIP was originally developed in 1998 for
 `PyQt &lt;http://www.riverbankcomputing.com/software/pyqt/&gt;`__ - the Python
@@ -950,7 +950,8 @@ SIP allows a class's meta-type and super-type to be explicitly specified using
 the `Metatype`_ and `Supertype`_ class annotations.
 
 SIP also allows the default meta-type and super-type to be changed for a module
-using the `%DefaultMetatype`_ and `%DefaultSupertype`_ directives.
+using the `%DefaultMetatype`_ and `%DefaultSupertype`_ directives.  Unlike the
+default super-type, the default meta-type is inherited by importing modules.
 
 If you want to use your own meta-type or super-type then they must be
 sub-classed from one of the SIP provided types.  Your types must be registered
@@ -2209,7 +2210,8 @@ For example::
     %DefaultMetatype *dotted-name*
 
 This directive is used to specify the Python type that should be used as the
-meta-type for any C/C++ data type that doesn't have an explicit super-type.
+meta-type for any C/C++ data type defined in the same module, and by importing
+modules, that doesn't have an explicit super-type.
 
 If this is not specified then ``sip.wrappertype`` is used.
 
@@ -2231,7 +2233,8 @@ For example::
     %DefaultSupertype *dotted-name*
 
 This directive is used to specify the Python type that should be used as the
-super-type for any C/C++ data type that doesn't have an explicit super-type.
+super-type for any C/C++ data type defined in the same module that doesn't have
+an explicit super-type.
 
 If this is not specified then ``sip.wrapper`` is used.
 </diff>
      <filename>doc/sipref.txt</filename>
    </modified>
    <modified>
      <diff>@@ -10198,8 +10198,12 @@ static void generateFunctionCall(classDef *cd,classDef *ocd,overDef *od,
         /* Make a copy if it is not a reference or it is a const reference. */
         if (!isReference(res) || isConstArg(res))
         {
-            needsNew = TRUE;
-            resetIsConstArg(res);
+            /* If it is a class then we must be able to copy it. */
+            if (res-&gt;atype != class_type || !cannotCopy(res-&gt;u.cd))
+            {
+                needsNew = TRUE;
+                resetIsConstArg(res);
+            }
         }
     }
 </diff>
      <filename>sipgen/gencode.c</filename>
    </modified>
    <modified>
      <diff>@@ -26,7 +26,7 @@
 #define PACKAGE &quot;sip&quot;
 #endif
 
-#define VERSION &quot;4.8-snapshot-20090409&quot;
+#define VERSION &quot;4.8-snapshot-20090430&quot;
 
 
 /* Global variables - see sip.h for their meaning. */</diff>
      <filename>sipgen/main.c</filename>
    </modified>
    <modified>
      <diff>@@ -92,6 +92,7 @@
 #define CLASS_NO_QMETAOBJECT    0x02000000  /* It has no QMetaObject. */
 #define CLASS_IS_TEMPLATE   0x04000000  /* It is a template class. */
 #define CLASS_IS_DEPRECATED 0x08000000  /* It is deprecated. */
+#define CLASS_CANNOT_COPY   0x10000000  /* It cannot be copied. */
 
 #define hasSigSlots(cd)     ((cd)-&gt;classflags &amp; CLASS_HAS_SIGSLOTS)
 #define setHasSigSlots(cd)  ((cd)-&gt;classflags |= CLASS_HAS_SIGSLOTS)
@@ -136,6 +137,8 @@
 #define resetIsTemplateClass(cd)    ((cd)-&gt;classflags &amp;= ~CLASS_IS_TEMPLATE)
 #define isDeprecatedClass(cd)   ((cd)-&gt;classflags &amp; CLASS_IS_DEPRECATED)
 #define setIsDeprecatedClass(cd)    ((cd)-&gt;classflags |= CLASS_IS_DEPRECATED)
+#define cannotCopy(cd)      ((cd)-&gt;classflags &amp; CLASS_CANNOT_COPY)
+#define setCannotCopy(cd)   ((cd)-&gt;classflags |= CLASS_CANNOT_COPY)
 
 #define isPublicDtor(cd)    ((cd)-&gt;classflags &amp; SECT_IS_PUBLIC)
 #define setIsPublicDtor(cd) ((cd)-&gt;classflags |= SECT_IS_PUBLIC)</diff>
      <filename>sipgen/sip.h</filename>
    </modified>
    <modified>
      <diff>@@ -156,29 +156,6 @@ void transform(sipSpec *pt)
         }
     }
 
-    /*
-     * Set the default super-type for the main module if it doesn't have one
-     * explicitly set.
-     */
-    if (pt-&gt;module-&gt;defsupertype == NULL)
-    {
-        moduleListDef *mld;
-
-        for (mld = pt-&gt;module-&gt;allimports; mld != NULL; mld = mld-&gt;next)
-        {
-            if (mld-&gt;module-&gt;defsupertype == NULL)
-                continue;
-
-            if (pt-&gt;module-&gt;defsupertype == NULL)
-                pt-&gt;module-&gt;defsupertype = mld-&gt;module-&gt;defsupertype;
-            else if (pt-&gt;module-&gt;defsupertype != mld-&gt;module-&gt;defsupertype)
-                fatal(&quot;The %s module has imported different default super-types %s and %s\n&quot;,
-                        pt-&gt;module-&gt;fullname-&gt;text,
-                        pt-&gt;module-&gt;defsupertype-&gt;text,
-                        mld-&gt;module-&gt;defsupertype-&gt;text);
-        }
-    }
-
     /* Check each class has been defined. */
     for (cd = pt -&gt; classes; cd != NULL; cd = cd -&gt; next)
         if (cd -&gt; iff -&gt; module == NULL)
@@ -226,8 +203,8 @@ void transform(sipSpec *pt)
     }
 
     /* Handle default ctors now that the argument types are resolved. */ 
-    if (!pt -&gt; genc)
-        for (cd = pt -&gt; classes; cd != NULL; cd = cd -&gt; next)
+    if (!pt-&gt;genc)
+        for (cd = pt-&gt;classes; cd != NULL; cd = cd-&gt;next)
             if (!noDefaultCtors(cd) &amp;&amp; !isOpaque(cd) &amp;&amp; cd-&gt;iff-&gt;type != namespace_iface)
                 addDefaultCopyCtor(cd);
 
@@ -1331,81 +1308,79 @@ static void transformCasts(sipSpec *pt, classDef *cd)
 
 
 /*
- * Add a default copy ctor is required.
+ * Add a default copy ctor if required.
  */
 static void addDefaultCopyCtor(classDef *cd)
 {
-    ctorDef *copyct;
+    ctorDef *copyct, **tailp;
     mroDef *mro;
 
     /* See if there is a private copy ctor in the hierarchy. */
- 
-    copyct = NULL;
- 
-    for (mro = cd -&gt; mro; mro != NULL; mro = mro -&gt; next)
+    for (mro = cd-&gt;mro; mro != NULL; mro = mro-&gt;next)
     {
         ctorDef *ct;
 
         if (isDuplicateSuper(mro))
             continue;
 
-        for (ct = mro -&gt; cd -&gt; ctors; ct != NULL; ct = ct -&gt; next)
+        for (ct = mro-&gt;cd-&gt;ctors; ct != NULL; ct = ct-&gt;next)
         {
             argDef *ad = &amp;ct -&gt; pysig.args[0];
  
             /* See if is a copy ctor. */
-            if (ct -&gt; pysig.nrArgs != 1 || ad -&gt; nrderefs != 0 ||
-                !isReference(ad) || ad -&gt; atype != class_type ||
-                ad -&gt; u.cd != mro -&gt; cd)
-                continue;
+            if (ct-&gt;pysig.nrArgs == 1 &amp;&amp; ad-&gt;nrderefs == 0 &amp;&amp;
+                isReference(ad) &amp;&amp; ad-&gt;atype == class_type &amp;&amp;
+                ad-&gt;u.cd == mro-&gt;cd)
+                break;
+        }
 
-            /* Stop now if the copy ctor is private. */
+        if (ct != NULL)
+        {
+            /* If the copy ctor is private then the class can't be copied. */
             if (isPrivateCtor(ct))
+            {
+                setCannotCopy(cd);
                 return;
- 
+            }
+
             /*
-             * Remember if it's in the class we are dealing with.
+             * If the ctor is in the class itself then there is nothing to do.
              */
-            if (mro == cd -&gt; mro)
-                copyct = ct;
+            if (mro == cd-&gt;mro)
+                return;
  
+            /* Otherwise we need to create a default. */
             break;
         }
     }
  
-    if (copyct == NULL)
-    {
-        ctorDef **tailp;
- 
-        /* Create a default public copy ctor. */
+    /* Create a default public copy ctor. */
+    copyct = sipMalloc(sizeof (ctorDef));
  
-        copyct = sipMalloc(sizeof (ctorDef));
+    copyct-&gt;ctorflags = SECT_IS_PUBLIC;
+    copyct-&gt;pysig.nrArgs = 1;
+    copyct-&gt;pysig.args[0].name = &quot;other&quot;;
+    copyct-&gt;pysig.args[0].atype = class_type;
+    copyct-&gt;pysig.args[0].u.cd = cd;
+    copyct-&gt;pysig.args[0].argflags = (ARG_IS_REF | ARG_IS_CONST | ARG_IN);
+    copyct-&gt;pysig.args[0].nrderefs = 0;
+    copyct-&gt;pysig.args[0].defval = NULL;
  
-        copyct -&gt; ctorflags = SECT_IS_PUBLIC;
-        copyct -&gt; pysig.nrArgs = 1;
-        copyct -&gt; pysig.args[0].name = &quot;other&quot;;
-        copyct -&gt; pysig.args[0].atype = class_type;
-        copyct -&gt; pysig.args[0].u.cd = cd;
-        copyct -&gt; pysig.args[0].argflags = (ARG_IS_REF | ARG_IS_CONST | ARG_IN);
-        copyct -&gt; pysig.args[0].nrderefs = 0;
-        copyct -&gt; pysig.args[0].defval = NULL;
+    copyct-&gt;cppsig = &amp;copyct-&gt;pysig;
+    copyct-&gt;exceptions = NULL;
+    copyct-&gt;methodcode = NULL;
+    copyct-&gt;prehook = NULL;
+    copyct-&gt;posthook = NULL;
+    copyct-&gt;next = NULL;
  
-        copyct -&gt; cppsig = &amp;copyct -&gt; pysig;
-        copyct -&gt; exceptions = NULL;
-        copyct -&gt; methodcode = NULL;
-        copyct -&gt; prehook = NULL;
-        copyct -&gt; posthook = NULL;
-        copyct -&gt; next = NULL;
- 
-        if (isDeprecatedClass(cd))
-            setIsDeprecatedCtor(copyct);
+    if (isDeprecatedClass(cd))
+        setIsDeprecatedCtor(copyct);
 
-        /* Append it to the list. */
-        for (tailp = &amp;cd -&gt; ctors; *tailp != NULL; tailp = &amp;(*tailp) -&gt; next)
-            ;
+    /* Append it to the list. */
+    for (tailp = &amp;cd-&gt;ctors; *tailp != NULL; tailp = &amp;(*tailp)-&gt;next)
+        ;
  
-        *tailp = copyct;
-    }
+    *tailp = copyct;
 }
 
 </diff>
      <filename>sipgen/transform.c</filename>
    </modified>
    <modified>
      <diff>@@ -83,7 +83,7 @@ static void *createUniversalSlot(sipWrapper *txSelf, const char *sig,
  */
 PyObject *sip_api_invoke_slot(const sipSlot *slot, PyObject *sigargs)
 {
-    PyObject *sa, *oxtype, *oxvalue, *oxtb, *sfunc, *newmeth, *sref;
+    PyObject *sa, *oxtype, *oxvalue, *oxtb, *sfunc, *sref;
 
     /* Keep some compilers quiet. */
     oxtype = oxvalue = oxtb = NULL;
@@ -145,9 +145,6 @@ PyObject *sip_api_invoke_slot(const sipSlot *slot, PyObject *sigargs)
             Py_XDECREF(sref);
             return NULL;
         }
-
-        /* Make sure we garbage collect the new method. */
-        newmeth = sfunc;
     }
     else if (slot -&gt; name != NULL)
     {
@@ -162,17 +159,15 @@ PyObject *sip_api_invoke_slot(const sipSlot *slot, PyObject *sigargs)
              */
             PyErr_Format(PyExc_NameError,&quot;Invalid slot %s&quot;,mname);
 
+            Py_XDECREF(sfunc);
             Py_XDECREF(sref);
             return NULL;
         }
-
-        /* Make sure we garbage collect the new method. */
-        newmeth = sfunc;
     }
     else
     {
-        sfunc = slot -&gt; pyobj;
-        newmeth = NULL;
+        sfunc = slot-&gt;pyobj;
+        Py_INCREF(sfunc);
     }
 
     /*
@@ -188,9 +183,9 @@ PyObject *sip_api_invoke_slot(const sipSlot *slot, PyObject *sigargs)
     {
         PyObject *nsa, *xtype, *xvalue, *xtb, *resobj;
 
-        if ((resobj = PyEval_CallObject(sfunc,sa)) != NULL)
+        if ((resobj = PyEval_CallObject(sfunc, sa)) != NULL)
         {
-            Py_XDECREF(newmeth);
+            Py_DECREF(sfunc);
             Py_XDECREF(sref);
 
             /* Remove any previous exception. */
@@ -281,7 +276,7 @@ PyObject *sip_api_invoke_slot(const sipSlot *slot, PyObject *sigargs)
         sa = nsa;
     }
 
-    Py_XDECREF(newmeth);
+    Py_DECREF(sfunc);
     Py_XDECREF(sref);
 
     Py_DECREF(sa);</diff>
      <filename>siplib/qtlib.c</filename>
    </modified>
    <modified>
      <diff>@@ -51,7 +51,7 @@ extern &quot;C&quot; {
  * Define the SIP version number.
  */
 #define SIP_VERSION         0x040800
-#define SIP_VERSION_STR     &quot;4.8-snapshot-20090409&quot;
+#define SIP_VERSION_STR     &quot;4.8-snapshot-20090430&quot;
 
 
 /*</diff>
      <filename>siplib/sip.h</filename>
    </modified>
    <modified>
      <diff>@@ -360,6 +360,7 @@ static void addClassSlots(sipWrapperType *wt, sipClassTypeDef *ctd);
 static void addTypeSlots(PyTypeObject *to, PyNumberMethods *nb,
         PySequenceMethods *sq, PyMappingMethods *mp, sipPySlotDef *slots);
 static void *findSlot(PyObject *self, sipPySlotType st);
+static void *findSlotInType(sipPySlotDef *psd, sipPySlotType st);
 static int objobjargprocSlot(PyObject *self, PyObject *arg1, PyObject *arg2,
         sipPySlotType st);
 static int ssizeobjargprocSlot(PyObject *self, SIP_SSIZE_T arg1,
@@ -6377,21 +6378,64 @@ static sipClassTypeDef *getClassType(const sipEncodedClassDef *enc,
  */
 static void *findSlot(PyObject *self, sipPySlotType st)
 {
-    sipPySlotDef *psd;
+    void *slot;
     PyTypeObject *py_type = Py_TYPE(self);
 
-    /* If it is not a wrapper then it must be an enum. */
+    /* See if it is a wrapper. */
     if (PyObject_TypeCheck((PyObject *)py_type, &amp;sipWrapperType_Type))
-        psd = ((sipClassTypeDef *)((sipWrapperType *)(py_type))-&gt;type)-&gt;ctd_pyslots;
+    {
+        sipClassTypeDef *ctd;
+
+        ctd = (sipClassTypeDef *)((sipWrapperType *)(py_type))-&gt;type;
+
+        if (ctd-&gt;ctd_pyslots != NULL)
+            slot = findSlotInType(ctd-&gt;ctd_pyslots, st);
+        else
+            slot = NULL;
+
+        if (slot == NULL)
+        {
+            sipEncodedClassDef *sup;
+
+            /* Search any super-types. */
+            if ((sup = ctd-&gt;ctd_supers) != NULL)
+            {
+                sipClassTypeDef *sup_ctd;
+
+                do
+                {
+                    sup_ctd = getClassType(sup, ctd-&gt;ctd_base.td_module);
+
+                    if (sup_ctd-&gt;ctd_pyslots != NULL)
+                        slot = findSlotInType(sup_ctd-&gt;ctd_pyslots, st);
+                }
+                while (slot == NULL &amp;&amp; !sup++-&gt;sc_flag);
+            }
+        }
+    }
     else
     {
+        sipEnumTypeDef *etd;
+
+        /* If it is not a wrapper then it must be an enum. */
         assert(PyObject_TypeCheck((PyObject *)py_type, &amp;sipEnumType_Type));
 
-        psd = ((sipEnumTypeDef *)((sipEnumTypeObject *)(py_type))-&gt;type)-&gt;etd_pyslots;
+        etd = (sipEnumTypeDef *)((sipEnumTypeObject *)(py_type))-&gt;type;
+
+        assert(etd-&gt;etd_pyslots != NULL);
+
+        slot = findSlotInType(etd-&gt;etd_pyslots, st);
     }
 
-    assert(psd != NULL);
+    return slot;
+}
 
+
+/*
+ * Find a particular slot function in a particular type.
+ */
+static void *findSlotInType(sipPySlotDef *psd, sipPySlotType st)
+{
     while (psd-&gt;psd_func != NULL)
     {
         if (psd-&gt;psd_type == st)
@@ -6400,7 +6444,6 @@ static void *findSlot(PyObject *self, sipPySlotType st)
         ++psd;
     }
 
-    /* This should never happen. */
     return NULL;
 }
 
@@ -6419,58 +6462,47 @@ static void *getPtrTypeDef(sipSimpleWrapper *self, const sipClassTypeDef **ctd)
 /*
  * Handle an objobjargproc slot.
  */
-static int objobjargprocSlot(PyObject *self,PyObject *arg1,PyObject *arg2,
+static int objobjargprocSlot(PyObject *self, PyObject *arg1, PyObject *arg2,
         sipPySlotType st)
 {
-    int (*f)(PyObject *,PyObject *);
-    PyObject *args;
+    int (*f)(PyObject *, PyObject *);
     int res;
 
-    /*
-     * Slot handlers require a single PyObject *.  The second argument is
-     * optional.
-     */
-    if (arg2 == NULL)
-        args = arg1;
-    else if (PyTuple_Check(arg1))
-    {
-        int i;
+    f = (int (*)(PyObject *, PyObject *))findSlot(self, st);
 
-        /* It's already a tuple so we need to copy it and append the value. */
-        if ((args = PyTuple_New(PyTuple_GET_SIZE(arg1) + 1)) == NULL)
-            return -1;
+    if (f != NULL)
+    {
+        PyObject *args;
 
-        for (i = 0; i &lt; PyTuple_GET_SIZE(arg1); ++i)
+        /*
+         * Slot handlers require a single PyObject *.  The second argument is
+         * optional.
+         */
+        if (arg2 == NULL)
         {
-            PyObject *o = PyTuple_GET_ITEM(arg1,i);
-
-            PyTuple_SET_ITEM(args,i,o);
-            Py_INCREF(o);
+            args = arg1;
+            Py_INCREF(args);
         }
-
-        PyTuple_SET_ITEM(args,i,arg2);
-        Py_INCREF(arg2);
-    }
-    else
-    {
+        else
+        {
 #if PY_VERSION_HEX &gt;= 0x02040000
-        args = PyTuple_Pack(2, arg1, arg2);
+            args = PyTuple_Pack(2, arg1, arg2);
 #else
-        args = Py_BuildValue(&quot;(OO)&quot;, arg1, arg2);
+            args = Py_BuildValue(&quot;(OO)&quot;, arg1, arg2);
 #endif
 
-        if (args == NULL)
-            return -1;
-    }
-
-    f = (int (*)(PyObject *,PyObject *))findSlot(self, st);
-
-    res = f(self,args);
+            if (args == NULL)
+                return -1;
+        }
 
-    if (arg2 != NULL)
-    {
+        res = f(self, args);
         Py_DECREF(args);
     }
+    else
+    {
+        PyErr_SetNone(PyExc_NotImplementedError);
+        res = -1;
+    }
 
     return res;
 }
@@ -6482,37 +6514,45 @@ static int objobjargprocSlot(PyObject *self,PyObject *arg1,PyObject *arg2,
 static int ssizeobjargprocSlot(PyObject *self, SIP_SSIZE_T arg1,
         PyObject *arg2, sipPySlotType st)
 {
-    int (*f)(PyObject *,PyObject *);
-    PyObject *args;
+    int (*f)(PyObject *, PyObject *);
     int res;
 
-    /*
-     * Slot handlers require a single PyObject *.  The second argument is
-     * optional.
-     */
-    if (arg2 == NULL)
+    f = (int (*)(PyObject *, PyObject *))findSlot(self, st);
+
+    if (f != NULL)
+    {
+        PyObject *args;
+
+        /*
+         * Slot handlers require a single PyObject *.  The second argument is
+         * optional.
+         */
+        if (arg2 == NULL)
 #if PY_MAJOR_VERSION &gt;= 3
-        args = PyLong_FromSsize_t(arg1);
+            args = PyLong_FromSsize_t(arg1);
 #elif PY_VERSION_HEX &gt;= 0x02050000
-        args = PyInt_FromSsize_t(arg1);
+            args = PyInt_FromSsize_t(arg1);
 #else
-        args = PyInt_FromLong(arg1);
+            args = PyInt_FromLong(arg1);
 #endif
     else
 #if PY_VERSION_HEX &gt;= 0x02050000
-        args = Py_BuildValue(&quot;(nO)&quot;, arg1, arg2);
+            args = Py_BuildValue(&quot;(nO)&quot;, arg1, arg2);
 #else
-        args = Py_BuildValue(&quot;(iO)&quot;, arg1, arg2);
+            args = Py_BuildValue(&quot;(iO)&quot;, arg1, arg2);
 #endif
 
-    if (args == NULL)
-        return -1;
-
-    f = (int (*)(PyObject *,PyObject *))findSlot(self,st);
-
-    res = f(self,args);
+        if (args == NULL)
+            return -1;
 
-    Py_DECREF(args);
+        res = f(self, args);
+        Py_DECREF(args);
+    }
+    else
+    {
+        PyErr_SetNone(PyExc_NotImplementedError);
+        res = -1;
+    }
 
     return res;
 }
@@ -7656,7 +7696,9 @@ static PyObject *slot_call(PyObject *self,PyObject *args,PyObject *kw)
 {
     PyObject *(*f)(PyObject *,PyObject *);
 
-    f = (PyObject *(*)(PyObject *,PyObject *))findSlot(self,call_slot);
+    f = (PyObject *(*)(PyObject *,PyObject *))findSlot(self, call_slot);
+
+    assert(f != NULL);
 
     return f(self,args);
 }
@@ -7681,7 +7723,9 @@ static PyObject *slot_sq_item(PyObject *self, SIP_SSIZE_T n)
     if (arg == NULL)
         return NULL;
 
-    f = (PyObject *(*)(PyObject *,PyObject *))findSlot(self,getitem_slot);
+    f = (PyObject *(*)(PyObject *,PyObject *))findSlot(self, getitem_slot);
+
+    assert(f != NULL);
 
     res = f(self,arg);
 
@@ -7694,10 +7738,11 @@ static PyObject *slot_sq_item(PyObject *self, SIP_SSIZE_T n)
 /*
  * The mapping type assign subscript slot.
  */
-static int slot_mp_ass_subscript(PyObject *self,PyObject *key,
+static int slot_mp_ass_subscript(PyObject *self, PyObject *key,
         PyObject *value)
 {
-    return objobjargprocSlot(self,key,value,(value != NULL ? setitem_slot : delitem_slot));
+    return objobjargprocSlot(self, key, value,
+            (value != NULL ? setitem_slot : delitem_slot));
 }
 
 
@@ -7706,14 +7751,15 @@ static int slot_mp_ass_subscript(PyObject *self,PyObject *key,
  */
 static int slot_sq_ass_item(PyObject *self, SIP_SSIZE_T i, PyObject *o)
 {
-    return ssizeobjargprocSlot(self, i, o, (o != NULL ? setitem_slot : delitem_slot));
+    return ssizeobjargprocSlot(self, i, o,
+            (o != NULL ? setitem_slot : delitem_slot));
 }
 
 
 /*
  * The type rich compare slot.
  */
-static PyObject *slot_richcompare(PyObject *self,PyObject *arg,int op)
+static PyObject *slot_richcompare(PyObject *self, PyObject *arg, int op)
 {
     PyObject *(*f)(PyObject *,PyObject *);
     sipPySlotType st;
@@ -7747,13 +7793,13 @@ static PyObject *slot_richcompare(PyObject *self,PyObject *arg,int op)
     }
 
     /* It might not exist if not all the above have been implemented. */
-    if ((f = (PyObject *(*)(PyObject *,PyObject *))findSlot(self,st)) == NULL)
+    if ((f = (PyObject *(*)(PyObject *,PyObject *))findSlot(self, st)) == NULL)
     {
         Py_INCREF(Py_NotImplemented);
         return Py_NotImplemented;
     }
 
-    return f(self,arg);
+    return f(self, arg);
 }
 
 </diff>
      <filename>siplib/siplib.c</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a4721a75c79e2875612e2511da24304099122935</id>
    </parent>
  </parents>
  <author>
    <name>Kevin Watters</name>
    <email>kevinwatters@gmail.com</email>
  </author>
  <url>http://github.com/kevinw/sip/commit/de9650f5d9cdf1545039207f9b3e345931585067</url>
  <id>de9650f5d9cdf1545039207f9b3e345931585067</id>
  <committed-date>2009-05-11T07:26:12-07:00</committed-date>
  <authored-date>2009-05-11T07:26:12-07:00</authored-date>
  <message>sip-4.8-snapshot-20090430</message>
  <tree>cb8532a58c93044153bafda0d7a01e0f87b091c6</tree>
  <committer>
    <name>Kevin Watters</name>
    <email>kevinwatters@gmail.com</email>
  </committer>
</commit>
