]> granicus.if.org Git - python/commitdiff
Merge changes from r22a2-branch back into trunk. Also, change patch
authorBarry Warsaw <barry@python.org>
Wed, 22 Aug 2001 19:24:42 +0000 (19:24 +0000)
committerBarry Warsaw <barry@python.org>
Wed, 22 Aug 2001 19:24:42 +0000 (19:24 +0000)
level to 2.2a2+

Include/patchlevel.h
Lib/test/test_os.py
Modules/Setup.dist
Objects/typeobject.c
setup.py

index 3d226161511d89098c1f3e8ea326e813881dc91d..2c3b5dd6315f29e28e6e280e2422a6a75d41af76 100644 (file)
 #define PY_MINOR_VERSION       2
 #define PY_MICRO_VERSION       0
 #define PY_RELEASE_LEVEL       PY_RELEASE_LEVEL_ALPHA
-#define PY_RELEASE_SERIAL      1
+#define PY_RELEASE_SERIAL      2
 
 /* Version as a string */
-#define PY_VERSION             "2.2a1+"
+#define PY_VERSION             "2.2a2+"
 
 /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2.
    Use this for numeric comparisons, e.g. #if PY_VERSION_HEX >= ... */
index 0ea9f789844da1a0fde66d696b6758973f7ca3ab..9cddb5f7004a7a12b92670cfeb635ed182c3f28d 100644 (file)
@@ -6,6 +6,9 @@ import os
 import unittest
 import warnings
 
+warnings.filterwarnings("ignore", "tempnam", RuntimeWarning, __name__)
+warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning, __name__)
+
 from test_support import TESTFN, run_unittest
 
 
index e9c2a949a6c69ca41eb8dc5d1ab757b8d1359576..61afe8c8b7b41e979ade8e2291e20dffbf5c0b44 100644 (file)
@@ -98,6 +98,7 @@ PYTHONPATH=$(COREPYTHONPATH)
 
 posix posixmodule.c            # posix (UNIX) system calls
 _sre _sre.c                    # Fredrik Lundh's new regular expressions
+new newmodule.c                        # Tommy Burnette's 'new' module
 
 # The rest of the modules listed in this file are all commented out by
 # default.  Usually they can be detected and built as dynamically
@@ -347,11 +348,6 @@ GLHACK=-Dclear=__GLclear
 #_curses_panel _curses_panel.c -lpanel -lncurses 
 
 
-# Tommy Burnette's 'new' module (creates new empty objects of certain kinds):
-
-#new newmodule.c
-
-
 # Generic (SunOS / SVR4) dynamic loading module.
 # This is not needed for dynamic loading of Python modules --
 # it is a highly experimental and dangerous device for calling
index f2e6f4d4c91b663658e09212cfee4b47ab4e34d5..b64e10bcd4dc740ebc382dd122bacf4c71f3d41f 100644 (file)
@@ -2091,29 +2091,52 @@ static struct wrapperbase tab_init[] = {
 static PyObject *
 tp_new_wrapper(PyObject *self, PyObject *args, PyObject *kwds)
 {
-       PyTypeObject *type, *subtype;
+       PyTypeObject *type, *subtype, *staticbase;
        PyObject *arg0, *res;
 
        if (self == NULL || !PyType_Check(self))
                Py_FatalError("__new__() called with non-type 'self'");
        type = (PyTypeObject *)self;
        if (!PyTuple_Check(args) || PyTuple_GET_SIZE(args) < 1) {
-               PyErr_SetString(PyExc_TypeError,
-                               "T.__new__(): not enough arguments");
+               PyErr_Format(PyExc_TypeError,
+                            "%s.__new__(): not enough arguments",
+                            type->tp_name);
                return NULL;
        }
        arg0 = PyTuple_GET_ITEM(args, 0);
        if (!PyType_Check(arg0)) {
-               PyErr_SetString(PyExc_TypeError,
-                               "T.__new__(S): S is not a type object");
+               PyErr_Format(PyExc_TypeError,
+                            "%s.__new__(X): X is not a type object (%s)",
+                            type->tp_name,
+                            arg0->ob_type->tp_name);
                return NULL;
        }
        subtype = (PyTypeObject *)arg0;
        if (!PyType_IsSubtype(subtype, type)) {
-               PyErr_SetString(PyExc_TypeError,
-                               "T.__new__(S): S is not a subtype of T");
+               PyErr_Format(PyExc_TypeError,
+                            "%s.__new__(%s): %s is not a subtype of %s",
+                            type->tp_name,
+                            subtype->tp_name,
+                            subtype->tp_name,
+                            type->tp_name);
+               return NULL;
+       }
+
+       /* Check that the use doesn't do something silly and unsafe like
+          object.__new__(dictionary).  To do this, we check that the
+          most derived base that's not a heap type is this type. */
+       staticbase = subtype;
+       while (staticbase && (staticbase->tp_flags & Py_TPFLAGS_HEAPTYPE))
+               staticbase = staticbase->tp_base;
+       if (staticbase != type) {
+               PyErr_Format(PyExc_TypeError,
+                            "%s.__new__(%s) is not safe, use %s.__new__()",
+                            type->tp_name,
+                            subtype->tp_name,
+                            staticbase == NULL ? "?" : staticbase->tp_name);
                return NULL;
        }
+
        args = PyTuple_GetSlice(args, 1, PyTuple_GET_SIZE(args));
        if (args == NULL)
                return NULL;
index b60b35e04615f42e1e78ec7448aba5acd3d4d80e..88a70d3ed7b974b3fec1029af6975d616d3b4c3c 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -269,10 +269,6 @@ class PyBuildExt(build_ext):
         # (NIST's Secure Hash Algorithm.)
         exts.append( Extension('sha', ['shamodule.c']) )
 
-        # Tommy Burnette's 'new' module (creates new empty objects of certain
-        # kinds):
-        exts.append( Extension('new', ['newmodule.c']) )
-
         # Helper module for various ascii-encoders
         exts.append( Extension('binascii', ['binascii.c']) )