diff --git a/Include/assert.h b/Include/assert.h index 32d78bbd286..ac9c5d2c0e5 100644 --- a/Include/assert.h +++ b/Include/assert.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/bitset.h b/Include/bitset.h index d0761486ec9..07b64b0a64c 100644 --- a/Include/bitset.h +++ b/Include/bitset.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/bltinmodule.h b/Include/bltinmodule.h index dace6c59ed7..f162af1a569 100644 --- a/Include/bltinmodule.h +++ b/Include/bltinmodule.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/ceval.h b/Include/ceval.h index e7281f4615c..bec66812635 100644 --- a/Include/ceval.h +++ b/Include/ceval.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/cgensupport.h b/Include/cgensupport.h index c2598f84d1c..5c2cbd4cfa5 100644 --- a/Include/cgensupport.h +++ b/Include/cgensupport.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/classobject.h b/Include/classobject.h index b33cacce61f..88b955a4159 100644 --- a/Include/classobject.h +++ b/Include/classobject.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/compile.h b/Include/compile.h index 92b34d88198..a4478528d7d 100644 --- a/Include/compile.h +++ b/Include/compile.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved @@ -28,7 +28,9 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* An intermediate code fragment contains: - a string that encodes the instructions, - a list of the constants, - - and a list of the names used. */ + - a list of the names used, + - the filename from which it was compiled, + - the name of the object for which it was compiled. */ typedef struct { OB_HEAD @@ -36,6 +38,7 @@ typedef struct { object *co_consts; /* list of immutable constant objects */ object *co_names; /* list of stringobjects */ object *co_filename; /* string */ + object *co_name; /* string */ } codeobject; extern typeobject Codetype; @@ -46,4 +49,5 @@ extern typeobject Codetype; /* Public interface */ struct _node; /* Declare the existence of this type */ codeobject *compile PROTO((struct _node *, char *)); -codeobject *newcodeobject PROTO((object *, object *, object *, object *)); +codeobject *newcodeobject + PROTO((object *, object *, object *, object *, object *)); diff --git a/Include/dictobject.h b/Include/dictobject.h index 2c5d5394986..ce71570ab44 100644 --- a/Include/dictobject.h +++ b/Include/dictobject.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved @@ -22,28 +22,23 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ -/* -Dictionary object type -- mapping from char * to object. -NB: the key is given as a char *, not as a stringobject. -These functions set errno for errors. Functions dictremove() and -dictinsert() return nonzero for errors, getdictsize() returns -1, -the others NULL. A successful call to dictinsert() calls INCREF() -for the inserted item. -*/ +/* All in the sake of backward compatibility... */ -extern typeobject Dicttype; +#include "mappingobject.h" -#define is_dictobject(op) ((op)->ob_type == &Dicttype) +#define is_dictobject(op) is_mappingobject(op) + +#define newdictobject newmappingobject -extern object *newdictobject PROTO((void)); extern object *dictlookup PROTO((object *dp, char *key)); extern int dictinsert PROTO((object *dp, char *key, object *item)); extern int dictremove PROTO((object *dp, char *key)); -extern int getdictsize PROTO((object *dp)); extern char *getdictkey PROTO((object *dp, int i)); -extern object *getdictkeys PROTO((object *dp)); -extern object *getdict2key PROTO((object *dp, int i)); -extern object *dict2lookup PROTO((object *dp, object *key)); -extern int dict2insert PROTO((object *dp, object *key, object *item)); -extern int dict2remove PROTO((object *dp, object *key)); +#define getdictsize getmappingsize +#define getdictkeys getmappingkeys + +#define getdict2key getmappingkey +#define dict2lookup mappinglookup +#define dict2insert mappinginsert +#define dict2remove mappingremove diff --git a/Include/errcode.h b/Include/errcode.h index 33d65c23948..1439c7bf993 100644 --- a/Include/errcode.h +++ b/Include/errcode.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/errors.h b/Include/errors.h index 5a2a00a650d..f2d7b1acb49 100755 --- a/Include/errors.h +++ b/Include/errors.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/eval.h b/Include/eval.h index da4bbde6005..8ac672f3a05 100644 --- a/Include/eval.h +++ b/Include/eval.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/fileobject.h b/Include/fileobject.h index 7bce698cf8e..ee2201fa65f 100644 --- a/Include/fileobject.h +++ b/Include/fileobject.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/floatobject.h b/Include/floatobject.h index 9ea3e0171e0..9a70c3b73f2 100644 --- a/Include/floatobject.h +++ b/Include/floatobject.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/frameobject.h b/Include/frameobject.h index dd36468ec16..4d17267b97c 100644 --- a/Include/frameobject.h +++ b/Include/frameobject.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/funcobject.h b/Include/funcobject.h index eef2ce1be63..d24600d8200 100644 --- a/Include/funcobject.h +++ b/Include/funcobject.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/grammar.h b/Include/grammar.h index 5fd89158bc3..5aace87dd1e 100644 --- a/Include/grammar.h +++ b/Include/grammar.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/intobject.h b/Include/intobject.h index d89abb33b0d..ef11c2f0898 100644 --- a/Include/intobject.h +++ b/Include/intobject.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/intrcheck.h b/Include/intrcheck.h index 68d49771e1c..886dbed5509 100644 --- a/Include/intrcheck.h +++ b/Include/intrcheck.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/listobject.h b/Include/listobject.h index 710db2dad60..519776a23b1 100644 --- a/Include/listobject.h +++ b/Include/listobject.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/longintrepr.h b/Include/longintrepr.h index 84f35240148..7ca69ba76de 100644 --- a/Include/longintrepr.h +++ b/Include/longintrepr.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/longobject.h b/Include/longobject.h index c17b2f5924c..5a8b7157662 100644 --- a/Include/longobject.h +++ b/Include/longobject.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/marshal.h b/Include/marshal.h index 636357c50f7..9b16227af58 100644 --- a/Include/marshal.h +++ b/Include/marshal.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/metagrammar.h b/Include/metagrammar.h index 1923996fcce..40b7d6c83d8 100644 --- a/Include/metagrammar.h +++ b/Include/metagrammar.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/methodobject.h b/Include/methodobject.h index c6c5606bfa4..0cbfd6a98e9 100644 --- a/Include/methodobject.h +++ b/Include/methodobject.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/moduleobject.h b/Include/moduleobject.h index 0dfcadac6d0..bf3c4a42d11 100644 --- a/Include/moduleobject.h +++ b/Include/moduleobject.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/mymalloc.h b/Include/mymalloc.h index e4315bdb98f..6259712f0f3 100644 --- a/Include/mymalloc.h +++ b/Include/mymalloc.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/myselect.h b/Include/myselect.h index 54884adcf0a..3f65243621c 100644 --- a/Include/myselect.h +++ b/Include/myselect.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/node.h b/Include/node.h index fa60f5113d8..31bae1be244 100644 --- a/Include/node.h +++ b/Include/node.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/object.h b/Include/object.h index f644be3a3d7..ff02bea6d43 100644 --- a/Include/object.h +++ b/Include/object.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved @@ -188,6 +188,10 @@ typedef struct _typeobject { number_methods *tp_as_number; sequence_methods *tp_as_sequence; mapping_methods *tp_as_mapping; + + /* More standard operations (at end for binary compatibility) */ + + long (*tp_hash) FPROTO((object *)); } typeobject; extern typeobject Typetype; /* The type of type objects */ @@ -199,7 +203,9 @@ extern int printobject PROTO((object *, FILE *, int)); extern object * reprobject PROTO((object *)); extern int cmpobject PROTO((object *, object *)); extern object *getattr PROTO((object *, char *)); -extern int setattr PROTO((object *, char *, object *)); +extern object *getattro PROTO((object *, object *)); +extern int setattro PROTO((object *, object *, object *)); +extern long hashobject PROTO((object *)); /* Flag bits for printing: */ #define PRINT_RAW 1 /* No string quotes etc. */ diff --git a/Include/objimpl.h b/Include/objimpl.h index 3d1dceb5a18..683f03e47f3 100644 --- a/Include/objimpl.h +++ b/Include/objimpl.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/opcode.h b/Include/opcode.h index a0db342d45c..67c0b82e408 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved @@ -113,6 +113,10 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #define LOAD_LOCAL 115 /* Index in name list */ #define LOAD_GLOBAL 116 /* Index in name list */ +#define LOAD_FAST 117 /* Local variable number */ +#define STORE_FAST 118 /* Local variable number */ +#define RESERVE_FAST 119 /* Number of local variables */ + #define SETUP_LOOP 120 /* Target address (absolute) */ #define SETUP_EXCEPT 121 /* "" */ #define SETUP_FINALLY 122 /* "" */ diff --git a/Include/osdefs.h b/Include/osdefs.h index 773abdffc40..939978a6e82 100644 --- a/Include/osdefs.h +++ b/Include/osdefs.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/parsetok.h b/Include/parsetok.h index 3e3cc6c2d48..623c4d8b1fa 100644 --- a/Include/parsetok.h +++ b/Include/parsetok.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/pgenheaders.h b/Include/pgenheaders.h index 86071420eb9..049e9f45357 100644 --- a/Include/pgenheaders.h +++ b/Include/pgenheaders.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/pyerrors.h b/Include/pyerrors.h index 5a2a00a650d..f2d7b1acb49 100644 --- a/Include/pyerrors.h +++ b/Include/pyerrors.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/pythonrun.h b/Include/pythonrun.h index 162a6f74f62..94413768110 100644 --- a/Include/pythonrun.h +++ b/Include/pythonrun.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/structmember.h b/Include/structmember.h index 8520863de61..425300c084e 100644 --- a/Include/structmember.h +++ b/Include/structmember.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/sysmodule.h b/Include/sysmodule.h index e7035946503..36a4499b498 100644 --- a/Include/sysmodule.h +++ b/Include/sysmodule.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/token.h b/Include/token.h index ba5717be658..053ceabedf4 100644 --- a/Include/token.h +++ b/Include/token.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/traceback.h b/Include/traceback.h index 08370e37e21..c45526cd202 100644 --- a/Include/traceback.h +++ b/Include/traceback.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Include/tupleobject.h b/Include/tupleobject.h index 448fb71d20a..4c8d302bf56 100644 --- a/Include/tupleobject.h +++ b/Include/tupleobject.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Modules/cdmodule.c b/Modules/cdmodule.c index c0bc3c7d1ac..27cf35c43a9 100644 --- a/Modules/cdmodule.c +++ b/Modules/cdmodule.c @@ -1,6 +1,6 @@ /********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Modules/cgensupport.c b/Modules/cgensupport.c index a3023ebb9c0..5dcac867c75 100644 --- a/Modules/cgensupport.c +++ b/Modules/cgensupport.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Modules/cgensupport.h b/Modules/cgensupport.h index c2598f84d1c..5c2cbd4cfa5 100644 --- a/Modules/cgensupport.h +++ b/Modules/cgensupport.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Modules/config.c.in b/Modules/config.c.in index da74276fb5c..7dba37ce0c0 100644 --- a/Modules/config.c.in +++ b/Modules/config.c.in @@ -62,12 +62,12 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "patchlevel.h" -#define VERSION "0.9.%d (%s)" +#define VERSION "0.9.%d BETA (%s)" #ifdef __DATE__ #define DATE __DATE__ #else -#define DATE ">= 11 Jan 1993" +#define DATE ">= 27 Mar 1993" #endif #ifdef USE_STDWIN diff --git a/Modules/dbmmodule.c b/Modules/dbmmodule.c index 46559798a01..0f368d202f7 100644 --- a/Modules/dbmmodule.c +++ b/Modules/dbmmodule.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Modules/fcntlmodule.c b/Modules/fcntlmodule.c index d4d48f82d6f..7862b062043 100644 --- a/Modules/fcntlmodule.c +++ b/Modules/fcntlmodule.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Modules/imgfile.c b/Modules/imgfile.c index 7783083aaf8..a6db0266d2a 100644 --- a/Modules/imgfile.c +++ b/Modules/imgfile.c @@ -58,7 +58,7 @@ static imgfile_error(str) { err_setstr(ImgfileError, str); error_called = 1; - return; /* To imglib, which will return a failure indictaor */ + return; /* To imglib, which will return a failure indicator */ } diff --git a/Modules/sgimodule.c b/Modules/sgimodule.c index 1951ad8bc98..b3733846a0d 100644 --- a/Modules/sgimodule.c +++ b/Modules/sgimodule.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Modules/stropmodule.c b/Modules/stropmodule.c index f00cfc78b50..61574426ef8 100644 --- a/Modules/stropmodule.c +++ b/Modules/stropmodule.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Modules/structmodule.c b/Modules/structmodule.c index eaeee5013a2..03e8f182915 100644 --- a/Modules/structmodule.c +++ b/Modules/structmodule.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Modules/sunaudiodev.c b/Modules/sunaudiodev.c index d02041acbff..b4470dd85df 100644 --- a/Modules/sunaudiodev.c +++ b/Modules/sunaudiodev.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Objects/classobject.c b/Objects/classobject.c index 95b85f52a42..823e397f795 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -261,7 +261,7 @@ instance_setattr(inst, name, v) return dictinsert(inst->in_attr, name, v); } -object * +static object * instance_repr(inst) instanceobject *inst; { @@ -280,7 +280,7 @@ instance_repr(inst) return res; } -int +static int instance_compare(inst, other) instanceobject *inst, *other; { @@ -311,7 +311,43 @@ instance_compare(inst, other) return outcome; } -int +static long +instance_hash(inst) + instanceobject *inst; +{ + object *func; + object *res; + int outcome; + + func = instance_getattr(inst, "__hash__"); + if (func == NULL) { + /* If there is no __cmp__ method, we hash on the address. + If a __cmp__ method exists, there must be a __hash__. */ + err_clear(); + func = instance_getattr(inst, "__cmp__"); + if (func == NULL) + return (long)inst; + err_setstr(TypeError, "unhashable instance"); + return -1; + } + res = call_object(func, (object *)NULL); + DECREF(func); + if (res == NULL) + return -1; + if (is_intobject(res)) { + outcome = getintvalue(res); + if (outcome == -1) + outcome = -2; + } + else { + err_setstr(TypeError, "__hash__() should return an int"); + outcome = -1; + } + DECREF(res); + return outcome; +} + +static int instance_length(inst) instanceobject *inst; { @@ -339,7 +375,7 @@ instance_length(inst) return outcome; } -object * +static object * instance_subscript(inst, key) instanceobject *inst; object *key; @@ -362,7 +398,7 @@ instance_subscript(inst, key) return res; } -int +static int instance_ass_subscript(inst, key, value) instanceobject*inst; object *key; @@ -395,7 +431,7 @@ instance_ass_subscript(inst, key, value) return 0; } -mapping_methods instance_as_mapping = { +static mapping_methods instance_as_mapping = { instance_length, /*mp_length*/ instance_subscript, /*mp_subscript*/ instance_ass_subscript, /*mp_ass_subscript*/ @@ -612,7 +648,7 @@ UNARY(instance_neg, "__neg__") UNARY(instance_pos, "__pos__") UNARY(instance_abs, "__abs__") -int +static int instance_nonzero(self) instanceobject *self; { @@ -739,9 +775,10 @@ typeobject Instancetype = { &instance_as_number, /*tp_as_number*/ &instance_as_sequence, /*tp_as_sequence*/ &instance_as_mapping, /*tp_as_mapping*/ + instance_hash, /*tp_hash*/ }; -object * +static object * instance_convert(inst, methodname) object *inst; char *methodname; @@ -837,6 +874,20 @@ instancemethod_compare(a, b) return cmp; } +static long +instancemethod_hash(a) + instancemethodobject *a; +{ + long x, y; + x = hashobject(a->im_self); + if (x == -1) + return -1; + y = hashobject(a->im_func); + if (y == -1) + return -1; + return x ^ y; +} + typeobject Instancemethodtype = { OB_HEAD_INIT(&Typetype) 0, @@ -852,4 +903,5 @@ typeobject Instancemethodtype = { 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ + instancemethod_hash, /*tp_hash*/ }; diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 1cfa3082e0f..fa66a9d73fc 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -24,8 +24,13 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* Mapping object implementation; using a hash table */ +/* This file should really be called "dictobject.c", since "mapping" + is the generic name for objects with an unorderred arbitrary key + set (just like lists are sequences), but since it improves (and was + originally derived from) a file by that name I had to change its + name. For the user these objects are still called "dictionaries". */ + #include "allobjects.h" -#include "mappingobject.h" #include "modsupport.h" @@ -593,7 +598,7 @@ mapping_getattr(mp, name) typeobject Mappingtype = { OB_HEAD_INIT(&Typetype) 0, - "mapping", + "dictionary", sizeof(mappingobject), 0, mapping_dealloc, /*tp_dealloc*/ diff --git a/Objects/floatobject.c b/Objects/floatobject.c index e5635837d07..8533e0e7be4 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -145,6 +145,38 @@ float_compare(v, w) return (i < j) ? -1 : (i > j) ? 1 : 0; } +static long +float_hash(v) + floatobject *v; +{ + double intpart, fractpart; + int expo; + long x; + /* This is designed so that Python numbers with the same + value hash to the same value, otherwise comparisons + of mapping keys will turn out weird */ + fractpart = modf(v->ob_fval, &intpart); + if (fractpart == 0.0) { + if (intpart > 0x7fffffffL || -intpart > 0x7fffffffL) { + /* Convert to long int and use its hash... */ + object *w = dnewlongobject(v->ob_fval); + if (w == NULL) + return -1; + x = hashobject(w); + DECREF(w); + return x; + } + x = (long)intpart; + } + else { + fractpart = frexp(fractpart, &expo); + x = (long) (intpart + fractpart) ^ expo; /* Rather arbitrary */ + } + if (x == -1) + x = -2; + return x; +} + static object * float_add(v, w) floatobject *v; @@ -378,4 +410,5 @@ typeobject Floattype = { &float_as_number, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ + float_hash, /*tp_hash */ }; diff --git a/Objects/frameobject.c b/Objects/frameobject.c index c7b5ddf58ef..cec050249fa 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Objects/funcobject.c b/Objects/funcobject.c index a779ebbeb21..ccf1b29fda6 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved @@ -25,7 +25,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* Function object implementation */ #include "allobjects.h" - +#include "compile.h" #include "structmember.h" typedef struct { @@ -98,6 +98,17 @@ func_dealloc(op) DEL(op); } +static object* +func_repr(op) + funcobject *op; +{ + char buf[140]; + sprintf(buf, "", + getstringvalue(((codeobject*)(op->func_code))->co_name), + (long)op); + return newstringobject(buf); +} + typeobject Functype = { OB_HEAD_INIT(&Typetype) 0, @@ -109,5 +120,5 @@ typeobject Functype = { func_getattr, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ - 0, /*tp_repr*/ + func_repr, /*tp_repr*/ }; diff --git a/Objects/intobject.c b/Objects/intobject.c index 858458c0848..6806f0c109a 100644 --- a/Objects/intobject.c +++ b/Objects/intobject.c @@ -144,6 +144,16 @@ int_compare(v, w) return (i < j) ? -1 : (i > j) ? 1 : 0; } +static long +int_hash(v) + intobject *v; +{ + long x = v -> ob_ival; + if (x == -1) + x = -2; + return x; +} + static object * int_add(v, w) intobject *v; @@ -413,7 +423,7 @@ int_or(v, w) static object * int_int(v) - object *v; + intobject *v; { INCREF(v); return v; @@ -421,26 +431,24 @@ int_int(v) static object * int_long(v) - object *v; + intobject *v; { - long x = getintvalue(v); - return newlongobject(x); + return newlongobject((v -> ob_ival)); } static object * int_float(v) - object *v; + intobject *v; { - long x = getintvalue(v); - return newfloatobject((double)x); + return newfloatobject((double)(v -> ob_ival)); } static object * int_oct(v) - object *v; + intobject *v; { char buf[20]; - long x = getintvalue(v); + long x = v -> ob_ival; if (x == 0) strcpy(buf, "0"); else if (x > 0) @@ -452,10 +460,10 @@ int_oct(v) static object * int_hex(v) - object *v; + intobject *v; { char buf[20]; - long x = getintvalue(v); + long x = v -> ob_ival; if (x >= 0) sprintf(buf, "0x%lx", x); else @@ -463,7 +471,6 @@ int_hex(v) return newstringobject(buf); } - static number_methods int_as_number = { int_add, /*nb_add*/ int_sub, /*nb_subtract*/ @@ -505,4 +512,5 @@ typeobject Inttype = { &int_as_number, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ + &int_hash, /*tp_hash*/ }; diff --git a/Objects/longobject.c b/Objects/longobject.c index 38473e24226..fb82a1fc88b 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -555,6 +555,7 @@ static void long_dealloc PROTO((object *)); static int long_print PROTO((object *, FILE *, int)); static object *long_repr PROTO((object *)); static int long_compare PROTO((longobject *, longobject *)); +static long long_hash PROTO((longobject *)); static object *long_add PROTO((longobject *, longobject *)); static object *long_sub PROTO((longobject *, longobject *)); @@ -615,6 +616,35 @@ long_compare(a, b) return sign < 0 ? -1 : sign > 0 ? 1 : 0; } +static long +long_hash(v) + longobject *v; +{ + long x; + int i, sign; + + /* This is designed so that Python ints and longs with the + same value hash to the same value, otherwise comparisons + of mapping keys will turn out weird */ + i = v->ob_size; + sign = 1; + x = 0; + if (i < 0) { + sign = -1; + i = -(i); + } + while (--i >= 0) { + /* Force a 32-bit circular shift */ + x = ((x << SHIFT) & ~MASK) | ((x >> (32-SHIFT)) & MASK); + x += v->ob_digit[i]; + } + x = x * sign; + if (x == -1) + x = -2; + return x; +} + + /* Add the absolute values of two long integers. */ static longobject *x_add PROTO((longobject *, longobject *)); @@ -1346,4 +1376,6 @@ typeobject Longtype = { &long_as_number,/*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ + (long (*) FPROTO((object *))) + long_hash, /*tp_hash*/ }; diff --git a/Objects/mappingobject.c b/Objects/mappingobject.c index 1cfa3082e0f..fa66a9d73fc 100644 --- a/Objects/mappingobject.c +++ b/Objects/mappingobject.c @@ -24,8 +24,13 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* Mapping object implementation; using a hash table */ +/* This file should really be called "dictobject.c", since "mapping" + is the generic name for objects with an unorderred arbitrary key + set (just like lists are sequences), but since it improves (and was + originally derived from) a file by that name I had to change its + name. For the user these objects are still called "dictionaries". */ + #include "allobjects.h" -#include "mappingobject.h" #include "modsupport.h" @@ -593,7 +598,7 @@ mapping_getattr(mp, name) typeobject Mappingtype = { OB_HEAD_INIT(&Typetype) 0, - "mapping", + "dictionary", sizeof(mappingobject), 0, mapping_dealloc, /*tp_dealloc*/ diff --git a/Objects/methodobject.c b/Objects/methodobject.c index d0b29c7ee08..d7ba02e7a1d 100644 --- a/Objects/methodobject.c +++ b/Objects/methodobject.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved @@ -108,11 +108,41 @@ meth_repr(m) sprintf(buf, "", m->m_name); else sprintf(buf, - "", - m->m_name, m->m_self->ob_type->tp_name); + "", + m->m_name, m->m_self->ob_type->tp_name, + (long)m->m_self); return newstringobject(buf); } +static int +meth_compare(a, b) + methodobject *a, *b; +{ + if (a->m_self != b->m_self) + return cmpobject(a->m_self, b->m_self); + if (a->m_meth == b->m_meth) + return 0; + if (strcmp(a->m_name, b->m_name) < 0) + return -1; + else + return 1; +} + +static long +meth_hash(a) + methodobject *a; +{ + long x, y; + if (a->m_self == NULL) + x = 0; + else { + x = hashobject(a->m_self); + if (x == -1) + return -1; + } + return x ^ (long) a->m_meth; +} + typeobject Methodtype = { OB_HEAD_INIT(&Typetype) 0, @@ -123,11 +153,12 @@ typeobject Methodtype = { 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + meth_compare, /*tp_compare*/ meth_repr, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ + meth_hash, /*tp_hash*/ }; object *listmethods PROTO((struct methodlist *)); /* Forward */ diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c index 9733a774b91..749d872b259 100644 --- a/Objects/moduleobject.c +++ b/Objects/moduleobject.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Objects/object.c b/Objects/object.c index 707dd58eb96..9a8d4b391be 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved @@ -165,6 +165,20 @@ cmpobject(v, w) return (*tp->tp_compare)(v, w); } +long +hashobject(v) + object *v; +{ + typeobject *tp = v->ob_type; + if (tp->tp_hash != NULL) + return (*tp->tp_hash)(v); + if (tp->tp_compare == NULL) + return (long) v; /* Use address as hash value */ + /* If there's a cmp but no hash defined, the object can't be hashed */ + err_setstr(TypeError, "unhashable type"); + return -1; +} + object * getattr(v, name) object *v; @@ -229,6 +243,7 @@ static typeobject Notype = { 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ + 0, /*tp_hash */ }; object NoObject = { diff --git a/Objects/stringobject.c b/Objects/stringobject.c index 25f12fc36d0..5c7345d40fb 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -293,6 +293,21 @@ string_compare(a, b) return (len_a < len_b) ? -1 : (len_a > len_b) ? 1 : 0; } +static long +string_hash(a) + stringobject *a; +{ + register int len = a->ob_size; + register unsigned char *p = (unsigned char *) a->ob_sval; + register long x = *p << 7; + while (--len >= 0) + x = (x + x + x) ^ *p++; + x ^= a->ob_size; + if (x == -1) + x = -2; + return x; +} + static sequence_methods string_as_sequence = { string_length, /*sq_length*/ string_concat, /*sq_concat*/ @@ -318,6 +333,7 @@ typeobject Stringtype = { 0, /*tp_as_number*/ &string_as_sequence, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ + string_hash, /*tp_hash*/ }; void diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index 0875a0c112c..9eb332b3011 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved @@ -179,6 +179,27 @@ tuplecompare(v, w) return v->ob_size - w->ob_size; } +static long +tuplehash(v) + tupleobject *v; +{ + register long x, y; + register int len = v->ob_size; + register object **p; + x = 0x345678L; + p = v->ob_item; + while (--len >= 0) { + y = hashobject(*p++); + if (y == -1) + return -1; + x = (x + x + x) ^ y; + } + x ^= v->ob_size; + if (x == -1) + x = -2; + return x; +} + static int tuplelength(a) tupleobject *a; @@ -329,4 +350,5 @@ typeobject Tupletype = { 0, /*tp_as_number*/ &tuple_as_sequence, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ + tuplehash, /*tp_hash*/ }; diff --git a/Objects/typeobject.c b/Objects/typeobject.c index f78d280f819..7176008b29c 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Parser/acceler.c b/Parser/acceler.c index 6765de0469d..22df3cfa520 100644 --- a/Parser/acceler.c +++ b/Parser/acceler.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Parser/assert.h b/Parser/assert.h index 32d78bbd286..ac9c5d2c0e5 100644 --- a/Parser/assert.h +++ b/Parser/assert.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Parser/bitset.c b/Parser/bitset.c index 2fd02bef6a4..e7249c847b5 100644 --- a/Parser/bitset.c +++ b/Parser/bitset.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Parser/firstsets.c b/Parser/firstsets.c index 8f3c70fe3ee..3d1b3a7a57a 100644 --- a/Parser/firstsets.c +++ b/Parser/firstsets.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Parser/grammar.c b/Parser/grammar.c index dd2c58ea3dd..81b51ded7de 100644 --- a/Parser/grammar.c +++ b/Parser/grammar.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Parser/grammar1.c b/Parser/grammar1.c index ed6815d426f..716f8b6b49c 100644 --- a/Parser/grammar1.c +++ b/Parser/grammar1.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Parser/intrcheck.c b/Parser/intrcheck.c index bd73f8b82b6..feab7668fc4 100644 --- a/Parser/intrcheck.c +++ b/Parser/intrcheck.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Parser/listnode.c b/Parser/listnode.c index 7b5dfa15f08..07c66ac1418 100644 --- a/Parser/listnode.c +++ b/Parser/listnode.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Parser/metagrammar.c b/Parser/metagrammar.c index 7a3e31579b4..c670555ceeb 100644 --- a/Parser/metagrammar.c +++ b/Parser/metagrammar.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Parser/node.c b/Parser/node.c index b59e4f71ca8..1362f8be6fc 100644 --- a/Parser/node.c +++ b/Parser/node.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Parser/parser.c b/Parser/parser.c index 7d053c9a0bc..8a85a32bf34 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Parser/parser.h b/Parser/parser.h index 2c0e327e0e1..0763312aaad 100644 --- a/Parser/parser.h +++ b/Parser/parser.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Parser/pgen.c b/Parser/pgen.c index d88245bf0ce..a1e03fe9441 100644 --- a/Parser/pgen.c +++ b/Parser/pgen.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Parser/pgen.h b/Parser/pgen.h index 59af07dc15e..948f5a589fc 100644 --- a/Parser/pgen.h +++ b/Parser/pgen.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Parser/pgenmain.c b/Parser/pgenmain.c index c19a446dacb..57cdc6190d1 100644 --- a/Parser/pgenmain.c +++ b/Parser/pgenmain.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Parser/printgrammar.c b/Parser/printgrammar.c index ead876fcc04..67a7f027961 100644 --- a/Parser/printgrammar.c +++ b/Parser/printgrammar.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index 5b5b9b2b31d..22c20b0b763 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Parser/tokenizer.h b/Parser/tokenizer.h index 723ef780831..636295a12e9 100644 --- a/Parser/tokenizer.h +++ b/Parser/tokenizer.h @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 4213fc38a2b..8fd12e41927 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -281,10 +281,28 @@ builtin_getattr(self, args) object *args; { object *v; - char *name; - if (!getargs(args, "(Os)", &v, &name)) + object *name; + if (!getargs(args, "(OS)", &v, &name)) return NULL; - return getattr(v, name); + return getattro(v, name); +} + +static object * +builtin_hasattr(self, args) + object *self; + object *args; +{ + object *v; + object *name; + if (!getargs(args, "(OS)", &v, &name)) + return NULL; + v = getattro(v, name); + if (v == NULL) { + err_clear(); + return newintobject(0L); + } + DECREF(v); + return newintobject(1L); } static object * @@ -293,16 +311,31 @@ builtin_setattr(self, args) object *args; { object *v; - char *name; + object *name; object *value; - if (!getargs(args, "(OsO)", &v, &name, &value)) + if (!getargs(args, "(OSO)", &v, &name, &value)) return NULL; - if (setattr(v, name, value) != 0) + if (setattro(v, name, value) != 0) return NULL; INCREF(None); return None; } +static object * +builtin_hash(self, args) + object *self; + object *args; +{ + object *v; + long x; + if (!getargs(args, "O", &v)) + return NULL; + x = hashobject(v); + if (x == -1) + return NULL; + return newintobject(x); +} + static object * builtin_hex(self, v) object *self; @@ -687,6 +720,8 @@ static struct methodlist builtin_methods[] = { {"execfile", builtin_execfile}, {"float", builtin_float}, {"getattr", builtin_getattr}, + {"hasattr", builtin_hasattr}, + {"hash", builtin_hash}, {"hex", builtin_hex}, {"input", builtin_input}, {"int", builtin_int}, diff --git a/Python/ceval.c b/Python/ceval.c index 97f38ab0c0d..64f2429a74b 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -173,6 +173,7 @@ eval_code(co, globals, locals, arg) register object *u; register object *t; register frameobject *f; /* Current frame */ + register listobject *fastlocals = NULL; object *trace = NULL; /* Trace function or NULL */ object *retval; /* Return value iff why == WHY_RETURN */ char *name; /* Name used by some instructions */ @@ -911,19 +912,18 @@ eval_code(co, globals, locals, arg) break; case STORE_ATTR: - name = GETNAME(oparg); + w = GETNAMEV(oparg); v = POP(); u = POP(); - err = setattr(v, name, u); /* v.name = u */ + err = setattro(v, w, u); /* v.w = u */ DECREF(v); DECREF(u); break; case DELETE_ATTR: - name = GETNAME(oparg); + w = GETNAMEV(oparg); v = POP(); - err = setattr(v, name, (object *)NULL); - /* del v.name */ + err = setattro(v, w, (object *)NULL); /* del v.w */ DECREF(v); break; @@ -992,6 +992,22 @@ eval_code(co, globals, locals, arg) INCREF(x); PUSH(x); break; + + case RESERVE_FAST: + if (oparg > 0) { + XDECREF(fastlocals); + x = newlistobject(oparg); + fastlocals = (listobject *) x; + } + break; + + case LOAD_FAST: + /* NYI */ + break; + + case STORE_FAST: + /* NYI */ + break; case BUILD_TUPLE: x = newtupleobject(oparg); @@ -1025,9 +1041,9 @@ eval_code(co, globals, locals, arg) break; case LOAD_ATTR: - name = GETNAME(oparg); + w = GETNAMEV(oparg); v = POP(); - x = getattr(v, name); + x = getattro(v, w); DECREF(v); PUSH(x); break; @@ -1283,6 +1299,8 @@ eval_code(co, globals, locals, arg) current_frame = f->f_back; DECREF(f); + + XDECREF(fastlocals); return retval; } diff --git a/Python/cgensupport.c b/Python/cgensupport.c index a3023ebb9c0..5dcac867c75 100644 --- a/Python/cgensupport.c +++ b/Python/cgensupport.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Python/compile.c b/Python/compile.c index 483e5247b4a..116b6bb1c7c 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved @@ -50,6 +50,7 @@ static struct memberlist code_memberlist[] = { {"co_consts", T_OBJECT, OFF(co_consts), READONLY}, {"co_names", T_OBJECT, OFF(co_names), READONLY}, {"co_filename", T_OBJECT, OFF(co_filename), READONLY}, + {"co_name", T_OBJECT, OFF(co_name), READONLY}, {NULL} /* Sentinel */ }; @@ -69,6 +70,7 @@ code_dealloc(co) XDECREF(co->co_consts); XDECREF(co->co_names); XDECREF(co->co_filename); + XDECREF(co->co_name); DEL(co); } @@ -80,12 +82,15 @@ code_repr(co) int lineno = -1; char *p = GETSTRINGVALUE(co->co_code); char *filename = "???"; + char *name = "???"; if (*p == SET_LINENO) lineno = (p[1] & 0xff) | ((p[2] & 0xff) << 8); if (co->co_filename && is_stringobject(co->co_filename)) filename = getstringvalue(co->co_filename); - sprintf(buf, "", - (long)co, filename, lineno); + if (co->co_name && is_stringobject(co->co_name)) + name = getstringvalue(co->co_name); + sprintf(buf, "", + name, (long)co, filename, lineno); return newstringobject(buf); } @@ -107,18 +112,20 @@ typeobject Codetype = { }; codeobject * -newcodeobject(code, consts, names, filename) +newcodeobject(code, consts, names, filename, name) object *code; object *consts; object *names; object *filename; + object *name; { codeobject *co; int i; /* Check argument types */ if (code == NULL || !is_stringobject(code) || consts == NULL || !is_listobject(consts) || - names == NULL || !is_listobject(names)) { + names == NULL || !is_listobject(names) || + name == NULL || !is_stringobject(name)) { err_badcall(); return NULL; } @@ -140,6 +147,8 @@ newcodeobject(code, consts, names, filename) co->co_names = names; INCREF(filename); co->co_filename = filename; + INCREF(name); + co->co_name = name; } return co; } @@ -162,6 +171,7 @@ struct compiling { int c_block[MAXBLOCKS]; /* stack of block types */ int c_nblocks; /* current block stack level */ char *c_filename; /* filename of current node */ + char *c_name; /* name of object (e.g. function) */ }; @@ -232,6 +242,7 @@ com_init(c, filename) c->c_begin = 0; c->c_nblocks = 0; c->c_filename = filename; + c->c_name = "?"; return 1; fail_0: @@ -2020,6 +2031,8 @@ compile_funcdef(c, n) { node *ch; REQ(n, funcdef); /* funcdef: 'def' NAME parameters ':' suite */ + c->c_name = STR(CHILD(n, 1)); + com_addoparg(c, RESERVE_FAST, 0); /* Patched up later */ ch = CHILD(n, 2); /* parameters: '(' [varargslist] ')' */ ch = CHILD(ch, 1); /* ')' | varargslist */ if (TYPE(ch) == RPAR) @@ -2089,6 +2102,8 @@ compile_node(c, n) /* Optimization for local and global variables. + XXX Need to update this text for LOAD_FAST stuff... + Attempt to replace all LOAD_NAME instructions that refer to a local variable with LOAD_LOCAL instructions, and all that refer to a global variable with LOAD_GLOBAL instructions. @@ -2187,17 +2202,21 @@ compile(n, filename) { struct compiling sc; codeobject *co; - object *v; if (!com_init(&sc, filename)) return NULL; compile_node(&sc, n); com_done(&sc); - if (sc.c_errors == 0 && (v = newstringobject(filename)) != NULL) { - co = newcodeobject(sc.c_code, sc.c_consts, sc.c_names, v); - DECREF(v); + co = NULL; + if (sc.c_errors == 0) { + object *v, *w; + v = newstringobject(sc.c_filename); + w = newstringobject(sc.c_name); + if (v != NULL && w != NULL) + co = newcodeobject(sc.c_code, sc.c_consts, + sc.c_names, v, w); + XDECREF(v); + XDECREF(w); } - else - co = NULL; com_free(&sc); if (co != NULL && filename[0] != '<') optimizer(co); diff --git a/Python/fmod.c b/Python/fmod.c index 607f6a5f823..8301b944f05 100644 --- a/Python/fmod.c +++ b/Python/fmod.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Python/getcwd.c b/Python/getcwd.c index 96c2291c8af..675c4a6b273 100644 --- a/Python/getcwd.c +++ b/Python/getcwd.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Python/import.c b/Python/import.c index da9422b27d3..4b7ee1372d3 100644 --- a/Python/import.c +++ b/Python/import.c @@ -52,9 +52,9 @@ extern int verbose; /* Defined in pythonmain.c */ extern char *argv0; #endif -/* Magic word to reject pre-0.9.4 .pyc files */ +/* Magic word to reject pre-0.9.9 .pyc files */ -#define MAGIC 0x949494L +#define MAGIC 0x99BE2AL static object *modules; diff --git a/Python/marshal.c b/Python/marshal.c index 268db006918..65f7f2d47fc 100644 --- a/Python/marshal.c +++ b/Python/marshal.c @@ -195,6 +195,7 @@ w_object(v, p) w_object(co->co_consts, p); w_object(co->co_names, p); w_object(co->co_filename, p); + w_object(co->co_name, p); } else { w_byte(TYPE_UNKNOWN, p); @@ -384,9 +385,10 @@ r_object(p) object *consts = r_object(p); object *names = r_object(p); object *filename = r_object(p); + object *name = r_object(p); if (!err_occurred()) { v = (object *) newcodeobject(code, - consts, names, filename); + consts, names, filename, name); } else v = NULL; diff --git a/Python/pythonmain.c b/Python/pythonmain.c index 1c6469231d0..171861127f2 100644 --- a/Python/pythonmain.c +++ b/Python/pythonmain.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 1bcc083b61a..e59458e5877 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Python/strerror.c b/Python/strerror.c index ce9bd980901..a2f3acf768d 100644 --- a/Python/strerror.c +++ b/Python/strerror.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Python/structmember.c b/Python/structmember.c index e2658a6fbc0..6b29c30e7d4 100644 --- a/Python/structmember.c +++ b/Python/structmember.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved diff --git a/Python/traceback.c b/Python/traceback.c index 3c246b5c736..6ed19178efc 100644 --- a/Python/traceback.c +++ b/Python/traceback.c @@ -1,6 +1,6 @@ /*********************************************************** -Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The -Netherlands. +Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Amsterdam, The Netherlands. All Rights Reserved