summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-06-14 20:41:17 (GMT)
committerGuido van Rossum <guido@python.org>2002-06-14 20:41:17 (GMT)
commitbea18ccde6bc12e061c21bb6b944379d8b123845 (patch)
treed5366d2bba31bde0cf6d05e1b55cde64cf3d3864
parent57454e57f83b407dd2653cbfcead7c9801beeff0 (diff)
downloadcpython-bea18ccde6bc12e061c21bb6b944379d8b123845.zip
cpython-bea18ccde6bc12e061c21bb6b944379d8b123845.tar.gz
cpython-bea18ccde6bc12e061c21bb6b944379d8b123845.tar.bz2
SF patch 568629 by Oren Tirosh: types made callable.
These built-in functions are replaced by their (now callable) type: slice() buffer() and these types can also be called (but have no built-in named function named after them) classobj (type name used to be "class") code function instance instancemethod (type name used to be "instance method") The module "new" has been replaced with a small backward compatibility placeholder in Python. A large portion of the patch simply removes the new module from various platform-specific build recipes. The following binary Mac project files still have references to it: Mac/Build/PythonCore.mcp Mac/Build/PythonStandSmall.mcp Mac/Build/PythonStandalone.mcp [I've tweaked the code layout and the doc strings here and there, and added a comment to types.py about StringTypes vs. basestring. --Guido]
-rw-r--r--Lib/types.py8
-rw-r--r--Mac/Distributions/dev.include1
-rw-r--r--Mac/MPW/Makefile4
-rw-r--r--Misc/BeOS-setup.py4
-rw-r--r--Modules/Setup.dist1
-rw-r--r--Objects/bufferobject.c40
-rw-r--r--Objects/classobject.c98
-rw-r--r--Objects/descrobject.c2
-rw-r--r--Objects/funcobject.c51
-rw-r--r--Objects/sliceobject.c32
-rw-r--r--PC/os2vacpp/makefile15
-rw-r--r--PC/os2vacpp/makefile.omk9
-rw-r--r--PCbuild/pythoncore.dsp15
-rw-r--r--Python/bltinmodule.c50
-rw-r--r--Python/compile.c67
-rw-r--r--Python/dynload_aix.c17
-rw-r--r--RISCOS/Makefile3
17 files changed, 287 insertions, 130 deletions
diff --git a/Lib/types.py b/Lib/types.py
index da0e597..fc0fbfb 100644
--- a/Lib/types.py
+++ b/Lib/types.py
@@ -23,13 +23,17 @@ except NameError:
pass
StringType = str
+
+# StringTypes is already outdated. Instead of writing "type(x) in
+# types.StringTypes", you should use "isinstance(x, basestring)". But
+# we keep around for compatibility with Python 2.2.
try:
UnicodeType = unicode
StringTypes = (StringType, UnicodeType)
except NameError:
StringTypes = (StringType,)
-BufferType = type(buffer(''))
+BufferType = buffer
TupleType = tuple
ListType = list
@@ -77,7 +81,7 @@ except TypeError:
pass
tb = None; del tb
-SliceType = type(slice(0))
+SliceType = slice
EllipsisType = type(Ellipsis)
DictProxyType = type(TypeType.__dict__)
diff --git a/Mac/Distributions/dev.include b/Mac/Distributions/dev.include
index 70c75cb..4ac3b51 100644
--- a/Mac/Distributions/dev.include
+++ b/Mac/Distributions/dev.include
@@ -501,7 +501,6 @@
(':Modules:md5module.c', None)
(':Modules:mmapmodule.c', None)
(':Modules:mpzmodule.c', None)
-(':Modules:newmodule.c', None)
(':Modules:nismodule.c', None)
(':Modules:operator.c', None)
(':Modules:parsermodule.c', None)
diff --git a/Mac/MPW/Makefile b/Mac/MPW/Makefile
index 3c06014..817198c 100644
--- a/Mac/MPW/Makefile
+++ b/Mac/MPW/Makefile
@@ -77,7 +77,6 @@ ALL = ¶
"{Objs}"moduleobject.c.o ¶
"{Objs}"myreadline.c.o ¶
"{Objs}"mystrtoul.c.o ¶
- "{Objs}"newmodule.c.o ¶
"{Objs}"nfullpath.c.o ¶
"{Objs}"node.c.o ¶
"{Objs}"object.c.o ¶
@@ -473,9 +472,6 @@ xxmodule.slb Ä PythonLib.slb "{Objs}"xxmodule.c.o
"{Objs}"mathmodule.c.o Ä "{Top}"Modules:mathmodule.c
{CC} "{Top}"Modules:mathmodule.c -o "{Objs}"mathmodule.c.o -s mathmodule.c {CFlags}
-"{Objs}"newmodule.c.o Ä "{Top}"Modules:newmodule.c
- {CC} "{Top}"Modules:newmodule.c -o "{Objs}"newmodule.c.o -s newmodule.c {CFlags}
-
"{Objs}"parsermodule.c.o Ä "{Top}"Modules:parsermodule.c
{CC} "{Top}"Modules:parsermodule.c -o "{Objs}"parsermodule.c.o -s parsermodule.c {CFlags}
diff --git a/Misc/BeOS-setup.py b/Misc/BeOS-setup.py
index 8f9b776..53b62b7 100644
--- a/Misc/BeOS-setup.py
+++ b/Misc/BeOS-setup.py
@@ -232,10 +232,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']) )
diff --git a/Modules/Setup.dist b/Modules/Setup.dist
index 0c7e015..f3bc312 100644
--- a/Modules/Setup.dist
+++ b/Modules/Setup.dist
@@ -110,7 +110,6 @@ 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
diff --git a/Objects/bufferobject.c b/Objects/bufferobject.c
index 51b9ef9..031c000 100644
--- a/Objects/bufferobject.c
+++ b/Objects/bufferobject.c
@@ -155,6 +155,27 @@ PyBuffer_New(int size)
/* Methods */
+static PyObject *
+buffer_new(PyTypeObject *type, PyObject *args, PyObject *kw)
+{
+ PyObject *ob;
+ int offset = 0;
+ int size = Py_END_OF_BUFFER;
+
+ if ( !PyArg_ParseTuple(args, "O|ii:buffer", &ob, &offset, &size) )
+ return NULL;
+ return PyBuffer_FromObject(ob, offset, size);
+}
+
+PyDoc_STRVAR(buffer_doc,
+"buffer(object [, offset[, size]])\n\
+\n\
+Create a new buffer object which references the given object.\n\
+The buffer will reference a slice of the target object from the\n\
+start of the object (or at the specified offset). The slice will\n\
+extend to the end of the target object (or with the specified size).");
+
+
static void
buffer_dealloc(PyBufferObject *self)
{
@@ -539,5 +560,22 @@ PyTypeObject PyBuffer_Type = {
0, /* tp_setattro */
&buffer_as_buffer, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
- 0, /* tp_doc */
+ buffer_doc, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ buffer_new, /* tp_new */
};
diff --git a/Objects/classobject.c b/Objects/classobject.c
index 1033ab6..979c967 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -149,6 +149,27 @@ PyMethod_Class(PyObject *im)
return ((PyMethodObject *)im)->im_class;
}
+PyDoc_STRVAR(class_doc,
+"classobj(name, bases, dict)\n\
+\n\
+Create a class object. The name must be a string; the second argument\n\
+a tuple of classes, and the third a dictionary.");
+
+static PyObject *
+new_class(PyObject* unused, PyObject* args)
+{
+ PyObject *name;
+ PyObject *classes;
+ PyObject *dict;
+
+ if (!PyArg_ParseTuple(args, "SO!O!:class",
+ &name,
+ &PyTuple_Type, &classes,
+ &PyDict_Type, &dict))
+ return NULL;
+ return PyClass_New(classes, dict, name);
+}
+
static PyObject *
class_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
@@ -435,7 +456,7 @@ class_traverse(PyClassObject *o, visitproc visit, void *arg)
PyTypeObject PyClass_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
- "class",
+ "classobj",
sizeof(PyClassObject),
0,
(destructor)class_dealloc, /* tp_dealloc */
@@ -454,7 +475,7 @@ PyTypeObject PyClass_Type = {
(setattrofunc)class_setattr, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
- 0, /* tp_doc */
+ class_doc, /* tp_doc */
(traverseproc)class_traverse, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
@@ -575,6 +596,34 @@ PyInstance_New(PyObject *klass, PyObject *arg, PyObject *kw)
/* Instance methods */
+PyDoc_STRVAR(instance_doc,
+"instance(class[, dict])\n\
+\n\
+Create an instance without calling its __init__() method.\n\
+The class must be a classic class.\n\
+If present, dict must be a dictionary or None.");
+
+static PyObject *
+instance_new(PyTypeObject* type, PyObject* args, PyObject *kw)
+{
+ PyObject *klass;
+ PyObject *dict = Py_None;
+
+ if (!PyArg_ParseTuple(args, "O!|O:instance",
+ &PyClass_Type, &klass, &dict))
+ return NULL;
+
+ if (dict == Py_None)
+ dict = NULL;
+ else if (!PyDict_Check(dict)) {
+ PyErr_SetString(PyExc_TypeError,
+ "instance() second arg must be dictionary or None");
+ return NULL;
+ }
+ return PyInstance_NewRaw(klass, dict);
+}
+
+
static void
instance_dealloc(register PyInstanceObject *inst)
{
@@ -2014,13 +2063,24 @@ PyTypeObject PyInstance_Type = {
(setattrofunc)instance_setattr, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES,/*tp_flags*/
- 0, /* tp_doc */
+ instance_doc, /* tp_doc */
(traverseproc)instance_traverse, /* tp_traverse */
0, /* tp_clear */
instance_richcompare, /* tp_richcompare */
offsetof(PyInstanceObject, in_weakreflist), /* tp_weaklistoffset */
(getiterfunc)instance_getiter, /* tp_iter */
(iternextfunc)instance_iternext, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ instance_new, /* tp_new */
};
@@ -2125,6 +2185,31 @@ instancemethod_getattro(PyObject *obj, PyObject *name)
return NULL;
}
+PyDoc_STRVAR(instancemethod_doc,
+"instancemethod(function, instance, class)\n\
+\n\
+Create an instance method object.");
+
+static PyObject *
+instancemethod_new(PyTypeObject* type, PyObject* args, PyObject *kw)
+{
+ PyObject *func;
+ PyObject *self;
+ PyObject *classObj;
+
+ if (!PyArg_ParseTuple(args, "OOO:instancemethod",
+ &func, &self, &classObj))
+ return NULL;
+ if (!PyCallable_Check(func)) {
+ PyErr_SetString(PyExc_TypeError,
+ "first argument must be callable");
+ return NULL;
+ }
+ if (self == Py_None)
+ self = NULL;
+ return PyMethod_New(func, self, classObj);
+}
+
static void
instancemethod_dealloc(register PyMethodObject *im)
{
@@ -2362,7 +2447,7 @@ instancemethod_descr_get(PyObject *meth, PyObject *obj, PyObject *class)
PyTypeObject PyMethod_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
- "instance method",
+ "instancemethod",
sizeof(PyMethodObject),
0,
(destructor)instancemethod_dealloc, /* tp_dealloc */
@@ -2381,7 +2466,7 @@ PyTypeObject PyMethod_Type = {
PyObject_GenericSetAttr, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
- 0, /* tp_doc */
+ instancemethod_doc, /* tp_doc */
(traverseproc)instancemethod_traverse, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
@@ -2396,6 +2481,9 @@ PyTypeObject PyMethod_Type = {
instancemethod_descr_get, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ instancemethod_new, /* tp_new */
};
/* Clear out the free list */
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
index 1130f86..2d926b4 100644
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -725,7 +725,7 @@ proxy_traverse(PyObject *self, visitproc visit, void *arg)
static PyTypeObject proxytype = {
PyObject_HEAD_INIT(&PyType_Type)
0, /* ob_size */
- "dict-proxy", /* tp_name */
+ "dictproxy", /* tp_name */
sizeof(proxyobject), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index f96d0dd..4eac035 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -266,6 +266,52 @@ static PyGetSetDef func_getsetlist[] = {
{NULL} /* Sentinel */
};
+PyDoc_STRVAR(func_doc,
+"function(code, globals[, name[, argdefs]])\n\
+\n\
+Create a function object from a code object and a dictionary.\n\
+The optional name string overrides the name from the code object.\n\
+The optional argdefs tuple specifies the default argument values.");
+
+static PyObject *
+func_new(PyTypeObject* type, PyObject* args, PyObject* kw)
+{
+ PyObject *code;
+ PyObject *globals;
+ PyObject *name = Py_None;
+ PyObject *defaults = Py_None;
+ PyFunctionObject *newfunc;
+
+ if (!PyArg_ParseTuple(args, "O!O!|OO!:function",
+ &PyCode_Type, &code,
+ &PyDict_Type, &globals,
+ &name,
+ &PyTuple_Type, &defaults))
+ return NULL;
+ if (name != Py_None && !PyString_Check(name)) {
+ PyErr_SetString(PyExc_TypeError,
+ "arg 3 (name) must be None or string");
+ return NULL;
+ }
+
+ newfunc = (PyFunctionObject *)PyFunction_New(code, globals);
+ if (newfunc == NULL)
+ return NULL;
+
+ if (name != Py_None) {
+ Py_XINCREF(name);
+ Py_XDECREF(newfunc->func_name);
+ newfunc->func_name = name;
+ }
+ if (defaults != Py_None) {
+ Py_XINCREF(defaults);
+ Py_XDECREF(newfunc->func_defaults);
+ newfunc->func_defaults = defaults;
+ }
+
+ return (PyObject *)newfunc;
+}
+
static void
func_dealloc(PyFunctionObject *op)
{
@@ -415,7 +461,7 @@ PyTypeObject PyFunction_Type = {
PyObject_GenericSetAttr, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
- 0, /* tp_doc */
+ func_doc, /* tp_doc */
(traverseproc)func_traverse, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
@@ -430,6 +476,9 @@ PyTypeObject PyFunction_Type = {
func_descr_get, /* tp_descr_get */
0, /* tp_descr_set */
offsetof(PyFunctionObject, func_dict), /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ func_new, /* tp_new */
};
diff --git a/Objects/sliceobject.c b/Objects/sliceobject.c
index 9a268b7..a43644d 100644
--- a/Objects/sliceobject.c
+++ b/Objects/sliceobject.c
@@ -164,6 +164,30 @@ PySlice_GetIndicesEx(PySliceObject *r, int length,
return 0;
}
+static PyObject *
+slice_new(PyTypeObject *type, PyObject *args, PyObject *kw)
+{
+ PyObject *start, *stop, *step;
+
+ start = stop = step = NULL;
+
+ if (!PyArg_ParseTuple(args, "O|OO:slice", &start, &stop, &step))
+ return NULL;
+
+ /* This swapping of stop and start is to maintain similarity with
+ range(). */
+ if (stop == NULL) {
+ stop = start;
+ start = NULL;
+ }
+ return PySlice_New(start, stop, step);
+}
+
+PyDoc_STRVAR(slice_doc,
+"slice([start,] stop[, step])\n\
+\n\
+Create a slice object. This is used for extended slicing (e.g. a[0:10:2]).");
+
static void
slice_dealloc(PySliceObject *r)
{
@@ -240,7 +264,7 @@ PyTypeObject PySlice_Type = {
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
- 0, /* tp_doc */
+ slice_doc, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
@@ -252,4 +276,10 @@ PyTypeObject PySlice_Type = {
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ slice_new, /* tp_new */
};
diff --git a/PC/os2vacpp/makefile b/PC/os2vacpp/makefile
index 029b901..680a8e6 100644
--- a/PC/os2vacpp/makefile
+++ b/PC/os2vacpp/makefile
@@ -182,7 +182,6 @@ MODULES = \
$(PATHOBJ)\MathModule.obj \
$(PATHOBJ)\MD5c.obj \
$(PATHOBJ)\MD5Module.obj \
- $(PATHOBJ)\NewModule.obj \
$(PATHOBJ)\Operator.obj \
$(PATHOBJ)\PCREModule.obj \
$(PATHOBJ)\PyPCRE.obj \
@@ -806,20 +805,6 @@ mpzmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \
$(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \
$(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h
-newmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \
- $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\compile.h $(PY_INCLUDE)\complexobject.h \
- pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \
- $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \
- $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \
- $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \
- $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \
- $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \
- $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \
- $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \
- $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \
- $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \
- $(PY_INCLUDE)\tupleobject.h
-
nismodule.obj: $(PY_INCLUDE)\abstract.h $(OS2TCPIP)\Include\sys\time.h $(PY_INCLUDE)\ceval.h \
$(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \
pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \
diff --git a/PC/os2vacpp/makefile.omk b/PC/os2vacpp/makefile.omk
index 6b90e89..0d11b6a 100644
--- a/PC/os2vacpp/makefile.omk
+++ b/PC/os2vacpp/makefile.omk
@@ -152,7 +152,6 @@ MODULES = \
MathModule.obj \
MD5c.obj \
MD5Module.obj \
- NewModule.obj \
Operator.obj \
PosixModule.obj \
RegexModule.obj \
@@ -619,14 +618,6 @@ mpzmodule.obj: abstract.h ceval.h classobject.h cobject.h \
pyerrors.h pyfpe.h pystate.h python.h pythonrun.h rangeobject.h \
sliceobject.h stringobject.h sysmodule.h traceback.h tupleobject.h
-newmodule.obj: abstract.h ceval.h classobject.h cobject.h compile.h \
- complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \
- funcobject.h import.h intobject.h intrcheck.h listobject.h \
- longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \
- myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \
- pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \
- stringobject.h sysmodule.h traceback.h tupleobject.h
-
nismodule.obj: abstract.h c:\mptn\include\sys\time.h ceval.h classobject.h \
cobject.h complexobject.h pyconfig.h dictobject.h fileobject.h \
floatobject.h funcobject.h import.h intobject.h intrcheck.h \
diff --git a/PCbuild/pythoncore.dsp b/PCbuild/pythoncore.dsp
index 1c32bf1..77b8268 100644
--- a/PCbuild/pythoncore.dsp
+++ b/PCbuild/pythoncore.dsp
@@ -1253,21 +1253,6 @@ SOURCE=..\Python\mystrtoul.c
# End Source File
# Begin Source File
-SOURCE=..\Modules\newmodule.c
-
-!IF "$(CFG)" == "pythoncore - Win32 Release"
-
-!ELSEIF "$(CFG)" == "pythoncore - Win32 Debug"
-
-!ELSEIF "$(CFG)" == "pythoncore - Win32 Alpha Debug"
-
-!ELSEIF "$(CFG)" == "pythoncore - Win32 Alpha Release"
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
SOURCE=..\Parser\node.c
!IF "$(CFG)" == "pythoncore - Win32 Release"
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 8f28ea6..7126391 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -107,27 +107,6 @@ Note that classes are callable, as are instances with a __call__() method.");
static PyObject *
-builtin_buffer(PyObject *self, PyObject *args)
-{
- PyObject *ob;
- int offset = 0;
- int size = Py_END_OF_BUFFER;
-
- if ( !PyArg_ParseTuple(args, "O|ii:buffer", &ob, &offset, &size) )
- return NULL;
- return PyBuffer_FromObject(ob, offset, size);
-}
-
-PyDoc_STRVAR(buffer_doc,
-"buffer(object [, offset[, size]]) -> object\n\
-\n\
-Create a new buffer object which references the given object.\n\
-The buffer will reference a slice of the target object from the\n\
-start of the object (or at the specified offset). The slice will\n\
-extend to the end of the target object (or with the specified size).");
-
-
-static PyObject *
builtin_callable(PyObject *self, PyObject *v)
{
return PyBool_FromLong((long)PyCallable_Check(v));
@@ -1079,31 +1058,6 @@ Return the number of items of a sequence or mapping.");
static PyObject *
-builtin_slice(PyObject *self, PyObject *args)
-{
- PyObject *start, *stop, *step;
-
- start = stop = step = NULL;
-
- if (!PyArg_ParseTuple(args, "O|OO:slice", &start, &stop, &step))
- return NULL;
-
- /* This swapping of stop and start is to maintain similarity with
- range(). */
- if (stop == NULL) {
- stop = start;
- start = NULL;
- }
- return PySlice_New(start, stop, step);
-}
-
-PyDoc_STRVAR(slice_doc,
-"slice([start,] stop[, step]) -> slice object\n\
-\n\
-Create a slice object. This is used for slicing by the Numeric extensions.");
-
-
-static PyObject *
builtin_locals(PyObject *self)
{
PyObject *d;
@@ -1775,7 +1729,6 @@ static PyMethodDef builtin_methods[] = {
{"__import__", builtin___import__, METH_VARARGS, import_doc},
{"abs", builtin_abs, METH_O, abs_doc},
{"apply", builtin_apply, METH_VARARGS, apply_doc},
- {"buffer", builtin_buffer, METH_VARARGS, buffer_doc},
{"callable", builtin_callable, METH_O, callable_doc},
{"chr", builtin_chr, METH_VARARGS, chr_doc},
{"cmp", builtin_cmp, METH_VARARGS, cmp_doc},
@@ -1813,7 +1766,6 @@ static PyMethodDef builtin_methods[] = {
{"repr", builtin_repr, METH_O, repr_doc},
{"round", builtin_round, METH_VARARGS, round_doc},
{"setattr", builtin_setattr, METH_VARARGS, setattr_doc},
- {"slice", builtin_slice, METH_VARARGS, slice_doc},
#ifdef Py_USING_UNICODE
{"unichr", builtin_unichr, METH_VARARGS, unichr_doc},
#endif
@@ -1849,6 +1801,7 @@ _PyBuiltin_Init(void)
SETBUILTIN("True", Py_True);
SETBUILTIN("basestring", &PyBaseString_Type);
SETBUILTIN("bool", &PyBool_Type);
+ SETBUILTIN("buffer", &PyBuffer_Type);
SETBUILTIN("classmethod", &PyClassMethod_Type);
#ifndef WITHOUT_COMPLEX
SETBUILTIN("complex", &PyComplex_Type);
@@ -1861,6 +1814,7 @@ _PyBuiltin_Init(void)
SETBUILTIN("list", &PyList_Type);
SETBUILTIN("long", &PyLong_Type);
SETBUILTIN("object", &PyBaseObject_Type);
+ SETBUILTIN("slice", &PySlice_Type);
SETBUILTIN("staticmethod", &PyStaticMethod_Type);
SETBUILTIN("str", &PyString_Type);
SETBUILTIN("super", &PySuper_Type);
diff --git a/Python/compile.c b/Python/compile.c
index 4bbe44f..b0e125d 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -91,6 +91,69 @@ static PyMemberDef code_memberlist[] = {
{NULL} /* Sentinel */
};
+PyDoc_STRVAR(code_doc,
+"code(argcount, nlocals, stacksize, flags, codestring, constants, names,\n\
+ varnames, filename, name, firstlineno, lnotab[, freevars[, cellvars]])\n\
+\n\
+Create a code object. Not for the faint of heart.");
+
+static PyObject *
+code_new(PyTypeObject *type, PyObject *args, PyObject *kw)
+{
+ int argcount;
+ int nlocals;
+ int stacksize;
+ int flags;
+ PyObject *code;
+ PyObject *consts;
+ PyObject *names;
+ PyObject *varnames;
+ PyObject *freevars = NULL;
+ PyObject *cellvars = NULL;
+ PyObject *filename;
+ PyObject *name;
+ int firstlineno;
+ PyObject *lnotab;
+
+ if (!PyArg_ParseTuple(args, "iiiiSO!O!O!SSiS|O!O!:code",
+ &argcount, &nlocals, &stacksize, &flags,
+ &code,
+ &PyTuple_Type, &consts,
+ &PyTuple_Type, &names,
+ &PyTuple_Type, &varnames,
+ &filename, &name,
+ &firstlineno, &lnotab,
+ &PyTuple_Type, &freevars,
+ &PyTuple_Type, &cellvars))
+ return NULL;
+
+ if (freevars == NULL || cellvars == NULL) {
+ PyObject *empty = PyTuple_New(0);
+ if (empty == NULL)
+ return NULL;
+ if (freevars == NULL) {
+ freevars = empty;
+ Py_INCREF(freevars);
+ }
+ if (cellvars == NULL) {
+ cellvars = empty;
+ Py_INCREF(cellvars);
+ }
+ Py_DECREF(empty);
+ }
+
+ if (!PyObject_CheckReadBuffer(code)) {
+ PyErr_SetString(PyExc_TypeError,
+ "bytecode object must be a single-segment read-only buffer");
+ return NULL;
+ }
+
+ return (PyObject *)PyCode_New(argcount, nlocals, stacksize, flags,
+ code, consts, names, varnames,
+ freevars, cellvars, filename, name,
+ firstlineno, lnotab);
+}
+
static void
code_dealloc(PyCodeObject *co)
{
@@ -200,7 +263,7 @@ PyTypeObject PyCode_Type = {
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
- 0, /* tp_doc */
+ code_doc, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
@@ -217,7 +280,7 @@ PyTypeObject PyCode_Type = {
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
- 0, /* tp_new */
+ code_new, /* tp_new */
};
#define NAME_CHARS \
diff --git a/Python/dynload_aix.c b/Python/dynload_aix.c
index 4e39c31..bb26c07 100644
--- a/Python/dynload_aix.c
+++ b/Python/dynload_aix.c
@@ -104,19 +104,6 @@ aix_getoldmodules(void **modlistptr)
return 0;
}
-static int
-aix_bindnewmodule(void *newmoduleptr, void *modlistptr)
-{
- register ModulePtr modptr;
-
- /*
- -- Bind the new module with the list of loaded modules.
- */
- for (modptr = (ModulePtr)modlistptr; modptr; modptr = modptr->next)
- if (loadbind(0, modptr->entry, newmoduleptr) != 0)
- return -1;
- return 0;
-}
static void
aix_loaderror(const char *pathname)
@@ -192,10 +179,6 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
aix_loaderror(pathname);
return NULL;
}
- if (aix_bindnewmodule((void *)p, staticmodlistptr) == -1) {
- aix_loaderror(pathname);
- return NULL;
- }
return p;
}
diff --git a/RISCOS/Makefile b/RISCOS/Makefile
index 649404b..bcfca81 100644
--- a/RISCOS/Makefile
+++ b/RISCOS/Makefile
@@ -264,9 +264,6 @@ $(LIB_PYTHON): $(OBJECTS)
$(LINK) -aof -o @.^.Modules.o.md5link @.^.Modules.o.md5c @.^.Modules.o.md5module
$(MAKEDLK) -d @.^.Lib.md5/pyd -s s.linktab -o @.^.Modules.o.md5link -e initmd5
-@.^.Lib.new/pyd: @.^.Modules.o.newmodule s.linktab
- $(MAKEDLK) -d @.^.Lib.new/pyd -s s.linktab -o @.^.Modules.o.newmodule -e initnew
-
@.^.Lib.operator/pyd: @.^.Modules.o.operator s.linktab
$(MAKEDLK) -d @.^.Lib.operator/pyd -s s.linktab -o @.^.Modules.o.operator -e initoperator