summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1996-06-17 16:56:56 (GMT)
committerGuido van Rossum <guido@python.org>1996-06-17 16:56:56 (GMT)
commit26b310a3fd3e4aa7444baa5769344f056e8dd64e (patch)
tree429c95cc160f08468dde62f3e716ceb2d38a9897 /Modules
parent53725a2858fe992cac4b343615b1594f201cced4 (diff)
downloadcpython-26b310a3fd3e4aa7444baa5769344f056e8dd64e.zip
cpython-26b310a3fd3e4aa7444baa5769344f056e8dd64e.tar.gz
cpython-26b310a3fd3e4aa7444baa5769344f056e8dd64e.tar.bz2
Added new.instance(class, dict).
Diffstat (limited to 'Modules')
-rw-r--r--Modules/newmodule.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/Modules/newmodule.c b/Modules/newmodule.c
index afe3092..0591d3c 100644
--- a/Modules/newmodule.c
+++ b/Modules/newmodule.c
@@ -27,6 +27,31 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "allobjects.h"
#include "compile.h"
+static char new_instance_doc[] =
+"Create an instance object from (CLASS, DICT) without calling its __init__().";
+
+static object *
+new_instance(unused, args)
+ object* unused;
+ object* args;
+{
+ object* klass;
+ object *dict;
+ instanceobject *inst;
+ if (!newgetargs(args, "O!O!",
+ &Classtype, &klass,
+ &Dicttype, &dict))
+ return NULL;
+ inst = NEWOBJ(instanceobject, &Instancetype);
+ if (inst == NULL)
+ return NULL;
+ INCREF(klass);
+ INCREF(dict);
+ inst->in_class = (classobject *)klass;
+ inst->in_dict = dict;
+ return (object *)inst;
+}
+
static char new_im_doc[] =
"Create a instance method object from (FUNCTION, INSTANCE, CLASS).";
@@ -163,6 +188,7 @@ new_class(unused, args)
}
static struct methodlist new_methods[] = {
+ {"instance", new_instance, 1, new_instance_doc},
{"instancemethod", new_instancemethod, 1, new_im_doc},
#if 0
{"function", new_function, 1, new_function_doc},