From python-dev@python.org Mon May 1 17:17:27 2000 From: python-dev@python.org (Barry A. Warsaw) Date: Mon, 1 May 2000 12:17:27 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Modules posixmodule.c,2.132,2.133 Message-ID: <20000501161727.53F3E6616D@anthem.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Modules In directory anthem:/home/bwarsaw/projects/python/Modules Modified Files: posixmodule.c Log Message: posix_utime(): Allow the second argument to be None, which invokes the utime(path, NULL) call, setting the atime and mtime of the file to the current time. The previous signature utime(path, (atime, mtime)) is of course still allowed. Index: posixmodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.132 retrieving revision 2.133 diff -C2 -r2.132 -r2.133 *** posixmodule.c 2000/04/26 20:34:28 2.132 --- posixmodule.c 2000/05/01 16:17:24 2.133 *************** *** 1251,1255 **** static char posix_utime__doc__[] = "utime(path, (atime, utime)) -> None\n\ ! Set the access and modified time of the file to the given values."; static PyObject * --- 1251,1257 ---- static char posix_utime__doc__[] = "utime(path, (atime, utime)) -> None\n\ ! utime(path, None) -> None\n\ ! Set the access and modified time of the file to the given values. If the\n\ ! second form is used, set the access and modified times to the current time."; static PyObject * *************** *** 1261,1264 **** --- 1263,1267 ---- long atime, mtime; int res; + PyObject* arg; /* XXX should define struct utimbuf instead, above */ *************** *** 1275,1285 **** #endif /* HAVE_UTIME_H */ ! if (!PyArg_ParseTuple(args, "s(ll):utime", &path, &atime, &mtime)) return NULL; ! ATIME = atime; ! MTIME = mtime; ! Py_BEGIN_ALLOW_THREADS ! res = utime(path, UTIME_ARG); ! Py_END_ALLOW_THREADS if (res < 0) return posix_error_with_filename(path); --- 1278,1301 ---- #endif /* HAVE_UTIME_H */ ! if (!PyArg_ParseTuple(args, "sO:utime", &path, &arg)) return NULL; ! if (arg == Py_None) { ! /* optional time values not given */ ! Py_BEGIN_ALLOW_THREADS ! res = utime(path, NULL); ! Py_END_ALLOW_THREADS ! } ! else if (!PyArg_Parse(arg, "(ll)", &atime, &mtime)) { ! PyErr_SetString(PyExc_TypeError, ! "Second argument must be a 2-tuple of numbers."); ! return NULL; ! } ! else { ! ATIME = atime; ! MTIME = mtime; ! Py_BEGIN_ALLOW_THREADS ! res = utime(path, UTIME_ARG); ! Py_END_ALLOW_THREADS ! } if (res < 0) return posix_error_with_filename(path); From python-dev@python.org Mon May 1 17:17:35 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 1 May 2000 12:17:35 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Lib codecs.py,1.8,1.9 Message-ID: <200005011617.MAA20387@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Lib In directory eric:/projects/python/develop/guido/src/Lib Modified Files: codecs.py Log Message: Marc-Andre Lemburg: The two methods .readline() and .readlines() in StreamReaderWriter didn't define the self argument. Found by Tom Emerson. Index: codecs.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/codecs.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** codecs.py 2000/04/13 14:11:21 1.8 --- codecs.py 2000/05/01 16:17:32 1.9 *************** *** 325,333 **** return self.reader.read(size) ! def readline(size=None): return self.reader.readline(size) ! def readlines(sizehint=None): return self.reader.readlines(sizehint) --- 325,333 ---- return self.reader.read(size) ! def readline(self, size=None): return self.reader.readline(size) ! def readlines(self, sizehint=None): return self.reader.readlines(sizehint) From python-dev@python.org Mon May 1 17:18:25 2000 From: python-dev@python.org (Barry A. Warsaw) Date: Mon, 1 May 2000 12:18:25 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libos.tex,1.38,1.39 Message-ID: <20000501161825.9F3AE6616D@anthem.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/lib In directory anthem:/home/bwarsaw/projects/python/Doc/lib Modified Files: libos.tex Log Message: Document the new additional signature for utime(). In addition to the previous functionality utime(path, (atime, mtime)), now allowed is utime(path, None) which sets the file's times to the current time. Index: libos.tex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -r1.38 -r1.39 *** libos.tex 2000/04/03 20:13:53 1.38 --- libos.tex 2000/05/01 16:18:22 1.39 *************** *** 703,709 **** \end{funcdesc} ! \begin{funcdesc}{utime}{path, (atime, mtime)} ! Set the access and modified time of the file to the given values. ! (The second argument is a tuple of two items.) Availability: Macintosh, \UNIX{}, Windows. \end{funcdesc} --- 703,712 ---- \end{funcdesc} ! \begin{funcdesc}{utime}{path, times} ! Set the access and modified times of the file specified by \var{path}. ! If \var{times} is \code{None}, then the file's access and modified ! times are set to the current time. Otherwise, \var{times} must be a ! 2-tuple of numbers, of the form \var{(atime, mtime)} which is used to ! set the access and modified times, respectively. Availability: Macintosh, \UNIX{}, Windows. \end{funcdesc} From python-dev@python.org Mon May 1 18:37:00 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 1 May 2000 13:37:00 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Python import.c,2.131,2.132 Message-ID: <200005011737.NAA20699@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Python In directory eric:/projects/python/develop/guido/src/Python Modified Files: import.c Log Message: Robin Becker: The following patch seems to fix a module case bug in 1.6a2 caused by wrong return values in routine allcaps83. [GvR: I also changed the case for end-s>8 to return 0.] Index: import.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Python/import.c,v retrieving revision 2.131 retrieving revision 2.132 diff -C2 -r2.131 -r2.132 *** import.c 2000/04/28 19:03:54 2.131 --- import.c 2000/05/01 17:36:58 2.132 *************** *** 1036,1048 **** if (dot != NULL) { if (dot-s > 8) ! return 1; /* More than 8 before '.' */ if (end-dot > 4) ! return 1; /* More than 3 after '.' */ end = strchr(dot+1, '.'); if (end != NULL) ! return 1; /* More than one dot */ } else if (end-s > 8) ! return 1; /* More than 8 and no dot */ while ((c = *s++)) { if (islower(c)) --- 1036,1048 ---- if (dot != NULL) { if (dot-s > 8) ! return 0; /* More than 8 before '.' */ if (end-dot > 4) ! return 0; /* More than 3 after '.' */ end = strchr(dot+1, '.'); if (end != NULL) ! return 0; /* More than one dot */ } else if (end-s > 8) ! return 0; /* More than 8 and no dot */ while ((c = *s++)) { if (islower(c)) From python-dev@python.org Mon May 1 18:51:44 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 1 May 2000 13:51:44 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Include pydebug.h,2.10,2.11 Message-ID: <200005011751.NAA20832@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Include In directory eric:/projects/python/develop/guido/src/Include Modified Files: pydebug.h Log Message: Marc-Andre Lemburg: Added Py_UnicodeFlag for use by the -U command line option. Index: pydebug.h =================================================================== RCS file: /projects/cvsroot/python/dist/src/Include/pydebug.h,v retrieving revision 2.10 retrieving revision 2.11 diff -C2 -r2.10 -r2.11 *** pydebug.h 1998/12/04 18:48:15 2.10 --- pydebug.h 2000/05/01 17:51:41 2.11 *************** *** 44,47 **** --- 44,48 ---- extern DL_IMPORT(int) Py_FrozenFlag; extern DL_IMPORT(int) Py_TabcheckFlag; + extern DL_IMPORT(int) Py_UnicodeFlag; DL_IMPORT(void) Py_FatalError Py_PROTO((char *)); From python-dev@python.org Mon May 1 18:54:35 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 1 May 2000 13:54:35 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Modules main.c,1.36,1.37 Message-ID: <200005011754.NAA20879@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Modules In directory eric:/projects/python/develop/guido/src/Modules Modified Files: main.c Log Message: Marc-Andre Lemburg: Added -U command line option. With the option enabled the Python compiler interprets all "..." strings as u"..." (same with r"..." and ur"..."). Index: main.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/main.c,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -r1.36 -r1.37 *** main.c 1999/04/19 17:54:19 1.36 --- main.c 2000/05/01 17:54:33 1.37 *************** *** 76,79 **** --- 76,80 ---- static char *usage_mid = "\ -u : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x)\n\ + -U : Unicode literals: treats '...' literals like u'...'\n\ -v : verbose (trace import statements) (also PYTHONVERBOSE=x)\n\ -x : skip first line of source, allowing use of non-Unix forms of #!cmd\n\ *************** *** 120,124 **** unbuffered = 1; ! while ((c = getopt(argc, argv, "c:diOStuvxX")) != EOF) { if (c == 'c') { /* -c is the last option; following arguments --- 121,125 ---- unbuffered = 1; ! while ((c = getopt(argc, argv, "c:diOStuUvxX")) != EOF) { if (c == 'c') { /* -c is the last option; following arguments *************** *** 171,174 **** --- 172,179 ---- case 'X': Py_UseClassExceptionsFlag = 0; + break; + + case 'U': + Py_UnicodeFlag++; break; From python-dev@python.org Mon May 1 18:54:58 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 1 May 2000 13:54:58 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Python compile.c,2.106,2.107 Message-ID: <200005011754.NAA20901@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Python In directory eric:/projects/python/develop/guido/src/Python Modified Files: compile.c Log Message: Marc-Andre Lemburg: Support for the new -U command line option option: with the option enabled the Python compiler interprets all "..." strings as u"..." (same with r"..." and ur"..."). Index: compile.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Python/compile.c,v retrieving revision 2.106 retrieving revision 2.107 diff -C2 -r2.106 -r2.107 *** compile.c 2000/04/28 16:42:25 2.106 --- compile.c 2000/05/01 17:54:56 2.107 *************** *** 921,925 **** } } ! if (unicode) { if (rawmode) return PyUnicode_DecodeRawUnicodeEscape( --- 921,925 ---- } } ! if (unicode || Py_UnicodeFlag) { if (rawmode) return PyUnicode_DecodeRawUnicodeEscape( From python-dev@python.org Mon May 1 18:55:17 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 1 May 2000 13:55:17 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Python pythonrun.c,2.93,2.94 Message-ID: <200005011755.NAA20923@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Python In directory eric:/projects/python/develop/guido/src/Python Modified Files: pythonrun.c Log Message: Marc-Andre Lemburg: Added Py_UnicodeFlag for use by the -U command line option. Index: pythonrun.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Python/pythonrun.c,v retrieving revision 2.93 retrieving revision 2.94 diff -C2 -r2.93 -r2.94 *** pythonrun.c 2000/04/27 23:44:15 2.93 --- pythonrun.c 2000/05/01 17:55:15 2.94 *************** *** 89,92 **** --- 89,93 ---- int Py_UseClassExceptionsFlag = 1; /* Needed by bltinmodule.c */ int Py_FrozenFlag; /* Needed by getpath.c */ + int Py_UnicodeFlag = 0; /* Needed by compile.c */ static int initialized = 0; From python-dev@python.org Mon May 1 21:08:49 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 1 May 2000 16:08:49 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Lib shlex.py,1.5,1.6 Message-ID: <200005012008.QAA22121@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Lib In directory eric:/projects/python/develop/guido/src/Lib Modified Files: shlex.py Log Message: Eric Raymond: Added and documented the capability for shlex to handle lexical-level inclusion and a stack of input sources. Also, the input stream member is now documented, and the constructor takes an optional source-filename. The class provides facilities to generate error messages that track file and line number. [GvR: I changed the __main__ code so that it actually stops at EOF, as Eric surely intended -- however it returned '' instead of the None he was testing for.] Index: shlex.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/shlex.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** shlex.py 2000/02/04 15:28:40 1.5 --- shlex.py 2000/05/01 20:08:46 1.6 *************** *** 2,5 **** --- 2,6 ---- # Module and documentation by Eric S. Raymond, 21 Dec 1998 + # Input stacking and error message cleanup added by ESR, March 2000 import sys *************** *** 7,15 **** class shlex: "A lexical analyzer class for simple shell-like syntaxes." ! def __init__(self, instream=None): if instream: self.instream = instream else: self.instream = sys.stdin self.commenters = '#' self.wordchars = 'abcdfeghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_' --- 8,18 ---- class shlex: "A lexical analyzer class for simple shell-like syntaxes." ! def __init__(self, instream=None, infile=None): if instream: self.instream = instream + self.infile = infile else: self.instream = sys.stdin + self.infile = None self.commenters = '#' self.wordchars = 'abcdfeghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_' *************** *** 21,39 **** self.debug = 0 self.token = '' def push_token(self, tok): "Push a token onto the stack popped by the get_token method" ! if (self.debug >= 1): ! print "Pushing " + tok self.pushback = [tok] + self.pushback; def get_token(self): ! "Get a token from the input stream (or from stack if it's monempty)" if self.pushback: tok = self.pushback[0] self.pushback = self.pushback[1:] ! if (self.debug >= 1): ! print "Popping " + tok return tok tok = '' while 1: --- 24,80 ---- self.debug = 0 self.token = '' + self.filestack = [] + self.source = None + if self.debug: + print 'shlex: reading from %s, line %d' % (self.instream,self.lineno) def push_token(self, tok): "Push a token onto the stack popped by the get_token method" ! if self.debug >= 1: ! print "shlex: pushing token " + `tok` self.pushback = [tok] + self.pushback; def get_token(self): ! "Get a token from the input stream (or from stack if it's nonempty)" if self.pushback: tok = self.pushback[0] self.pushback = self.pushback[1:] ! if self.debug >= 1: ! print "shlex: popping token " + `tok` return tok + # No pushback. Get a token. + raw = self.read_token() + # Handle inclusions + while raw == self.source: + (newfile, newstream) = self.sourcehook(self.read_token()) + self.filestack = [(self.infile,self.instream,self.lineno)] + self.filestack + self.infile = newfile + self.instream = newstream + self.lineno = 1 + if self.debug: + print 'shlex: pushing to file %s' % (self.infile,) + raw = self.get_token() + # Maybe we got EOF instead? + while raw == "": + if len(self.filestack) == 0: + return "" + else: + self.instream.close() + (self.infile, self.instream, self.lineno) = self.filestack[0] + self.filestack = self.filestack[1:] + if self.debug: + print 'shlex: popping to %s, line %d' % (self.instream, self.lineno) + self.state = ' ' + raw = self.get_token() + # Neither inclusion nor EOF + if self.debug >= 1: + if raw: + print "shlex: token=" + `raw` + else: + print "shlex: token=EOF" + return raw + + def read_token(self): + "Read a token from the input stream (no pushback or inclusions)" tok = '' while 1: *************** *** 42,48 **** self.lineno = self.lineno + 1 if self.debug >= 3: ! print "In state " + repr(self.state) + " I see character: " + repr(nextchar) if self.state == None: ! return '' elif self.state == ' ': if not nextchar: --- 83,90 ---- self.lineno = self.lineno + 1 if self.debug >= 3: ! print "shlex: in state " + repr(self.state) + " I see character: " + repr(nextchar) if self.state == None: ! self.token = ''; # past end of file ! break elif self.state == ' ': if not nextchar: *************** *** 51,55 **** elif nextchar in self.whitespace: if self.debug >= 2: ! print "I see whitespace in whitespace state" if self.token: break # emit current token --- 93,97 ---- elif nextchar in self.whitespace: if self.debug >= 2: ! print "shlex: I see whitespace in whitespace state" if self.token: break # emit current token *************** *** 82,86 **** elif nextchar in self.whitespace: if self.debug >= 2: ! print "I see whitespace in word state" self.state = ' ' if self.token: --- 124,128 ---- elif nextchar in self.whitespace: if self.debug >= 2: ! print "shlex: I see whitespace in word state" self.state = ' ' if self.token: *************** *** 96,100 **** self.pushback = [nextchar] + self.pushback if self.debug >= 2: ! print "I see punctuation in word state" self.state = ' ' if self.token: --- 138,142 ---- self.pushback = [nextchar] + self.pushback if self.debug >= 2: ! print "shlex: I see punctuation in word state" self.state = ' ' if self.token: *************** *** 102,112 **** else: continue - result = self.token self.token = '' ! if self.debug >= 1: ! print "Token: " + result return result if __name__ == '__main__': --- 144,162 ---- else: continue result = self.token self.token = '' ! if self.debug > 1: ! if result: ! print "shlex: raw token=" + `result` ! else: ! print "shlex: raw token=EOF" return result + def sourcehook(self, newfile): + "Hook called on a filename to be sourced." + if newfile[0] == '"': + newfile = newfile[1:-1] + return (newfile, open(newfile, "r")) + if __name__ == '__main__': *************** *** 114,120 **** while 1: tt = lexer.get_token() ! if tt != None: ! print "Token: " + repr(tt) ! else: break --- 164,169 ---- while 1: tt = lexer.get_token() ! print "Token: " + repr(tt) ! if not tt: break From python-dev@python.org Mon May 1 21:14:15 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 1 May 2000 16:14:15 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Lib shlex.py,1.6,1.7 Message-ID: <200005012014.QAA22178@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Lib In directory eric:/projects/python/develop/guido/src/Lib Modified Files: shlex.py Log Message: Eric Raymond: Add a convenience function to generate C-compiler style error leaders. Index: shlex.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/shlex.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** shlex.py 2000/05/01 20:08:46 1.6 --- shlex.py 2000/05/01 20:14:12 1.7 *************** *** 159,162 **** --- 159,170 ---- return (newfile, open(newfile, "r")) + def error_leader(self, infile=None, lineno=None): + "Emit a C-compiler-like, Emacs-friendly error-message leader." + if not infile: + infile = self.infile + if not lineno: + lineno = self.lineno + return "\"%s\", line %d: " % (infile, lineno) + if __name__ == '__main__': From python-dev@python.org Mon May 1 21:19:11 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 1 May 2000 16:19:11 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Python import.c,2.132,2.133 Message-ID: <200005012019.QAA22280@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Python In directory eric:/projects/python/develop/guido/src/Python Modified Files: import.c Log Message: Marc-Andre Lemburg: Changed all references to the MAGIC constant to use a global pyc_magic instead. This global is initially set to MAGIC, but can be changed by the _PyImport_Init() function to provide for special features implemented in the compiler which are settable using command line switches and affect the way PYC files are generated. Currently this change is only done for the -U flag. Index: import.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Python/import.c,v retrieving revision 2.132 retrieving revision 2.133 diff -C2 -r2.132 -r2.133 *** import.c 2000/05/01 17:36:58 2.132 --- import.c 2000/05/01 20:19:08 2.133 *************** *** 87,90 **** --- 87,95 ---- #define MAGIC (50428 | ((long)'\r'<<16) | ((long)'\n'<<24)) + /* Magic word as global; note that _PyImport_Init() can change the + value of this global to accomodate for alterations of how the + compiler works which are enabled by command line switches. */ + static long pyc_magic = MAGIC; + /* See _PyImport_FixupExtension() below */ static PyObject *extensions = NULL; *************** *** 136,139 **** --- 141,151 ---- } } + + if (Py_UnicodeFlag) { + /* Fix the pyc_magic so that byte compiled code created + using the all-Unicode method doesn't interfere with + code created in normal operation mode. */ + pyc_magic = MAGIC + 1; + } } *************** *** 367,371 **** PyImport_GetMagicNumber() { ! return MAGIC; } --- 379,383 ---- PyImport_GetMagicNumber() { ! return pyc_magic; } *************** *** 573,577 **** return NULL; magic = PyMarshal_ReadLongFromFile(fp); ! if (magic != MAGIC) { if (Py_VerboseFlag) PySys_WriteStderr("# %s has bad magic\n", cpathname); --- 585,589 ---- return NULL; magic = PyMarshal_ReadLongFromFile(fp); ! if (magic != pyc_magic) { if (Py_VerboseFlag) PySys_WriteStderr("# %s has bad magic\n", cpathname); *************** *** 628,632 **** magic = PyMarshal_ReadLongFromFile(fp); ! if (magic != MAGIC) { PyErr_Format(PyExc_ImportError, "Bad magic number in %.200s", cpathname); --- 640,644 ---- magic = PyMarshal_ReadLongFromFile(fp); ! if (magic != pyc_magic) { PyErr_Format(PyExc_ImportError, "Bad magic number in %.200s", cpathname); *************** *** 686,690 **** return; } ! PyMarshal_WriteLongToFile(MAGIC, fp); /* First write a 0 for mtime */ PyMarshal_WriteLongToFile(0L, fp); --- 698,702 ---- return; } ! PyMarshal_WriteLongToFile(pyc_magic, fp); /* First write a 0 for mtime */ PyMarshal_WriteLongToFile(0L, fp); *************** *** 1954,1961 **** if (!PyArg_ParseTuple(args, ":get_magic")) return NULL; ! buf[0] = (char) ((MAGIC >> 0) & 0xff); ! buf[1] = (char) ((MAGIC >> 8) & 0xff); ! buf[2] = (char) ((MAGIC >> 16) & 0xff); ! buf[3] = (char) ((MAGIC >> 24) & 0xff); return PyString_FromStringAndSize(buf, 4); --- 1966,1973 ---- if (!PyArg_ParseTuple(args, ":get_magic")) return NULL; ! buf[0] = (char) ((pyc_magic >> 0) & 0xff); ! buf[1] = (char) ((pyc_magic >> 8) & 0xff); ! buf[2] = (char) ((pyc_magic >> 16) & 0xff); ! buf[3] = (char) ((pyc_magic >> 24) & 0xff); return PyString_FromStringAndSize(buf, 4); From python-dev@python.org Mon May 1 21:14:50 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 1 May 2000 16:14:50 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libshlex.tex,1.6,1.7 Message-ID: <200005012014.QAA22197@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/lib In directory eric:/projects/python/develop/guido/src/Doc/lib Modified Files: libshlex.tex Log Message: Eric Raymond: (1) Added and documented the capability for shlex to handle lexical-level inclusion and a stack of input sources. Also, the input stream member is now documented, and the constructor takes an optional source-filename. The class provides facilities to generate error messages that track file and line number. (2) Add a convenience function to generate C-compiler style error leaders. Index: libshlex.tex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/lib/libshlex.tex,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** libshlex.tex 2000/04/03 20:13:54 1.6 --- libshlex.tex 2000/05/01 20:14:47 1.7 *************** *** 14,23 **** Python applications. ! \begin{classdesc}{shlex}{\optional{stream}} A \class{shlex} instance or subclass instance is a lexical analyzer object. The initialization argument, if present, specifies where to read characters from. It must be a file- or stream-like object with \method{read()} and \method{readline()} methods. If no argument is given, ! input will be taken from \code{sys.stdin}. \end{classdesc} --- 14,26 ---- Python applications. ! \begin{classdesc}{shlex}{\optional{stream}, \optional{file}} A \class{shlex} instance or subclass instance is a lexical analyzer object. The initialization argument, if present, specifies where to read characters from. It must be a file- or stream-like object with \method{read()} and \method{readline()} methods. If no argument is given, ! input will be taken from \code{sys.stdin}. The second optional ! argument is a filename string, which sets the initial value of the ! \member{infile} member. If the stream argument is omitted or ! equal to \code{sys.stdin}, this second argument defauilts to ``stdin''. \end{classdesc} *************** *** 44,47 **** --- 47,82 ---- \end{methoddesc} + \begin{methoddesc}{read_token}{} + Read a raw token. Ignore the pushback stack, and do not interpret source + requests. (This is not ordinarily a useful entry point, and is + documented here only for the sake of completeness.) + \end{methoddesc} + + \begin{methoddesc}{openhook}{filename} + When shlex detects a source request (see \member{source} below) + this method is given the following token as argument, and expected to + return a tuple consisting of a filename and an opened stream object. + + Normally, this method just strips any quotes off the argument and + treats it as a filename, calling \code{open()} on it. It is exposed so that + you can use it to implement directory search paths, addition of + file extensions, and other namespace hacks. + + There is no corresponding `close' hook, but a shlex instance will call + the \code{close()} method of the sourced input stream when it returns EOF. + \end{methoddesc} + + \begin{methoddesc}{error_leader}{\optional{file}, \optional{line}} + This method generates an error message leader in the format of a + Unix C compiler error label; the format is '"\%s", line \%d: ', + where the \%s is replaced with the name of the current source file and + the \%d with the current input line number (the optional arguments + can be used to override these). + + This convenience is provided to encourage shlex users to generate + error messages in the standard, parseable format understood by Emacs + and other Unix tools. + \end{methoddesc} + Instances of \class{shlex} subclasses have some public instance variables which either control lexical analysis or can be used *************** *** 71,74 **** --- 106,136 ---- quote types protect each other as in the shell.) By default, includes \ASCII{} single and double quotes. + \end{memberdesc} + + \begin{memberdesc}{infile} + The name of the current input file, as initially set at class + instantiation time or stacked by later source requests. It may + be useful to examine this when constructing error messages. + \end{memberdesc} + + \begin{memberdesc}{instream} + The input stream from which this shlex instance is reading characters. + \end{memberdesc} + + \begin{memberdesc}{source} + This member is None by default. If you assign a string to it, that + string will be recognized as a lexical-level inclusion request similar + to the `source' keyword in various shells. That is, the immediately + following token will opened as a filename and input taken from that + stream until EOF, at which point the \code{close()} method of that + stream will be called and the input source will again become the + original input stream. Source requests may be stacked any number of + levels deep. + \end{memberdesc} + + \begin{memberdesc}{debug} + If this member is numeric and 1 or more, a shlex instance will print + verbose progress output on its behavior. If you need to use this, + you can read the module source code to learn the details. \end{memberdesc} From python-dev@python.org Mon May 1 22:27:23 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 1 May 2000 17:27:23 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.12,2.13 Message-ID: <200005012127.RAA23301@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Objects In directory eric:/projects/python/develop/guido/src/Objects Modified Files: unicodeobject.c Log Message: Marc-Andre Lemburg: Fixed \OOO interpretation for Unicode objects. \777 now correctly produces the Unicode character with ordinal 511. Index: unicodeobject.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.12 retrieving revision 2.13 diff -C2 -r2.12 -r2.13 *** unicodeobject.c 2000/04/27 20:13:50 2.12 --- unicodeobject.c 2000/05/01 21:27:20 2.13 *************** *** 1017,1027 **** case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': ! c = s[-1] - '0'; if ('0' <= *s && *s <= '7') { ! c = (c<<3) + *s++ - '0'; if ('0' <= *s && *s <= '7') ! c = (c<<3) + *s++ - '0'; } ! *p++ = c; break; --- 1017,1027 ---- case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': ! x = s[-1] - '0'; if ('0' <= *s && *s <= '7') { ! x = (x<<3) + *s++ - '0'; if ('0' <= *s && *s <= '7') ! x = (x<<3) + *s++ - '0'; } ! *p++ = x; break; From python-dev@python.org Tue May 2 13:44:24 2000 From: python-dev@python.org (Guido van Rossum) Date: Tue, 2 May 2000 08:44:24 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/PCbuild zlib.dsp,1.11,1.12 Message-ID: <200005021244.IAA24357@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/PCbuild In directory eric:/projects/python/develop/guido/src/PCbuild Modified Files: zlib.dsp Log Message: The debug settings for zlib contained a bogus reference to msvcrt in the /nodefaultlib: option. Index: zlib.dsp =================================================================== RCS file: /projects/cvsroot/python/dist/src/PCbuild/zlib.dsp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** zlib.dsp 2000/04/21 21:26:08 1.11 --- zlib.dsp 2000/05/02 12:44:22 1.12 *************** *** 83,87 **** LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept ! # ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\zlib113dll\static32\zlibstat.lib /nologo /base:"0x1e1B0000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc msvcrt" /out:"./zlib_d.pyd" /pdbtype:sept /export:initzlib # SUBTRACT LINK32 /pdb:none --- 83,87 ---- LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept ! # ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\zlib113dll\static32\zlibstat.lib /nologo /base:"0x1e1B0000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./zlib_d.pyd" /pdbtype:sept /export:initzlib # SUBTRACT LINK32 /pdb:none From python-dev@python.org Tue May 2 14:49:16 2000 From: python-dev@python.org (Guido van Rossum) Date: Tue, 2 May 2000 09:49:16 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Tools/freeze modulefinder.py,1.11,1.12 Message-ID: <200005021349.JAA24416@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Tools/freeze In directory eric:/projects/python/develop/guido/src/Tools/freeze Modified Files: modulefinder.py Log Message: Sjoerd Mullender: Bad % formatting. Index: modulefinder.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Tools/freeze/modulefinder.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** modulefinder.py 1999/11/02 15:46:44 1.11 --- modulefinder.py 2000/05/02 13:49:13 1.12 *************** *** 250,254 **** if fp.read(4) != imp.get_magic(): self.msgout(2, "raise ImportError: Bad magic number", pathname) ! raise ImportError, "Bad magic number in %s", pathname fp.read(4) co = marshal.load(fp) --- 250,254 ---- if fp.read(4) != imp.get_magic(): self.msgout(2, "raise ImportError: Bad magic number", pathname) ! raise ImportError, "Bad magic number in %s" % pathname fp.read(4) co = marshal.load(fp) From python-dev@python.org Tue May 2 15:32:13 2000 From: python-dev@python.org (Guido van Rossum) Date: Tue, 2 May 2000 10:32:13 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Lib telnetlib.py,1.7,1.8 Message-ID: <200005021432.KAA24625@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Lib In directory eric:/projects/python/develop/guido/src/Lib Modified Files: telnetlib.py Log Message: Caolan McNamara: telnetlib is unable to connect to a few telnet daemons because of improper IAC handling, heres an attached oneliner to reject WILL messages which will allow many more telnet daemons to work with it, namely FreeBSD. Index: telnetlib.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/telnetlib.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** telnetlib.py 1998/12/23 23:04:17 1.7 --- telnetlib.py 2000/05/02 14:32:11 1.8 *************** *** 330,333 **** --- 330,334 ---- self.msg('IAC %s %d', c == WILL and 'WILL' or 'WONT', ord(c)) + self.sock.send(IAC + DONT + opt) else: self.msg('IAC %s not recognized' % `c`) From python-dev@python.org Tue May 2 16:52:36 2000 From: python-dev@python.org (Guido van Rossum) Date: Tue, 2 May 2000 11:52:36 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.3,1.4 Message-ID: <200005021552.LAA25623@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Lib In directory eric:/projects/python/develop/guido/src/Lib Modified Files: sre.py Log Message: I know this is only a temporary stop-gap measure, but the match() and search() functions didn't even work because _fixflags() isn't idempotent. I'm adding another stop-gap measure so that you can at least use sre.search() and sre.match() with a zero flags arg. Index: sre.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/sre.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** sre.py 2000/04/10 17:10:48 1.3 --- sre.py 2000/05/02 15:52:33 1.4 *************** *** 2,6 **** # # Secret Labs' Regular Expression Engine ! # $Id: sre.py,v 1.3 2000/04/10 17:10:48 guido Exp $ # # re-compatible interface for the sre matching engine --- 2,6 ---- # # Secret Labs' Regular Expression Engine ! # $Id: sre.py,v 1.4 2000/05/02 15:52:33 guido Exp $ # # re-compatible interface for the sre matching engine *************** *** 32,36 **** def search(pattern, string, flags=0): - assert flags == 0 return compile(pattern, _fixflags(flags)).search(string) --- 32,35 ---- *************** *** 42,46 **** def _fixflags(flags): # convert flag bitmask to sequence ! assert flags == 0 return () --- 41,45 ---- def _fixflags(flags): # convert flag bitmask to sequence ! assert not flags return () From python-dev@python.org Tue May 2 18:28:39 2000 From: python-dev@python.org (Fred Drake) Date: Tue, 2 May 2000 13:28:39 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/texinputs python.sty,1.58,1.59 Message-ID: <200005021728.NAA04148@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/texinputs In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/texinputs Modified Files: python.sty Log Message: \versionchanged: Added optional parameter for explanation of change. Index: python.sty =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/texinputs/python.sty,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -r1.58 -r1.59 *** python.sty 2000/04/26 18:13:58 1.58 --- python.sty 2000/05/02 17:28:36 1.59 *************** *** 839,847 **** % Example: % \versionadded{1.5.2} % \newcommand{\versionadded}[1]{% { New in version #1. }} ! \newcommand{\versionchanged}[1]{% ! { Changed in version #1. }} --- 839,853 ---- % Example: % \versionadded{1.5.2} + % \versionchanged[short explanation]{1.6} % \newcommand{\versionadded}[1]{% { New in version #1. }} ! \newcommand{\versionchanged}[2][\py@badkey]{% ! \ifx#1\@undefined% ! { Changed in version #2. }% ! \else% ! { Changed in version #2:\ #1. }% ! \fi% ! } From python-dev@python.org Tue May 2 18:29:38 2000 From: python-dev@python.org (Fred Drake) Date: Tue, 2 May 2000 13:29:38 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libos.tex,1.39,1.40 Message-ID: <200005021729.NAA04235@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/lib In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/lib Modified Files: libos.tex Log Message: Use \versionchanged to indicate when the second parameter to utime() was allowed to be None. Index: libos.tex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -r1.39 -r1.40 *** libos.tex 2000/05/01 16:18:22 1.39 --- libos.tex 2000/05/02 17:29:35 1.40 *************** *** 707,712 **** If \var{times} is \code{None}, then the file's access and modified times are set to the current time. Otherwise, \var{times} must be a ! 2-tuple of numbers, of the form \var{(atime, mtime)} which is used to ! set the access and modified times, respectively. Availability: Macintosh, \UNIX{}, Windows. \end{funcdesc} --- 707,713 ---- If \var{times} is \code{None}, then the file's access and modified times are set to the current time. Otherwise, \var{times} must be a ! 2-tuple of numbers, of the form \code{(\var{atime}, \var{mtime})} ! which is used to set the access and modified times, respectively. ! \versionchanged[added support for \code{None} for \var{times}]{1.6} Availability: Macintosh, \UNIX{}, Windows. \end{funcdesc} From python-dev@python.org Tue May 2 18:37:45 2000 From: python-dev@python.org (Fred Drake) Date: Tue, 2 May 2000 13:37:45 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/perl python.perl,1.73,1.74 Message-ID: <200005021737.NAA04360@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/perl In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/perl Modified Files: python.perl Log Message: do_cmd_versionchanged(): Added support for optional parameter explaining the change that was made in the specified version. Index: python.perl =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/perl/python.perl,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -r1.73 -r1.74 *** python.perl 2000/04/26 18:05:24 1.73 --- python.perl 2000/05/02 17:37:42 1.74 *************** *** 282,287 **** # one parameter: \versionchanged{version} local($_) = @_; my $release = next_argument(); ! return "\nChanged in version $release.\n" . $_; } --- 282,292 ---- # one parameter: \versionchanged{version} local($_) = @_; + my $explanation = next_optional_argument(); my $release = next_argument(); ! my $text = "\nChanged in version $release.\n"; ! if ($release) { ! $text = "\nChanged in version $release:\n$explanation.\n"; ! } ! return $text . $_; } From python-dev@python.org Tue May 2 18:43:46 2000 From: python-dev@python.org (Fred Drake) Date: Tue, 2 May 2000 13:43:46 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/doc doc.tex,1.19,1.20 Message-ID: <200005021743.NAA04429@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/doc In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/doc Modified Files: doc.tex Log Message: Added descriptions of \versionadded and \versionchanged. Index: doc.tex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/doc/doc.tex,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** doc.tex 2000/04/11 19:08:30 1.19 --- doc.tex 2000/05/02 17:43:44 1.20 *************** *** 572,575 **** --- 572,595 ---- \end{macrodesc} + \begin{macrodesc}{versionadded}{\p{version}} + The version of Python which added the described feature to the + library or C API. This is typically added to the end of the + first paragraph of the description before any availability + notes. The location should be selected so the explanation makes + sense and may vary as needed. + \end{macrodesc} + + \begin{macrodesc}{versionchanged}{\op{explanation}\p{version}} + The version of Python in which the named feature was changed in + some way (new parameters, changed side effects, etc.). + \var{explanation} should be a \emph{brief} explanation of the + change consisting of a non-capitalized sentence fragment; a + period will be appended by the formatting process. + This is typically added to the end of the first paragraph of the + description before any availability notes and after + \macro{versionadded}. The location should be selected so the + explanation makes sense and may vary as needed. + \end{macrodesc} + \subsection{Module-specific Markup} From python-dev@python.org Tue May 2 19:31:07 2000 From: python-dev@python.org (Barry A. Warsaw) Date: Tue, 2 May 2000 14:31:07 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src .cvsignore,NONE,2.1 Message-ID: <20000502183107.B401F66375@anthem.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src In directory anthem:/home/bwarsaw/projects/python Added Files: .cvsignore Log Message: Ignore a bunch of generated files. From python-dev@python.org Tue May 2 19:32:36 2000 From: python-dev@python.org (Barry A. Warsaw) Date: Tue, 2 May 2000 14:32:36 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Modules .cvsignore,NONE,2.1 Message-ID: <20000502183236.EC2AF66375@anthem.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Modules In directory anthem:/home/bwarsaw/projects/python/Modules Added Files: .cvsignore Log Message: Ignore a bunch of generated files. From python-dev@python.org Tue May 2 19:33:11 2000 From: python-dev@python.org (Barry A. Warsaw) Date: Tue, 2 May 2000 14:33:11 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Objects .cvsignore,NONE,2.1 Message-ID: <20000502183311.1188766375@anthem.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Objects In directory anthem:/home/bwarsaw/projects/python/Objects Added Files: .cvsignore Log Message: Ignore a bunch of generated files. From python-dev@python.org Tue May 2 19:34:04 2000 From: python-dev@python.org (Barry A. Warsaw) Date: Tue, 2 May 2000 14:34:04 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Parser .cvsignore,NONE,2.1 Message-ID: <20000502183404.A9C4566375@anthem.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Parser In directory anthem:/home/bwarsaw/projects/python/Parser Added Files: .cvsignore Log Message: Ignore a bunch of generated files. From python-dev@python.org Tue May 2 19:34:32 2000 From: python-dev@python.org (Barry A. Warsaw) Date: Tue, 2 May 2000 14:34:32 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Python .cvsignore,NONE,2.1 Message-ID: <20000502183432.CC5A266375@anthem.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Python In directory anthem:/home/bwarsaw/projects/python/Python Added Files: .cvsignore Log Message: Ignore a bunch of generated files. From python-dev@python.org Tue May 2 20:09:43 2000 From: python-dev@python.org (Guido van Rossum) Date: Tue, 2 May 2000 15:09:43 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Include rename2.h,2.22,NONE Message-ID: <200005021909.PAA26194@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Include In directory eric:/projects/python/develop/guido/src/Include Removed Files: rename2.h Log Message: At last, this backward compatibility file bites the dust. If you still haven't updated your extension since the Grand Renaming, you don't deserve Python 1.6. :-) From python-dev@python.org Tue May 2 20:19:02 2000 From: python-dev@python.org (Barry A. Warsaw) Date: Tue, 2 May 2000 15:19:02 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Python pythonrun.c,2.94,2.95 Message-ID: <20000502191902.CA7786636B@anthem.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Python In directory anthem:/home/bwarsaw/projects/python/Python Modified Files: pythonrun.c Log Message: Py_UseClassExceptionsFlag is deprecated. We keep the C variable for C API consistency, but nothing sets it or checks it now. Index: pythonrun.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Python/pythonrun.c,v retrieving revision 2.94 retrieving revision 2.95 diff -C2 -r2.94 -r2.95 *** pythonrun.c 2000/05/01 17:55:15 2.94 --- pythonrun.c 2000/05/02 19:18:59 2.95 *************** *** 87,91 **** int Py_InteractiveFlag; /* Needed by Py_FdIsInteractive() below */ int Py_NoSiteFlag; /* Suppress 'import site' */ ! int Py_UseClassExceptionsFlag = 1; /* Needed by bltinmodule.c */ int Py_FrozenFlag; /* Needed by getpath.c */ int Py_UnicodeFlag = 0; /* Needed by compile.c */ --- 87,91 ---- int Py_InteractiveFlag; /* Needed by Py_FdIsInteractive() below */ int Py_NoSiteFlag; /* Suppress 'import site' */ ! int Py_UseClassExceptionsFlag = 1; /* Needed by bltinmodule.c: deprecated */ int Py_FrozenFlag; /* Needed by getpath.c */ int Py_UnicodeFlag = 0; /* Needed by compile.c */ From python-dev@python.org Tue May 2 20:20:28 2000 From: python-dev@python.org (Barry A. Warsaw) Date: Tue, 2 May 2000 15:20:28 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Modules main.c,1.37,1.38 Message-ID: <20000502192028.D30216636B@anthem.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Modules In directory anthem:/home/bwarsaw/projects/python/Modules Modified Files: main.c Log Message: usage_mid: Remove the description of the -X flag; it's gone now. Py_Main(): Remove the 'X' case. Index: main.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/main.c,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -r1.37 -r1.38 *** main.c 2000/05/01 17:54:33 1.37 --- main.c 2000/05/02 19:20:26 1.38 *************** *** 79,83 **** -v : verbose (trace import statements) (also PYTHONVERBOSE=x)\n\ -x : skip first line of source, allowing use of non-Unix forms of #!cmd\n\ - -X : disable class based built-in exceptions\n\ -c cmd : program passed in as string (terminates option list)\n\ file : program read from script file\n\ --- 79,82 ---- *************** *** 168,175 **** case 'x': skipfirstline = 1; - break; - - case 'X': - Py_UseClassExceptionsFlag = 0; break; --- 167,170 ---- From python-dev@python.org Tue May 2 20:24:09 2000 From: python-dev@python.org (Barry A. Warsaw) Date: Tue, 2 May 2000 15:24:09 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.154,2.155 Message-ID: <20000502192409.8C44E6636B@anthem.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Python In directory anthem:/home/bwarsaw/projects/python/Python Modified Files: bltinmodule.c Log Message: initerrors(): Remove this function. String-based standard exceptions are no longer supported (i.e. -X option is removed). _PyBuiltin_Init_1(): Don't call initerrors(). This does mean that it is possible to raise an ImportError before that exception has been initialized, say because exceptions.py can't be found, or contains bogosity. See changes to errors.c for how this is handled. _PyBuiltin_Init_2(): Don't test Py_UseClassExceptionsFlag, just go ahead and initialize the class-based standard exceptions. If this fails, we throw a Py_FatalError. Index: bltinmodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.154 retrieving revision 2.155 diff -C2 -r2.154 -r2.155 *** bltinmodule.c 2000/04/13 02:42:50 2.154 --- bltinmodule.c 2000/05/02 19:24:06 2.155 *************** *** 2545,2632 **** } - static void - initerrors(dict) - PyObject *dict; - { - int i, j; - int exccnt = 0; - for (i = 0; bltin_exc[i].name; i++, exccnt++) { - Py_XDECREF(*bltin_exc[i].exc); - if (bltin_exc[i].leaf_exc) - *bltin_exc[i].exc = - newstdexception(dict, bltin_exc[i].name); - } - - /* This is kind of bogus because we special case the some of the - * new exceptions to be nearly forward compatible. But this means - * we hard code knowledge about exceptions.py into C here. I don't - * have a better solution, though. - */ - PyExc_LookupError = PyTuple_New(2); - Py_INCREF(PyExc_IndexError); - PyTuple_SET_ITEM(PyExc_LookupError, 0, PyExc_IndexError); - Py_INCREF(PyExc_KeyError); - PyTuple_SET_ITEM(PyExc_LookupError, 1, PyExc_KeyError); - PyDict_SetItemString(dict, "LookupError", PyExc_LookupError); - - PyExc_ArithmeticError = PyTuple_New(3); - Py_INCREF(PyExc_OverflowError); - PyTuple_SET_ITEM(PyExc_ArithmeticError, 0, PyExc_OverflowError); - Py_INCREF(PyExc_ZeroDivisionError); - PyTuple_SET_ITEM(PyExc_ArithmeticError, 1, PyExc_ZeroDivisionError); - Py_INCREF(PyExc_FloatingPointError); - PyTuple_SET_ITEM(PyExc_ArithmeticError, 2, PyExc_FloatingPointError); - PyDict_SetItemString(dict, "ArithmeticError", PyExc_ArithmeticError); - - PyExc_EnvironmentError = PyTuple_New(2); - Py_INCREF(PyExc_IOError); - PyTuple_SET_ITEM(PyExc_EnvironmentError, 0, PyExc_IOError); - Py_INCREF(PyExc_OSError); - PyTuple_SET_ITEM(PyExc_EnvironmentError, 1, PyExc_OSError); - PyDict_SetItemString(dict, "EnvironmentError", PyExc_EnvironmentError); - - /* Make UnboundLocalError an alias for NameError */ - Py_INCREF(PyExc_NameError); - Py_DECREF(PyExc_UnboundLocalError); - PyExc_UnboundLocalError = PyExc_NameError; - if (PyDict_SetItemString(dict, "UnboundLocalError", - PyExc_NameError) != 0) - Py_FatalError("Cannot create string-based exceptions"); - /* Make UnicodeError an alias for ValueError */ - Py_INCREF(PyExc_ValueError); - Py_DECREF(PyExc_UnicodeError); - PyExc_UnicodeError = PyExc_ValueError; - if (PyDict_SetItemString(dict, "UnicodeError", - PyExc_ValueError) != 0) - Py_FatalError("Cannot create string-based exceptions"); - - /* missing from the StandardError tuple: Exception, StandardError, - * and SystemExit - */ - PyExc_StandardError = PyTuple_New(exccnt-3); - for (i = 2, j = 0; bltin_exc[i].name; i++) { - PyObject *exc = *bltin_exc[i].exc; - /* SystemExit is not an error, but it is an exception */ - if (exc != PyExc_SystemExit) { - Py_INCREF(exc); - PyTuple_SET_ITEM(PyExc_StandardError, j++, exc); - } - } - PyDict_SetItemString(dict, "StandardError", PyExc_StandardError); - - /* Exception is a 2-tuple */ - PyExc_Exception = PyTuple_New(2); - Py_INCREF(PyExc_SystemExit); - PyTuple_SET_ITEM(PyExc_Exception, 0, PyExc_SystemExit); - Py_INCREF(PyExc_StandardError); - PyTuple_SET_ITEM(PyExc_Exception, 1, PyExc_StandardError); - PyDict_SetItemString(dict, "Exception", PyExc_Exception); - - if (PyErr_Occurred()) - Py_FatalError("Could not initialize built-in string exceptions"); - } - - static void finierrors() --- 2545,2549 ---- *************** *** 2655,2659 **** return NULL; dict = PyModule_GetDict(mod); - initerrors(dict); if (PyDict_SetItemString(dict, "None", Py_None) < 0) return NULL; --- 2572,2575 ---- *************** *** 2671,2686 **** PyObject *dict; { ! /* if Python was started with -X, initialize the class exceptions */ ! if (Py_UseClassExceptionsFlag) { ! if (!init_class_exc(dict)) { ! /* class based exceptions could not be ! * initialized. Fall back to using string based ! * exceptions. ! */ ! PySys_WriteStderr( ! "Warning! Falling back to string-based exceptions\n"); ! initerrors(dict); ! } ! } } --- 2587,2594 ---- PyObject *dict; { ! if (!init_class_exc(dict)) ! /* class based exceptions could not be initialized. */ ! Py_FatalError("Standard exceptions could not be initialized."); ! /* does not return */ } From python-dev@python.org Tue May 2 20:24:42 2000 From: python-dev@python.org (Barry A. Warsaw) Date: Tue, 2 May 2000 15:24:42 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.155,2.156 Message-ID: <20000502192442.CA6B86636B@anthem.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Python In directory anthem:/home/bwarsaw/projects/python/Python Modified Files: bltinmodule.c Log Message: _PyBuiltin_Init_2(): Remove the misleading comment. Index: bltinmodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.155 retrieving revision 2.156 diff -C2 -r2.155 -r2.156 *** bltinmodule.c 2000/05/02 19:24:06 2.155 --- bltinmodule.c 2000/05/02 19:24:39 2.156 *************** *** 2590,2594 **** /* class based exceptions could not be initialized. */ Py_FatalError("Standard exceptions could not be initialized."); - /* does not return */ } --- 2590,2593 ---- From python-dev@python.org Tue May 2 20:27:53 2000 From: python-dev@python.org (Barry A. Warsaw) Date: Tue, 2 May 2000 15:27:53 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Python errors.c,2.44,2.45 Message-ID: <20000502192753.D03D86636B@anthem.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Python In directory anthem:/home/bwarsaw/projects/python/Python Modified Files: errors.c Log Message: PyErr_GivenExceptionMatches(): Check for err==NULL and exc==NULL and return 0 (exceptions don't match). This means that if an ImportError is raised because exceptions.py can't be imported, the interpreter will exit "cleanly" with an error message instead of just core dumping. PyErr_SetFromErrnoWithFilename(), PyErr_SetFromWindowsErrWithFilename(): Don't test on Py_UseClassExceptionsFlag. Index: errors.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Python/errors.c,v retrieving revision 2.44 retrieving revision 2.45 diff -C2 -r2.44 -r2.45 *** errors.c 2000/03/02 13:55:01 2.44 --- errors.c 2000/05/02 19:27:51 2.45 *************** *** 126,129 **** --- 126,133 ---- PyObject *err, *exc; { + if (err == NULL || exc == NULL) { + /* maybe caused by "import exceptions" that failed early on */ + return 0; + } if (PyTuple_Check(exc)) { int i, n; *************** *** 332,336 **** } #endif ! if (filename != NULL && Py_UseClassExceptionsFlag) v = Py_BuildValue("(iss)", i, s, filename); else --- 336,340 ---- } #endif ! if (filename != NULL) v = Py_BuildValue("(iss)", i, s, filename); else *************** *** 380,384 **** while (len > 0 && (s[len-1] <= ' ' || s[len-1] == '.')) s[--len] = '\0'; ! if (filename != NULL && Py_UseClassExceptionsFlag) v = Py_BuildValue("(iss)", err, s, filename); else --- 384,388 ---- while (len > 0 && (s[len-1] <= ' ' || s[len-1] == '.')) s[--len] = '\0'; ! if (filename != NULL) v = Py_BuildValue("(iss)", err, s, filename); else From python-dev@python.org Tue May 2 20:28:32 2000 From: python-dev@python.org (Barry A. Warsaw) Date: Tue, 2 May 2000 15:28:32 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Tools/i18n pygettext.py,1.8,1.9 Message-ID: <20000502192832.D7A276636B@anthem.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Tools/i18n In directory anthem:/home/bwarsaw/projects/python/Tools/i18n Modified Files: pygettext.py Log Message: Added an unused Unicode string for testing. Index: pygettext.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Tools/i18n/pygettext.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** pygettext.py 2000/03/08 15:18:35 1.8 --- pygettext.py 2000/05/02 19:28:30 1.9 *************** *** 450,451 **** --- 450,453 ---- if __name__ == '__main__': main() + # some more test strings + _(u'a unicode string') From python-dev@python.org Tue May 2 22:18:17 2000 From: python-dev@python.org (Guido van Rossum) Date: Tue, 2 May 2000 17:18:17 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Modules audioop.c,1.35,1.36 Message-ID: <200005022118.RAA01054@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Modules In directory eric:/projects/python/develop/guido/src/Modules Modified Files: audioop.c Log Message: Disable the ZEROTRAP code -- this turns a 0 byte into a 2 byte and I don't think that's what we want. There was some brief discussion of this somewhere but I don't recall where. Index: audioop.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/audioop.c,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -r1.35 -r1.36 *** audioop.c 2000/02/29 13:59:22 1.35 --- audioop.c 2000/05/02 21:18:13 1.36 *************** *** 112,116 **** 56, 48, 40, 32, 24, 16, 8, 0 }; ! #define ZEROTRAP /* turn on the trap as per the MIL-STD */ #define BIAS 0x84 /* define the add-in bias for 16 bit samples */ #define CLIP 32635 --- 112,116 ---- 56, 48, 40, 32, 24, 16, 8, 0 }; ! /* #define ZEROTRAP /* turn on the trap as per the MIL-STD */ #define BIAS 0x84 /* define the add-in bias for 16 bit samples */ #define CLIP 32635 From python-dev@python.org Tue May 2 23:29:50 2000 From: python-dev@python.org (Jeremy Hylton) Date: Tue, 2 May 2000 18:29:50 -0400 Subject: [Python-checkins] CVS: /python/nondist/src/Compiler compile.py,1.1,1.2 test.py,1.4,1.5 Message-ID: <200005022229.SAA19322@goon.cnri.reston.va.us> Update of /projects/cvsroot//python/nondist/src/Compiler In directory goon.cnri.reston.va.us:/tmp/Compiler Modified Files: compile.py test.py Log Message: patches from Mark Hammond compile.py: On Windows, use 'nul' instead of '/dev/null'. test.py: Use double-quotes for the command-line, as Windows doesnt recognise singles. Index: compile.py =================================================================== RCS file: /projects/cvsroot//python/nondist/src/Compiler/compile.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** compile.py 2000/03/06 19:13:21 1.1 --- compile.py 2000/05/02 22:29:46 1.2 *************** *** 12,16 **** visitor.ASTVisitor.VERBOSE = visitor.ASTVisitor.VERBOSE + 1 if k == '-q': ! f = open('/dev/null', 'wb') sys.stdout = f if not args: --- 12,19 ---- visitor.ASTVisitor.VERBOSE = visitor.ASTVisitor.VERBOSE + 1 if k == '-q': ! if sys.platform[:3]=="win": ! f = open('nul', 'wb') # /dev/null fails on Windows... ! else: ! f = open('/dev/null', 'wb') sys.stdout = f if not args: Index: test.py =================================================================== RCS file: /projects/cvsroot//python/nondist/src/Compiler/test.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** test.py 2000/02/10 17:34:12 1.4 --- test.py 2000/05/02 22:29:46 1.5 *************** *** 17,21 **** output = "experimental/%s.txt" % base os.system("python ../compile.py -q %s" % path) ! os.system("python -c 'import %s' > %s 2>&1" % (base, output)) os.system("diff -c %s %s" % ("%s/%s.txt" % (outputDir, base), output)) --- 17,21 ---- output = "experimental/%s.txt" % base os.system("python ../compile.py -q %s" % path) ! os.system('python -c "import %s" > %s 2>&1' % (base, output)) os.system("diff -c %s %s" % ("%s/%s.txt" % (outputDir, base), output)) From python-dev@python.org Tue May 2 23:33:02 2000 From: python-dev@python.org (Jeremy Hylton) Date: Tue, 2 May 2000 18:33:02 -0400 Subject: [Python-checkins] CVS: /python/nondist/src/Compiler/compiler ast.py,1.8,1.9 pyassem.py,1.8,1.9 pycodegen.py,1.19,1.20 transformer.py,1.9,1.10 Message-ID: <200005022233.SAA19347@goon.cnri.reston.va.us> Update of /projects/cvsroot//python/nondist/src/Compiler/compiler In directory goon.cnri.reston.va.us:/tmp/Compiler/compiler Modified Files: ast.py pyassem.py pycodegen.py transformer.py Log Message: patches from Mark Hammond Attached is a set of diffs for the .py compiler that adds support for the new extended call syntax. compiler/ast.py: CallFunc node gets 2 new children to support extended call syntax - "star_args" (for "*args") and "dstar_args" (for "**args") compiler/pyassem.py It appear that self.lnotab is supposed to be responsible for tracking line numbers, but self.firstlineno was still hanging around. Removed self.firstlineno completely. NOTE - I didnt actually test that the generated code has the correct line numbers!! Stack depth tracking appeared a little broken - the checks never made it beyond the "self.patterns" check - thus, the custom methods were never called! Fixed this. (XXX Jeremy notes: I think this code is still broken because it doesn't track stack effects across block bounaries.) Added support for the new extended call syntax opcodes for depth calculations. compiler/pycodegen.py Added support for the new extended call syntax opcodes. compiler/transformer.py Added support for the new extended call syntax. Index: ast.py =================================================================== RCS file: /projects/cvsroot//python/nondist/src/Compiler/compiler/ast.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** ast.py 2000/03/06 18:50:48 1.8 --- ast.py 2000/05/02 22:32:59 1.9 *************** *** 446,456 **** nodes['call_func'] = 'CallFunc' ! def __init__(self, node, args): self.node = node self.args = args ! self._children = ('call_func', node, args) def __repr__(self): ! return "CallFunc(%s,%s)" % self._children[1:] class Keyword(Node): --- 446,458 ---- nodes['call_func'] = 'CallFunc' ! def __init__(self, node, args, star_args = None, dstar_args = None): self.node = node self.args = args ! self.star_args = star_args ! self.dstar_args = dstar_args ! self._children = ('call_func', node, args, star_args, dstar_args) def __repr__(self): ! return "CallFunc(%s,%s,*%s, **%s)" % self._children[1:] class Keyword(Node): Index: pyassem.py =================================================================== RCS file: /projects/cvsroot//python/nondist/src/Compiler/compiler/pyassem.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** pyassem.py 2000/03/16 20:06:59 1.8 --- pyassem.py 2000/05/02 22:32:59 1.9 *************** *** 150,154 **** else: self.flags = 0 - self.firstlineno = None self.consts = [] self.names = [] --- 150,153 ---- *************** *** 315,320 **** if opname == "SET_LINENO": lnotab.nextLine(oparg) - if self.firstlineno is None: - self.firstlineno = oparg hi, lo = twobyte(oparg) try: --- 314,317 ---- *************** *** 343,347 **** self.lnotab.getCode(), self.getConsts(), tuple(self.names), tuple(self.varnames), ! self.filename, self.name, self.firstlineno, self.lnotab.getTable()) --- 340,344 ---- self.lnotab.getCode(), self.getConsts(), tuple(self.names), tuple(self.varnames), ! self.filename, self.name, self.lnotab.firstline, self.lnotab.getTable()) *************** *** 465,476 **** maxDepth = depth # now check patterns ! for pat, delta in self.patterns: if opname[:len(pat)] == pat: depth = depth + delta break # if we still haven't found a match if delta == 0: ! meth = getattr(self, opname) ! depth = depth + meth(i[1]) if depth < 0: depth = 0 --- 462,475 ---- maxDepth = depth # now check patterns ! for pat, pat_delta in self.patterns: if opname[:len(pat)] == pat: + delta = pat_delta depth = depth + delta break # if we still haven't found a match if delta == 0: ! meth = getattr(self, opname, None) ! if meth is not None: ! depth = depth + meth(i[1]) if depth < 0: depth = 0 *************** *** 528,531 **** --- 527,536 ---- hi, lo = divmod(argc, 256) return lo + hi * 2 + def CALL_FUNCTION_VAR(self, argc): + return self.CALL_FUNCTION(argc)+1 + def CALL_FUNCTION_KW(self, argc): + return self.CALL_FUNCTION(argc)+1 + def CALL_FUNCTION_VAR_KW(self, argc): + return self.CALL_FUNCTION(argc)+2 def MAKE_FUNCTION(self, argc): return -argc Index: pycodegen.py =================================================================== RCS file: /projects/cvsroot//python/nondist/src/Compiler/compiler/pycodegen.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** pycodegen.py 2000/03/16 20:06:59 1.19 --- pycodegen.py 2000/05/02 22:32:59 1.20 *************** *** 10,13 **** --- 10,21 ---- from compiler.pyassem import CO_VARARGS, CO_VARKEYWORDS, TupleArg + callfunc_opcode_info = { + # (Have *args, Have **args) : opcode + (0,0) : "CALL_FUNCTION", + (1,0) : "CALL_FUNCTION_VAR", + (0,1) : "CALL_FUNCTION_KW", + (1,1) : "CALL_FUNCTION_VAR_KW", + } + def compile(filename): f = open(filename) *************** *** 479,483 **** else: pos = pos + 1 ! self.emit('CALL_FUNCTION', kw << 8 | pos) def visitPrint(self, node): --- 487,498 ---- else: pos = pos + 1 ! if node.star_args is not None: ! self.visit(node.star_args) ! if node.dstar_args is not None: ! self.visit(node.dstar_args) ! have_star = node.star_args is not None ! have_dstar = node.dstar_args is not None ! opcode = callfunc_opcode_info[have_star, have_dstar] ! self.emit(opcode, kw << 8 | pos) def visitPrint(self, node): Index: transformer.py =================================================================== RCS file: /projects/cvsroot//python/nondist/src/Compiler/compiler/transformer.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** transformer.py 2000/03/16 20:03:04 1.9 --- transformer.py 2000/05/02 22:32:59 1.10 *************** *** 985,992 **** args = [ ] kw = 0 ! for i in range(1, len(nodelist), 2): ! kw, result = self.com_argument(nodelist[i], kw) args.append(result) ! return Node('call_func', primaryNode, args) def com_argument(self, nodelist, kw): --- 985,1014 ---- args = [ ] kw = 0 ! len_nodelist = len(nodelist) ! for i in range(1, len_nodelist, 2): ! node = nodelist[i] ! if node[0] == token.STAR or node[0] == token.DOUBLESTAR: ! break ! kw, result = self.com_argument(node, kw) args.append(result) ! else: ! i = i + 1 # No broken by star arg, so skip the last one we processed. ! star_node = dstar_node = None ! while i < len_nodelist: ! tok = nodelist[i] ! ch = nodelist[i+1] ! i = i + 3 ! if tok[0]==token.STAR: ! if star_node is not None: ! raise SyntaxError, 'already have the varargs indentifier' ! star_node = self.com_node(ch) ! elif tok[0]==token.DOUBLESTAR: ! if dstar_node is not None: ! raise SyntaxError, 'already have the kwargs indentifier' ! dstar_node = self.com_node(ch) ! else: ! raise SyntaxError, 'unknown node type: %s' % tok ! ! return Node('call_func', primaryNode, args, star_node, dstar_node) def com_argument(self, nodelist, kw): From python-dev@python.org Tue May 2 23:34:04 2000 From: python-dev@python.org (Jeremy Hylton) Date: Tue, 2 May 2000 18:34:04 -0400 Subject: [Python-checkins] CVS: /python/nondist/src/Compiler/tests test_func.py,1.8,1.9 Message-ID: <200005022234.SAA19372@goon.cnri.reston.va.us> Update of /projects/cvsroot//python/nondist/src/Compiler/tests In directory goon.cnri.reston.va.us:/tmp/Compiler/tests Modified Files: test_func.py Log Message: patches from Mark Hammond Attached is a set of diffs for the .py compiler that adds support for the new extended call syntax. tests/test_func.py Added tests of the new extended call syntax. Index: test_func.py =================================================================== RCS file: /projects/cvsroot//python/nondist/src/Compiler/tests/test_func.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** test_func.py 2000/02/17 22:11:39 1.8 --- test_func.py 2000/05/02 22:34:01 1.9 *************** *** 24,27 **** --- 24,38 ---- print test5() print test5(2, 0, 1, 2) + # Some extended call tests. + args = 0, (6, (3,22)) + kwargs = {'y':0, 'z':0} + print test4( ((10,6), 2), *args, **kwargs) + # Ensure kw args can come before the extended syntax. + print test4( ((10,6), 2), y=0,z=0, *args) + kwargs = {'a':1, 'c':4} + print test1( **kwargs ) + + print test5( *(2, 0, 1, 2) ) + print test5( 2, *(0, 1, 2) ) test() From python-dev@python.org Wed May 3 03:44:58 2000 From: python-dev@python.org (Guido van Rossum) Date: Tue, 2 May 2000 22:44:58 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Modules posixmodule.c,2.133,2.134 Message-ID: <200005030244.WAA02846@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Modules In directory eric:/projects/python/develop/guido/src/Modules Modified Files: posixmodule.c Log Message: Mark Hammond to the rescue: Checkin 2.131 of posixmodule.c changed os.stat on Windows, so that "/bin/" type notation (trailing backslash) would work on Windows to be consistent with Unix. However, the patch broke the simple case of: os.stat("\\") This did work in 1.5.2, and obviously should! This patch addresses this, and restores the correct behaviour. Index: posixmodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.133 retrieving revision 2.134 diff -C2 -r2.133 -r2.134 *** posixmodule.c 2000/05/01 16:17:24 2.133 --- posixmodule.c 2000/05/03 02:44:55 2.134 *************** *** 568,575 **** if ((pathlen > 0) && (path[pathlen-1] == '\\' || path[pathlen-1] == '/')) { ! /* exception for drive root */ ! if (!((pathlen == 3) && (path[1] == ':') && ! (path[2] == '\\' || path[2] == '/'))) { strncpy(pathcopy, path, pathlen); --- 568,576 ---- if ((pathlen > 0) && (path[pathlen-1] == '\\' || path[pathlen-1] == '/')) { ! /* exception for specific or current drive root */ ! if (!((pathlen == 1) || ! ((pathlen == 3) && (path[1] == ':') && ! (path[2] == '\\' || path[2] == '/')))) { strncpy(pathcopy, path, pathlen); From python-dev@python.org Wed May 3 12:03:27 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 3 May 2000 07:03:27 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.13,2.14 Message-ID: <200005031103.HAA03106@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Objects In directory eric:/projects/python/develop/guido/src/Objects Modified Files: unicodeobject.c Log Message: Mark Hammond: Fixes the MBCS codec to work correctly with zero length strings. Index: unicodeobject.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.13 retrieving revision 2.14 diff -C2 -r2.13 -r2.14 *** unicodeobject.c 2000/05/01 21:27:20 2.13 --- unicodeobject.c 2000/05/03 11:03:24 2.14 *************** *** 1556,1560 **** /* First get the size of the result */ DWORD usize = MultiByteToWideChar(CP_ACP, 0, s, size, NULL, 0); ! if (usize==0) return PyErr_SetFromWindowsErrWithFilename(0, NULL); --- 1556,1560 ---- /* First get the size of the result */ DWORD usize = MultiByteToWideChar(CP_ACP, 0, s, size, NULL, 0); ! if (size > 0 && usize==0) return PyErr_SetFromWindowsErrWithFilename(0, NULL); *************** *** 1579,1585 **** PyObject *repr; char *s; /* First get the size of the result */ ! DWORD mbcssize = WideCharToMultiByte(CP_ACP, 0, p, size, NULL, 0, NULL, NULL); if (mbcssize==0) return PyErr_SetFromWindowsErrWithFilename(0, NULL); --- 1579,1590 ---- PyObject *repr; char *s; + DWORD mbcssize; + /* If there are no characters, bail now! */ + if (size==0) + return PyString_FromString(""); + /* First get the size of the result */ ! mbcssize = WideCharToMultiByte(CP_ACP, 0, p, size, NULL, 0, NULL, NULL); if (mbcssize==0) return PyErr_SetFromWindowsErrWithFilename(0, NULL); From python-dev@python.org Wed May 3 13:27:25 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 3 May 2000 08:27:25 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.14,2.15 Message-ID: <200005031227.IAA03379@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Objects In directory eric:/projects/python/develop/guido/src/Objects Modified Files: unicodeobject.c Log Message: Mark Hammond withdraws his fix -- the size includes the trailing 0 so a size of 0 *is* illegal. Index: unicodeobject.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.14 retrieving revision 2.15 diff -C2 -r2.14 -r2.15 *** unicodeobject.c 2000/05/03 11:03:24 2.14 --- unicodeobject.c 2000/05/03 12:27:22 2.15 *************** *** 1556,1560 **** /* First get the size of the result */ DWORD usize = MultiByteToWideChar(CP_ACP, 0, s, size, NULL, 0); ! if (size > 0 && usize==0) return PyErr_SetFromWindowsErrWithFilename(0, NULL); --- 1556,1560 ---- /* First get the size of the result */ DWORD usize = MultiByteToWideChar(CP_ACP, 0, s, size, NULL, 0); ! if (usize==0) return PyErr_SetFromWindowsErrWithFilename(0, NULL); *************** *** 1579,1590 **** PyObject *repr; char *s; - DWORD mbcssize; - /* If there are no characters, bail now! */ - if (size==0) - return PyString_FromString(""); - /* First get the size of the result */ ! mbcssize = WideCharToMultiByte(CP_ACP, 0, p, size, NULL, 0, NULL, NULL); if (mbcssize==0) return PyErr_SetFromWindowsErrWithFilename(0, NULL); --- 1579,1585 ---- PyObject *repr; char *s; /* First get the size of the result */ ! DWORD mbcssize = WideCharToMultiByte(CP_ACP, 0, p, size, NULL, 0, NULL, NULL); if (mbcssize==0) return PyErr_SetFromWindowsErrWithFilename(0, NULL); From python-dev@python.org Wed May 3 16:11:50 2000 From: python-dev@python.org (Fred Drake) Date: Wed, 3 May 2000 11:11:50 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libtelnetlib.tex,1.4,1.5 Message-ID: <200005031511.LAA07113@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/lib In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/lib Modified Files: libtelnetlib.tex Log Message: Clarify status of connection of a new instance; it *is* connected if you pass server information to the constructor. Error noted by Pedro Diaz Jimenez . Index: libtelnetlib.tex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/lib/libtelnetlib.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** libtelnetlib.tex 2000/04/26 18:20:04 1.4 --- libtelnetlib.tex 2000/05/03 15:11:47 1.5 *************** *** 13,19 **** \begin{classdesc}{Telnet}{\optional{host\optional{, port}}} \class{Telnet} represents a connection to a telnet server. The ! instance is initially not connected; the \method{open()} method must ! be used to establish a connection. Alternatively, the host name and ! optional port number can be passed to the constructor, too. Do not reopen an already connected instance. --- 13,21 ---- \begin{classdesc}{Telnet}{\optional{host\optional{, port}}} \class{Telnet} represents a connection to a telnet server. The ! instance is initially not connected by default; the \method{open()} ! method must be used to establish a connection. Alternatively, the ! host name and optional port number can be passed to the constructor, ! to, in which case the connection to the server will be established ! before the constructor returns. Do not reopen an already connected instance. From python-dev@python.org Wed May 3 16:16:00 2000 From: python-dev@python.org (Fred Drake) Date: Wed, 3 May 2000 11:16:00 -0400 Subject: [Python-checkins] CVS: python/dist/src/Python getargs.c,2.30,2.31 Message-ID: <200005031516.LAA07192@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Python In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Python Modified Files: getargs.c Log Message: Brian Hooper : Added 'u' and 'u#' tags for PyArg_ParseTuple - these turn a PyUnicodeObject argument into a Py_UNICODE * buffer, or a Py_UNICODE * buffer plus a length with the '#'. Also added an analog to 'U' for Py_BuildValue. Index: getargs.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Python/getargs.c,v retrieving revision 2.30 retrieving revision 2.31 diff -C2 -r2.30 -r2.31 *** getargs.c 2000/04/27 20:13:18 2.30 --- getargs.c 2000/05/03 15:15:57 2.31 *************** *** 778,781 **** --- 778,813 ---- } + case 'u': /* raw unicode buffer (Py_UNICODE *) */ + { + if (*format == '#') { /* any buffer-like object */ + void **p = (void **)va_arg(*p_va, char **); + PyBufferProcs *pb = arg->ob_type->tp_as_buffer; + int *q = va_arg(*p_va, int *); + int count; + + if ( pb == NULL || + pb->bf_getreadbuffer == NULL || + pb->bf_getsegcount == NULL ) + return "read-only buffer"; + if ( (*pb->bf_getsegcount)(arg, NULL) != 1 ) + return "single-segment read-only buffer"; + if ( (count = + (*pb->bf_getreadbuffer)(arg, 0, p)) < 0 ) + return "(unspecified)"; + /* buffer interface returns bytes, we want + length in characters */ + *q = count/(sizeof(Py_UNICODE)); + format++; + } else { + Py_UNICODE **p = va_arg(*p_va, Py_UNICODE **); + + if (PyUnicode_Check(arg)) + *p = PyUnicode_AS_UNICODE(arg); + else + return "unicode"; + } + break; + } + case 'S': /* string object */ { From python-dev@python.org Wed May 3 16:17:05 2000 From: python-dev@python.org (Fred Drake) Date: Wed, 3 May 2000 11:17:05 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/ext ext.tex,1.72,1.73 Message-ID: <200005031517.LAA07208@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/ext In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/ext Modified Files: ext.tex Log Message: Brian Hooper : Added 'u' and 'u#' tags for PyArg_ParseTuple - these turn a PyUnicodeObject argument into a Py_UNICODE * buffer, or a Py_UNICODE * buffer plus a length with the '#'. Also added an analog to 'U' for Py_BuildValue. Index: ext.tex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/ext/ext.tex,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -r1.72 -r1.73 *** ext.tex 2000/04/28 14:43:33 1.72 --- ext.tex 2000/05/03 15:17:02 1.73 *************** *** 692,695 **** --- 692,706 ---- This is to \samp{s\#} as \samp{z} is to \samp{s}. + \item[\samp{u} (Unicode string) {[Py_UNICODE *]}] + Convert a Python Unicode object to a C pointer to a null-terminated + buffer of Unicode (UCS-2) data. As with \samp{s}, there is no need + to provide storage for the Unicode data buffer; a pointer to the + existing Unicode data is stored into the Py_UNICODE pointer variable whose + address you pass. + + \item[\samp{u\#} (Unicode string) {[Py_UNICODE *, int]}] + This variant on \samp{u} stores into two C variables, the first one + a pointer to a Unicode data buffer, the second one its length. + \item[\samp{b} (integer) {[char]}] Convert a Python integer to a tiny int, stored in a C \ctype{char}. *************** *** 752,755 **** --- 763,771 ---- The C variable may also be declared as \ctype{PyObject *}. + \item[\samp{U} (Unicode string) {[PyUnicodeObject *]}] + Like \samp{O} but requires that the Python object is a Unicode object. + Raises \exception{TypeError} if the object is not a Unicode object. + The C variable may also be declared as \ctype{PyObject *}. + \item[\samp{t\#} (read-only character buffer) {[char *, int]}] Like \samp{s\#}, but accepts any object which implements the read-only *************** *** 1017,1020 **** --- 1033,1045 ---- is ignored and \code{None} is returned. + \item[\samp{u} (Unicode string) {[Py_UNICODE *]}] + Convert a null-terminated buffer of Unicode (UCS-2) data to a Python Unicode + object. If the Unicode buffer pointer is \NULL{}, \code{None} is returned. + + \item[\samp{u\#} (Unicode string) {[Py_UNICODE *, int]}] + Convert a Unicode (UCS-2) data buffer and its length to a Python Unicode + object. If the Unicode buffer pointer is \NULL{}, the length is ignored and + \code{None} is returned. + \item[\samp{i} (integer) {[int]}] Convert a plain C \ctype{int} to a Python integer object. *************** *** 1049,1052 **** --- 1074,1080 ---- \item[\samp{S} (object) {[PyObject *]}] + Same as \samp{O}. + + \item[\samp{U} (object) {[PyObject *]}] Same as \samp{O}. From python-dev@python.org Wed May 3 20:40:36 2000 From: python-dev@python.org (Fred Drake) Date: Wed, 3 May 2000 15:40:36 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libsocket.tex,1.43,1.44 Message-ID: <200005031940.PAA08016@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/lib In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/lib Modified Files: libsocket.tex Log Message: Someone found the examples of poor practice on socket addresses! Spotted by Greg Kochanski . Index: libsocket.tex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/lib/libsocket.tex,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -r1.43 -r1.44 *** libsocket.tex 2000/04/04 17:48:30 1.43 --- libsocket.tex 2000/05/03 19:40:32 1.44 *************** *** 414,418 **** PORT = 50007 # Arbitrary non-privileged server s = socket(AF_INET, SOCK_STREAM) ! s.bind(HOST, PORT) s.listen(1) conn, addr = s.accept() --- 414,418 ---- PORT = 50007 # Arbitrary non-privileged server s = socket(AF_INET, SOCK_STREAM) ! s.bind((HOST, PORT)) s.listen(1) conn, addr = s.accept() *************** *** 431,435 **** PORT = 50007 # The same port as used by the server s = socket(AF_INET, SOCK_STREAM) ! s.connect(HOST, PORT) s.send('Hello, world') data = s.recv(1024) --- 431,435 ---- PORT = 50007 # The same port as used by the server s = socket(AF_INET, SOCK_STREAM) ! s.connect((HOST, PORT)) s.send('Hello, world') data = s.recv(1024) *************** *** 439,442 **** \begin{seealso} ! \seemodule{SocketServer}{classes that simplify writing network servers} \end{seealso} --- 439,442 ---- \begin{seealso} ! \seemodule{SocketServer}{classes that simplify writing network servers} \end{seealso} From python-dev@python.org Wed May 3 23:03:50 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 3 May 2000 18:03:50 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.156,2.157 Message-ID: <200005032203.SAA05545@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Python In directory eric:/projects/python/develop/guido/src/Python Modified Files: bltinmodule.c Log Message: A bit of cleanup: - When 'import exceptions' fails, don't suggest to use -v to print the traceback; this doesn't actually work. - Remove comment about fallback to string exceptions. - Remove a PyErr_Occurred() check after all is said and done that can never trigger. - Remove static function newstdexception() which is no longer called. Index: bltinmodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.156 retrieving revision 2.157 diff -C2 -r2.156 -r2.157 *** bltinmodule.c 2000/05/02 19:24:39 2.156 --- bltinmodule.c 2000/05/03 22:03:46 2.157 *************** *** 2441,2447 **** ! /* import exceptions module to extract class exceptions. on success, ! * return 1. on failure return 0 which signals _PyBuiltin_Init_2 to fall ! * back to using old-style string based exceptions. */ static int --- 2441,2447 ---- ! /* Import exceptions module to extract class exceptions. On success, ! * return 1. On failure return 0 which signals _PyBuiltin_Init_2 to ! * issue a fatal error. */ static int *************** *** 2458,2469 **** (d = PyModule_GetDict(m)) == NULL) { ! PySys_WriteStderr("'import exceptions' failed; "); ! if (Py_VerboseFlag) { ! PySys_WriteStderr("traceback:\n"); ! PyErr_Print(); ! } ! else { ! PySys_WriteStderr("use -v for traceback\n"); ! } goto finally; } --- 2458,2462 ---- (d = PyModule_GetDict(m)) == NULL) { ! PySys_WriteStderr("'import exceptions' failed\n"); goto finally; } *************** *** 2506,2521 **** /* we're done with the exceptions module */ Py_DECREF(m); - - if (PyErr_Occurred()) { - PySys_WriteStderr("Cannot initialize standard class exceptions; "); - if (Py_VerboseFlag) { - PySys_WriteStderr("traceback:\n"); - PyErr_Print(); - } - else - PySys_WriteStderr("use -v for traceback\n"); - goto finally; - } return 1; finally: Py_XDECREF(m); --- 2499,2504 ---- /* we're done with the exceptions module */ Py_DECREF(m); return 1; + finally: Py_XDECREF(m); *************** *** 2531,2546 **** Py_XDECREF(PyExc_MemoryErrorInst); PyExc_MemoryErrorInst = NULL; - } - - - static PyObject * - newstdexception(dict, name) - PyObject *dict; - char *name; - { - PyObject *v = PyString_FromString(name); - if (v == NULL || PyDict_SetItemString(dict, name, v) != 0) - Py_FatalError("Cannot create string-based exceptions"); - return v; } --- 2514,2517 ---- From python-dev@python.org Wed May 3 23:30:15 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 3 May 2000 18:30:15 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Modules _localemodule.c,2.7,2.8 Message-ID: <200005032230.SAA06070@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Modules In directory eric:/projects/python/develop/guido/clean/Modules Modified Files: _localemodule.c Log Message: Vladimir Marangozov: Change Py_Malloc/Realloc/Free calls to PyMem_Malloc/Realloc/Free + PyErr_Nomemory on error check. Py_Malloc c.s. are obsolete. Index: _localemodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/_localemodule.c,v retrieving revision 2.7 retrieving revision 2.8 diff -C2 -r2.7 -r2.8 *** _localemodule.c 2000/02/29 13:59:22 2.7 --- _localemodule.c 2000/05/03 22:30:13 2.8 *************** *** 288,302 **** /* assume no change in size, first */ n1=strlen(s)+1; ! buf=Py_Malloc(n1); ! if(!buf)return NULL; n2=strxfrm(buf,s,n1); if(n2>n1){ /* more space needed */ ! buf=Py_Realloc(buf,n2); ! if(!buf)return NULL; strxfrm(buf,s,n2); } result=PyString_FromString(buf); ! Py_Free(buf); return result; } --- 288,302 ---- /* assume no change in size, first */ n1=strlen(s)+1; ! buf=PyMem_Malloc(n1); ! if(!buf)return PyErr_NoMemory(); n2=strxfrm(buf,s,n1); if(n2>n1){ /* more space needed */ ! buf=PyMem_Realloc(buf,n2); ! if(!buf)return PyErr_NoMemory(); strxfrm(buf,s,n2); } result=PyString_FromString(buf); ! PyMem_Free(buf); return result; } From python-dev@python.org Wed May 3 23:33:17 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 3 May 2000 18:33:17 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Modules stdwinmodule.c,2.52,NONE Message-ID: <200005032233.SAA06093@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Modules In directory eric:/projects/python/develop/guido/clean/Modules Removed Files: stdwinmodule.c Log Message: >>Boing!<< Finally, this long-obsolete module bites the dust. From python-dev@python.org Wed May 3 23:34:15 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 3 May 2000 18:34:15 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Modules Setup.in,1.97,1.98 Message-ID: <200005032234.SAA06115@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Modules In directory eric:/projects/python/develop/guido/clean/Modules Modified Files: Setup.in Log Message: Remove all references to stdwin. Index: Setup.in =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/Setup.in,v retrieving revision 1.97 retrieving revision 1.98 diff -C2 -r1.97 -r1.98 *** Setup.in 2000/03/31 16:56:32 1.97 --- Setup.in 2000/05/03 22:34:12 1.98 *************** *** 80,84 **** MACHDEPPATH=:plat-$(MACHDEP) ! COREPYTHONPATH=$(DESTPATH)$(SITEPATH)$(TESTPATH)$(MACHDEPPATH)$(STDWINPATH)$(TKPATH) PYTHONPATH=$(COREPYTHONPATH) --- 80,84 ---- MACHDEPPATH=:plat-$(MACHDEP) ! COREPYTHONPATH=$(DESTPATH)$(SITEPATH)$(TESTPATH)$(MACHDEPPATH)$(TKPATH) PYTHONPATH=$(COREPYTHONPATH) *************** *** 183,206 **** #imageop imageop.c # Operations on images #rgbimg rgbimgmodule.c # Read SGI RGB image files (but coded portably) - - - # The stdwin module provides a simple, portable (between X11 and Mac) - # windowing interface. You need to ftp the STDWIN library, e.g. from - # ftp://ftp.cwi.nl/pub/stdwin. (If you get it elsewhere, be sure to - # get version 1.0 or higher!) The STDWIN variable must point to the - # STDWIN toplevel directory. - - # Uncomment and edit as needed: - #STDWIN=/ufs/guido/src/stdwin - - # Uncomment these lines: - #STDWINPATH=:lib-stdwin - #LIBTEXTEDIT=$(STDWIN)/$(MACHDEP)/Packs/textedit/libtextedit.a - #LIBX11STDWIN=$(STDWIN)/$(MACHDEP)/Ports/x11/libstdwin.a - #stdwin stdwinmodule.c -I$(STDWIN)/H $(LIBTEXTEDIT) $(LIBX11STDWIN) -lX11 - - # Use this instead of the last two lines above for alphanumeric stdwin: - #LIBALFASTDWIN=$(STDWIN)/$(MACHDEP)/Ports/alfa/libstdwin.a - #stdwin stdwinmodule.c -I$(STDWIN)/H $(LIBTEXTEDIT) $(LIBALFASTDWIN) -ltermcap --- 183,186 ---- From python-dev@python.org Thu May 4 00:44:56 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 3 May 2000 19:44:56 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Include mymalloc.h,2.17,2.18 objimpl.h,2.14,2.15 Message-ID: <200005032344.TAA06518@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Include In directory eric:/projects/python/develop/guido/clean/Include Modified Files: mymalloc.h objimpl.h Log Message: Vladimir Marangozov's long-awaited malloc restructuring. For more comments, read the patches@python.org archives. For documentation read the comments in mymalloc.h and objimpl.h. (This is not exactly what Vladimir posted to the patches list; I've made a few changes, and Vladimir sent me a fix in private email for a problem that only occurs in debug mode. I'm also holding back on his change to main.c, which seems unnecessary to me.) Index: mymalloc.h =================================================================== RCS file: /projects/cvsroot/python/dist/src/Include/mymalloc.h,v retrieving revision 2.17 retrieving revision 2.18 diff -C2 -r2.17 -r2.18 *** mymalloc.h 1998/12/04 18:48:10 2.17 --- mymalloc.h 2000/05/03 23:44:23 2.18 *************** *** 58,61 **** --- 58,63 ---- #endif + #include "myproto.h" + #ifdef __cplusplus /* Move this down here since some C++ #include's don't like to be included *************** *** 68,77 **** #endif ! /* The following should never be necessary */ ! #ifdef NEED_TO_DECLARE_MALLOC_AND_FRIEND ! extern ANY *malloc Py_PROTO((size_t)); ! extern ANY *calloc Py_PROTO((size_t, size_t)); ! extern ANY *realloc Py_PROTO((ANY *, size_t)); ! extern void free Py_PROTO((ANY *)); /* XXX sometimes int on Unix old systems */ #endif --- 70,75 ---- #endif ! #ifndef DL_IMPORT /* declarations for DLL import */ ! #define DL_IMPORT(RTYPE) RTYPE #endif *************** *** 88,118 **** #endif ! #define PyMem_NEW(type, n) \ ! ( (type *) malloc(_PyMem_EXTRA + (n) * sizeof(type)) ) ! #define PyMem_RESIZE(p, type, n) \ ! if ((p) == NULL) \ ! (p) = (type *) malloc(_PyMem_EXTRA + (n) * sizeof(type)); \ ! else \ ! (p) = (type *) realloc((ANY *)(p), \ ! _PyMem_EXTRA + (n) * sizeof(type)) ! #define PyMem_DEL(p) free((ANY *)p) ! #define PyMem_XDEL(p) if ((p) == NULL) ; else PyMem_DEL(p) ! /* Two sets of function wrappers around malloc and friends; useful if ! you need to be sure that you are using the same memory allocator as ! Python. Note that the wrappers make sure that allocating 0 bytes ! returns a non-NULL pointer, even if the underlying malloc doesn't. ! The Python interpreter continues to use PyMem_NEW etc. */ ! /* These wrappers around malloc call PyErr_NoMemory() on failure */ ! extern DL_IMPORT(ANY *) Py_Malloc Py_PROTO((size_t)); ! extern DL_IMPORT(ANY *) Py_Realloc Py_PROTO((ANY *, size_t)); ! extern DL_IMPORT(void) Py_Free Py_PROTO((ANY *)); ! /* These wrappers around malloc *don't* call anything on failure */ extern DL_IMPORT(ANY *) PyMem_Malloc Py_PROTO((size_t)); extern DL_IMPORT(ANY *) PyMem_Realloc Py_PROTO((ANY *, size_t)); extern DL_IMPORT(void) PyMem_Free Py_PROTO((ANY *)); #ifdef __cplusplus --- 86,199 ---- #endif ! /* ! * Core memory allocator ! * ===================== ! */ ! ! /* To make sure the interpreter is user-malloc friendly, all memory ! APIs are implemented on top of this one. ! ! The PyCore_* macros can be defined to make the interpreter use a ! custom allocator. Note that they are for internal use only. Both ! the core and extension modules should use the PyMem_* API. */ ! ! #ifndef PyCore_MALLOC_FUNC ! #undef PyCore_REALLOC_FUNC ! #undef PyCore_FREE_FUNC ! #define PyCore_MALLOC_FUNC malloc ! #define PyCore_REALLOC_FUNC realloc ! #define PyCore_FREE_FUNC free ! #endif + #ifndef PyCore_MALLOC_PROTO + #undef PyCore_REALLOC_PROTO + #undef PyCore_FREE_PROTO + #define PyCore_MALLOC_PROTO Py_PROTO((size_t)) + #define PyCore_REALLOC_PROTO Py_PROTO((ANY *, size_t)) + #define PyCore_FREE_PROTO Py_PROTO((ANY *)) + #endif ! #ifdef NEED_TO_DECLARE_MALLOC_AND_FRIEND ! extern ANY *PyCore_MALLOC_FUNC PyCore_MALLOC_PROTO; ! extern ANY *PyCore_REALLOC_FUNC PyCore_REALLOC_PROTO; ! extern void PyCore_FREE_FUNC PyCore_FREE_PROTO; ! #endif ! #ifndef PyCore_MALLOC ! #undef PyCore_REALLOC ! #undef PyCore_FREE ! #define PyCore_MALLOC(n) PyCore_MALLOC_FUNC(n) ! #define PyCore_REALLOC(p, n) PyCore_REALLOC_FUNC((p), (n)) ! #define PyCore_FREE(p) PyCore_FREE_FUNC(p) ! #endif ! /* BEWARE: ! ! Each interface exports both functions and macros. Extension modules ! should normally use the functions for ensuring binary compatibility ! of the user's code across Python versions. Subsequently, if the ! Python runtime switches to its own malloc (different from standard ! malloc), no recompilation is required for the extensions. ! ! The macro versions trade compatibility for speed. They can be used ! whenever there is a performance problem, but their use implies ! recompilation of the code for each new Python release. The Python ! core uses the macros because it *is* compiled on every upgrade. ! This might not be the case with 3rd party extensions in a custom ! setup (for example, a customer does not always have access to the ! source of 3rd party deliverables). You have been warned! */ ! ! /* ! * Raw memory interface ! * ==================== ! */ ! ! /* Functions */ ! ! /* Function wrappers around PyCore_MALLOC and friends; useful if you ! need to be sure that you are using the same memory allocator as ! Python. Note that the wrappers make sure that allocating 0 bytes ! returns a non-NULL pointer, even if the underlying malloc ! doesn't. Returned pointers must be checked for NULL explicitly. ! No action is performed on failure. */ extern DL_IMPORT(ANY *) PyMem_Malloc Py_PROTO((size_t)); extern DL_IMPORT(ANY *) PyMem_Realloc Py_PROTO((ANY *, size_t)); extern DL_IMPORT(void) PyMem_Free Py_PROTO((ANY *)); + + /* Starting from Python 1.6, the wrappers Py_{Malloc,Realloc,Free} are + no longer supported. They used to call PyErr_NoMemory() on failure. */ + + /* Macros */ + #define PyMem_MALLOC(n) PyCore_MALLOC(n) + #define PyMem_REALLOC(p, n) PyCore_REALLOC((ANY *)(p), (n)) + #define PyMem_FREE(p) PyCore_FREE((ANY *)(p)) + + /* + * Type-oriented memory interface + * ============================== + */ + + /* Functions */ + #define PyMem_New(type, n) \ + ( (type *) PyMem_Malloc((n) * sizeof(type)) ) + #define PyMem_Resize(p, type, n) \ + ( (p) = (type *) PyMem_Realloc((n) * sizeof(type)) ) + #define PyMem_Del(p) PyMem_Free(p) + + /* Macros */ + #define PyMem_NEW(type, n) \ + ( (type *) PyMem_MALLOC(_PyMem_EXTRA + (n) * sizeof(type)) ) + #define PyMem_RESIZE(p, type, n) \ + if ((p) == NULL) \ + (p) = (type *)(PyMem_MALLOC( \ + _PyMem_EXTRA + (n) * sizeof(type))); \ + else \ + (p) = (type *)(PyMem_REALLOC((p), \ + _PyMem_EXTRA + (n) * sizeof(type))) + #define PyMem_DEL(p) PyMem_FREE(p) + + /* PyMem_XDEL is deprecated. To avoid the call when p is NULL, + it is recommended to write the test explicitly in the code. + Note that according to ANSI C, free(NULL) has no effect. */ #ifdef __cplusplus Index: objimpl.h =================================================================== RCS file: /projects/cvsroot/python/dist/src/Include/objimpl.h,v retrieving revision 2.14 retrieving revision 2.15 diff -C2 -r2.14 -r2.15 *** objimpl.h 2000/03/01 15:06:53 2.14 --- objimpl.h 2000/05/03 23:44:23 2.15 *************** *** 36,75 **** ******************************************************************/ /* ! Additional macros for modules that implement new object types. You must first include "object.h". ! PyObject_NEW(type, typeobj) allocates memory for a new object of the given ! type; here 'type' must be the C structure type used to represent the ! object and 'typeobj' the address of the corresponding type object. ! Reference count and type pointer are filled in; the rest of the bytes of ! the object are *undefined*! The resulting expression type is 'type *'. ! The size of the object is actually determined by the tp_basicsize field ! of the type object. ! ! PyObject_NEW_VAR(type, typeobj, n) is similar but allocates a variable-size ! object with n extra items. The size is computed as tp_basicsize plus ! n * tp_itemsize. This fills in the ob_size field as well. ! */ ! #ifndef MS_COREDLL extern DL_IMPORT(PyObject *) _PyObject_New Py_PROTO((PyTypeObject *)); extern DL_IMPORT(PyVarObject *) _PyObject_NewVar Py_PROTO((PyTypeObject *, int)); ! ! #define PyObject_NEW(type, typeobj) ((type *) _PyObject_New(typeobj)) ! #define PyObject_NEW_VAR(type, typeobj, n) ((type *) _PyObject_NewVar(typeobj, n)) ! ! #else ! /* For an MS-Windows DLL, we change the way an object is created, so that the ! extension module's malloc is used, rather than the core DLL malloc, as there is ! no guarantee they will use the same heap ! */ ! extern DL_IMPORT(PyObject *) _PyObject_New Py_PROTO((PyTypeObject *, PyObject *)); ! extern DL_IMPORT(PyVarObject *) _PyObject_NewVar Py_PROTO((PyTypeObject *, int, PyVarObject *)); ! ! #define PyObject_NEW(type, typeobj) ((type *) _PyObject_New(typeobj,(PyObject *)malloc((typeobj)->tp_basicsize))) ! #define PyObject_NEW_VAR(type, typeobj, n) ((type *) _PyObject_NewVar(typeobj, n, (PyVarObject *)malloc((typeobj)->tp_basicsize + n * (typeobj)->tp_itemsize))) ! #endif /* MS_COREDLL */ #ifdef __cplusplus --- 36,237 ---- ******************************************************************/ + #include "mymalloc.h" + /* ! Functions and macros for modules that implement new object types. You must first include "object.h". + + - PyObject_New(type, typeobj) allocates memory for a new object of + the given type; here 'type' must be the C structure type used to + represent the object and 'typeobj' the address of the corresponding + type object. Reference count and type pointer are filled in; the + rest of the bytes of the object are *undefined*! The resulting + expression type is 'type *'. The size of the object is actually + determined by the tp_basicsize field of the type object. + + - PyObject_NewVar(type, typeobj, n) is similar but allocates a + variable-size object with n extra items. The size is computed as + tp_basicsize plus n * tp_itemsize. This fills in the ob_size field + as well. + + - PyObject_Del(op) releases the memory allocated for an object. + + - PyObject_Init(op, typeobj) and PyObject_InitVar(op, typeobj, n) are + similar to PyObject_{New, NewVar} except that they don't allocate + the memory needed for an object. Instead of the 'type' parameter, + they accept the pointer of a new object (allocated by an arbitrary + allocator) and initialize its object header fields. + + Note that objects created with PyObject_{New, NewVar} are allocated + within the Python heap by an object allocator, the latter being + implemented (by default) on top of the Python raw memory + allocator. This ensures that Python keeps control on the user's + objects regarding their memory management; for instance, they may be + subject to automatic garbage collection. + + In case a specific form of memory management is needed, implying that + the objects would not reside in the Python heap (for example standard + malloc heap(s) are mandatory, use of shared memory, C++ local storage + or operator new), you must first allocate the object with your custom + allocator, then pass its pointer to PyObject_{Init, InitVar} for + filling in its Python-specific fields: reference count, type pointer, + possibly others. You should be aware that Python has very limited + control over these objects because they don't cooperate with the + Python memory manager. Such objects may not be eligible for automatic + garbage collection and you have to make sure that they are released + accordingly whenever their destructor gets called (cf. the specific + form of memory management you're using). + + Unless you have specific memory management requirements, it is + recommended to use PyObject_{New, NewVar, Del}. */ + + /* + * Core object memory allocator + * ============================ + */ + + /* The purpose of the object allocator is to make make the distinction + between "object memory" and the rest within the Python heap. + + Object memory is the one allocated by PyObject_{New, NewVar}, i.e. + the one that holds the object's representation defined by its C + type structure, *excluding* any object-specific memory buffers that + might be referenced by the structure (for type structures that have + pointer fields). By default, the object memory allocator is + implemented on top of the raw memory allocator. + + The PyCore_* macros can be defined to make the interpreter use a + custom object memory allocator. They are reserved for internal + memory management purposes exclusively. Both the core and extension + modules should use the PyObject_* API. */ + + #ifndef PyCore_OBJECT_MALLOC_FUNC + #undef PyCore_OBJECT_REALLOC_FUNC + #undef PyCore_OBJECT_FREE_FUNC + #define PyCore_OBJECT_MALLOC_FUNC PyCore_MALLOC_FUNC + #define PyCore_OBJECT_REALLOC_FUNC PyCore_REALLOC_FUNC + #define PyCore_OBJECT_FREE_FUNC PyCore_FREE_FUNC + #endif + + #ifndef PyCore_OBJECT_MALLOC_PROTO + #undef PyCore_OBJECT_REALLOC_PROTO + #undef PyCore_OBJECT_FREE_PROTO + #define PyCore_OBJECT_MALLOC_PROTO PyCore_MALLOC_PROTO + #define PyCore_OBJECT_REALLOC_PROTO PyCore_REALLOC_PROTO + #define PyCore_OBJECT_FREE_PROTO PyCore_FREE_PROTO + #endif + + #ifdef NEED_TO_DECLARE_OBJECT_MALLOC_AND_FRIEND + extern ANY *PyCore_OBJECT_MALLOC_FUNC PyCore_OBJECT_MALLOC_PROTO; + extern ANY *PyCore_OBJECT_REALLOC_FUNC PyCore_OBJECT_REALLOC_PROTO; + extern void PyCore_OBJECT_FREE_FUNC PyCore_OBJECT_FREE_PROTO; + #endif + + #ifndef PyCore_OBJECT_MALLOC + #undef PyCore_OBJECT_REALLOC + #undef PyCore_OBJECT_FREE + #define PyCore_OBJECT_MALLOC(n) PyCore_OBJECT_MALLOC_FUNC(n) + #define PyCore_OBJECT_REALLOC(p, n) PyCore_OBJECT_REALLOC_FUNC((p), (n)) + #define PyCore_OBJECT_FREE(p) PyCore_OBJECT_FREE_FUNC(p) + #endif ! /* ! * Raw object memory interface ! * =========================== ! */ ! ! /* The use of this API should be avoided, unless a builtin object ! constructor inlines PyObject_{New, NewVar}, either because the ! latter functions cannot allocate the exact amount of needed memory, ! either for speed. This situation is exceptional, but occurs for ! some object constructors (PyBuffer_New, PyList_New...). Inlining ! PyObject_{New, NewVar} for objects that are supposed to belong to ! the Python heap is discouraged. If you really have to, make sure ! the object is initialized with PyObject_{Init, InitVar}. Do *not* ! inline PyObject_{Init, InitVar} for user-extension types or you ! might seriously interfere with Python's memory management. */ ! ! /* Functions */ ! ! /* Wrappers around PyCore_OBJECT_MALLOC and friends; useful if you ! need to be sure that you are using the same object memory allocator ! as Python. These wrappers *do not* make sure that allocating 0 ! bytes returns a non-NULL pointer. Returned pointers must be checked ! for NULL explicitly; no action is performed on failure. */ ! extern DL_IMPORT(ANY *) PyObject_Malloc Py_PROTO((size_t)); ! extern DL_IMPORT(ANY *) PyObject_Realloc Py_PROTO((ANY *, size_t)); ! extern DL_IMPORT(void) PyObject_Free Py_PROTO((ANY *)); ! ! /* Macros */ ! #define PyObject_MALLOC(n) PyCore_OBJECT_MALLOC(n) ! #define PyObject_REALLOC(op, n) PyCore_OBJECT_REALLOC((ANY *)(op), (n)) ! #define PyObject_FREE(op) PyCore_OBJECT_FREE((ANY *)(op)) ! /* ! * Generic object allocator interface ! * ================================== ! */ ! ! /* Functions */ ! extern DL_IMPORT(PyObject *) PyObject_Init Py_PROTO((PyObject *, PyTypeObject *)); ! extern DL_IMPORT(PyVarObject *) PyObject_InitVar Py_PROTO((PyVarObject *, PyTypeObject *, int)); extern DL_IMPORT(PyObject *) _PyObject_New Py_PROTO((PyTypeObject *)); extern DL_IMPORT(PyVarObject *) _PyObject_NewVar Py_PROTO((PyTypeObject *, int)); ! extern DL_IMPORT(void) _PyObject_Del Py_PROTO((PyObject *)); ! #define PyObject_New(type, typeobj) \ ! ( (type *) _PyObject_New(typeobj) ) ! #define PyObject_NewVar(type, typeobj, n) \ ! ( (type *) _PyObject_NewVar((typeobj), (n)) ) ! #define PyObject_Del(op) _PyObject_Del((PyObject *)(op)) ! ! /* Macros trading binary compatibility for speed. See also mymalloc.h. ! Note that these macros expect non-NULL object pointers.*/ ! #define PyObject_INIT(op, typeobj) \ ! ( (op)->ob_type = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) ! #define PyObject_INIT_VAR(op, typeobj, size) \ ! ( (op)->ob_size = (size), PyObject_INIT((op), (typeobj)) ) ! ! #define _PyObject_SIZE(typeobj) ( (typeobj)->tp_basicsize ) ! #define _PyObject_VAR_SIZE(typeobj, n) \ ! ( (typeobj)->tp_basicsize + (n) * (typeobj)->tp_itemsize ) ! ! #define PyObject_NEW(type, typeobj) \ ! ( (type *) PyObject_Init( \ ! (PyObject *) PyObject_MALLOC( _PyObject_SIZE(typeobj) ), (typeobj)) ) ! #define PyObject_NEW_VAR(type, typeobj, n) \ ! ( (type *) PyObject_InitVar( \ ! (PyVarObject *) PyObject_MALLOC( _PyObject_VAR_SIZE((typeobj),(n)) ),\ ! (typeobj), (n)) ) ! #define PyObject_DEL(op) PyObject_FREE(op) ! ! /* This example code implements an object constructor with a custom ! allocator, where PyObject_New is inlined, and shows the important ! distinction between two steps (at least): ! 1) the actual allocation of the object storage; ! 2) the initialization of the Python specific fields ! in this storage with PyObject_{Init, InitVar}. ! ! PyObject * ! YourObject_New(...) ! { ! PyObject *op; ! ! op = (PyObject *) Your_Allocator(_PyObject_SIZE(YourTypeStruct)); ! if (op == NULL) ! return PyErr_NoMemory(); ! ! op = PyObject_Init(op, &YourTypeStruct); ! if (op == NULL) ! return NULL; ! ! op->ob_field = value; ! ... ! return op; ! } ! ! Note that in C++, the use of the new operator usually implies that ! the 1st step is performed automatically for you, so in a C++ class ! constructor you would start directly with PyObject_Init/InitVar. */ #ifdef __cplusplus From python-dev@python.org Thu May 4 00:45:09 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 3 May 2000 19:45:09 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/PC winreg.c,1.1,1.2 Message-ID: <200005032345.TAA06577@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/PC In directory eric:/projects/python/develop/guido/clean/PC Modified Files: winreg.c Log Message: Vladimir Marangozov's long-awaited malloc restructuring. For more comments, read the patches@python.org archives. For documentation read the comments in mymalloc.h and objimpl.h. (This is not exactly what Vladimir posted to the patches list; I've made a few changes, and Vladimir sent me a fix in private email for a problem that only occurs in debug mode. I'm also holding back on his change to main.c, which seems unnecessary to me.) Index: winreg.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/PC/winreg.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** winreg.c 2000/03/28 20:37:15 1.1 --- winreg.c 2000/05/03 23:44:37 1.2 *************** *** 371,375 **** if (obkey->hkey) RegCloseKey((HKEY)obkey->hkey); ! PyMem_DEL(ob); } --- 371,375 ---- if (obkey->hkey) RegCloseKey((HKEY)obkey->hkey); ! PyObject_DEL(ob); } *************** *** 605,614 **** PyHKEY_FromHKEY(HKEY h) { ! PyHKEYObject *op = (PyHKEYObject *) malloc(sizeof(PyHKEYObject)); if (op == NULL) return PyErr_NoMemory(); ! op->ob_type = &PyHKEY_Type; op->hkey = h; - _Py_NewReference((PyObject *)op); return (PyObject *)op; } --- 605,616 ---- PyHKEY_FromHKEY(HKEY h) { ! PyHKEYObject *op; ! ! /* PyObject_New is inlined */ ! op = (PyHKEYObject *) PyObject_MALLOC(sizeof(PyHKEYObject)); if (op == NULL) return PyErr_NoMemory(); ! PyObject_INIT(op, &PyHKEY_Type); op->hkey = h; return (PyObject *)op; } *************** *** 1349,1353 **** rc = RegSetValueEx(hKey, valueName, 0, typ, data, len); Py_END_ALLOW_THREADS ! PyMem_Free(data); if (rc != ERROR_SUCCESS) return PyErr_SetFromWindowsErrWithFunction(rc, --- 1351,1355 ---- rc = RegSetValueEx(hKey, valueName, 0, typ, data, len); Py_END_ALLOW_THREADS ! PyMem_DEL(data); if (rc != ERROR_SUCCESS) return PyErr_SetFromWindowsErrWithFunction(rc, From python-dev@python.org Thu May 4 00:45:11 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 3 May 2000 19:45:11 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Parser myreadline.c,2.16,2.17 parsetok.c,2.15,2.16 pgenmain.c,2.15,2.16 tokenizer.c,2.40,2.41 Message-ID: <200005032345.TAA06612@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Parser In directory eric:/projects/python/develop/guido/clean/Parser Modified Files: myreadline.c parsetok.c pgenmain.c tokenizer.c Log Message: Vladimir Marangozov's long-awaited malloc restructuring. For more comments, read the patches@python.org archives. For documentation read the comments in mymalloc.h and objimpl.h. (This is not exactly what Vladimir posted to the patches list; I've made a few changes, and Vladimir sent me a fix in private email for a problem that only occurs in debug mode. I'm also holding back on his change to main.c, which seems unnecessary to me.) Index: myreadline.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Parser/myreadline.c,v retrieving revision 2.16 retrieving revision 2.17 diff -C2 -r2.16 -r2.17 *** myreadline.c 1998/08/29 16:03:27 2.16 --- myreadline.c 2000/05/03 23:44:37 2.17 *************** *** 90,94 **** char *p; n = 100; ! if ((p = malloc(n)) == NULL) return NULL; fflush(stdout); --- 90,94 ---- char *p; n = 100; ! if ((p = PyMem_MALLOC(n)) == NULL) return NULL; fflush(stdout); *************** *** 100,104 **** break; case 1: /* Interrupt */ ! free(p); return NULL; case -1: /* EOF */ --- 100,104 ---- break; case 1: /* Interrupt */ ! PyMem_FREE(p); return NULL; case -1: /* EOF */ *************** *** 118,122 **** while (n > 0 && p[n-1] != '\n') { int incr = n+2; ! p = realloc(p, n + incr); if (p == NULL) return NULL; --- 118,122 ---- while (n > 0 && p[n-1] != '\n') { int incr = n+2; ! p = PyMem_REALLOC(p, n + incr); if (p == NULL) return NULL; *************** *** 125,134 **** n += strlen(p+n); } ! return realloc(p, n+1); } /* By initializing this function pointer, systems embedding Python can ! override the readline function. */ char *(*PyOS_ReadlineFunctionPointer) Py_PROTO((char *)); --- 125,136 ---- n += strlen(p+n); } ! return PyMem_REALLOC(p, n+1); } /* By initializing this function pointer, systems embedding Python can ! override the readline function. ! ! Note: Python expects in return a buffer allocated with PyMem_Malloc. */ char *(*PyOS_ReadlineFunctionPointer) Py_PROTO((char *)); Index: parsetok.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Parser/parsetok.c,v retrieving revision 2.15 retrieving revision 2.16 diff -C2 -r2.15 -r2.16 *** parsetok.c 1998/12/21 18:32:40 2.15 --- parsetok.c 2000/05/03 23:44:37 2.16 *************** *** 193,197 **** if (tok->buf != NULL) { int len = tok->inp - tok->buf; ! err_ret->text = malloc(len + 1); if (err_ret->text != NULL) { if (len > 0) --- 193,197 ---- if (tok->buf != NULL) { int len = tok->inp - tok->buf; ! err_ret->text = PyMem_NEW(char, len + 1); if (err_ret->text != NULL) { if (len > 0) Index: pgenmain.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Parser/pgenmain.c,v retrieving revision 2.15 retrieving revision 2.16 diff -C2 -r2.15 -r2.16 *** pgenmain.c 1998/08/25 18:12:36 2.15 --- pgenmain.c 2000/05/03 23:44:37 2.16 *************** *** 140,144 **** } fprintf(stderr, "^\n"); ! free(err.text); } Py_Exit(1); --- 140,144 ---- } fprintf(stderr, "^\n"); ! PyMem_DEL(err.text); } Py_Exit(1); *************** *** 197,201 **** { int n = 1000; ! char *p = malloc(n); char *q; if (p == NULL) --- 197,201 ---- { int n = 1000; ! char *p = PyMem_MALLOC(n); char *q; if (p == NULL) *************** *** 210,214 **** if (n > 0 && p[n-1] != '\n') p[n-1] = '\n'; ! return realloc(p, n+1); } --- 210,214 ---- if (n > 0 && p[n-1] != '\n') p[n-1] = '\n'; ! return PyMem_REALLOC(p, n+1); } Index: tokenizer.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Parser/tokenizer.c,v retrieving revision 2.40 retrieving revision 2.41 diff -C2 -r2.40 -r2.41 *** tokenizer.c 2000/04/03 23:02:17 2.40 --- tokenizer.c 2000/05/03 23:44:37 2.41 *************** *** 220,224 **** tok->done = E_INTR; else if (*new == '\0') { ! free(new); tok->done = E_EOF; } --- 220,224 ---- tok->done = E_INTR; else if (*new == '\0') { ! PyMem_FREE(new); tok->done = E_EOF; } *************** *** 227,236 **** int oldlen = tok->cur - tok->buf; int newlen = oldlen + strlen(new); ! char *buf = realloc(tok->buf, newlen+1); tok->lineno++; if (buf == NULL) { ! free(tok->buf); tok->buf = NULL; ! free(new); tok->done = E_NOMEM; return EOF; --- 227,237 ---- int oldlen = tok->cur - tok->buf; int newlen = oldlen + strlen(new); ! char *buf = tok->buf; ! PyMem_RESIZE(buf, char, newlen+1); tok->lineno++; if (buf == NULL) { ! PyMem_DEL(tok->buf); tok->buf = NULL; ! PyMem_FREE(new); tok->done = E_NOMEM; return EOF; *************** *** 239,243 **** tok->cur = tok->buf + oldlen; strcpy(tok->buf + oldlen, new); ! free(new); tok->inp = tok->buf + newlen; tok->end = tok->inp + 1; --- 240,244 ---- tok->cur = tok->buf + oldlen; strcpy(tok->buf + oldlen, new); ! PyMem_FREE(new); tok->inp = tok->buf + newlen; tok->end = tok->inp + 1; *************** *** 247,251 **** tok->lineno++; if (tok->buf != NULL) ! free(tok->buf); tok->buf = new; tok->cur = tok->buf; --- 248,252 ---- tok->lineno++; if (tok->buf != NULL) ! PyMem_DEL(tok->buf); tok->buf = new; tok->cur = tok->buf; From python-dev@python.org Thu May 4 00:45:13 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 3 May 2000 19:45:13 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.2,2.3 _tkinter.c,1.96,1.97 almodule.c,1.23,1.24 arraymodule.c,2.38,2.39 bsddbmodule.c,1.17,1.18 cPickle.c,2.40,2.41 cStringIO.c,2.19,2.20 cdmodule.c,1.18,1.19 clmodule.c,2.19,2.20 cursesmodule.c,2.19,2.20 dbmmodule.c,2.16,2.17 dlmodule.c,2.6,2.7 flmodule.c,1.35,1.36 fmmodule.c,1.10,1.11 gdbmmodule.c,2.21,2.22 getpath.c,1.20,1.21 linuxaudiodev.c,2.1,2.2 md5module.c,2.14,2.15 mmapmodule.c,2.7,2.8 mpzmodule.c,2.22,2.23 newmodule.c,2.19,2.20 nismodule.c,2.15,2.16 parsermodule.c,2.38,2.39 pcremodule.c,2.18,2.19 pyexpat.c,2.3,2.4 readline.c,2.16,2.17 regexmodule.c,1.33,1.34 rotormodule.c,2.22,2.23 selectmodule.c,2.31,2.32 shamodule.c,2.4,2.5 socketmodule.c,1.106,1.107 stropmodule.c,2.62,2.63 sunaudiodev.c,1.16,1.17 svmodule.c,2.10,2.11 threadmodule.c,2.30,2.31 xxmodule.c,2.15,2.16 zlibmodule.c,2.31,2.32 Message-ID: <200005032345.TAA06649@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Modules In directory eric:/projects/python/develop/guido/clean/Modules Modified Files: _sre.c _tkinter.c almodule.c arraymodule.c bsddbmodule.c cPickle.c cStringIO.c cdmodule.c clmodule.c cursesmodule.c dbmmodule.c dlmodule.c flmodule.c fmmodule.c gdbmmodule.c getpath.c linuxaudiodev.c md5module.c mmapmodule.c mpzmodule.c newmodule.c nismodule.c parsermodule.c pcremodule.c pyexpat.c readline.c regexmodule.c rotormodule.c selectmodule.c shamodule.c socketmodule.c stropmodule.c sunaudiodev.c svmodule.c threadmodule.c xxmodule.c zlibmodule.c Log Message: Vladimir Marangozov's long-awaited malloc restructuring. For more comments, read the patches@python.org archives. For documentation read the comments in mymalloc.h and objimpl.h. (This is not exactly what Vladimir posted to the patches list; I've made a few changes, and Vladimir sent me a fix in private email for a problem that only occurs in debug mode. I'm also holding back on his change to main.c, which seems unnecessary to me.) Index: _sre.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/_sre.c,v retrieving revision 2.2 retrieving revision 2.3 diff -C2 -r2.2 -r2.3 *** _sre.c 2000/04/10 17:06:55 2.2 --- _sre.c 2000/05/03 23:44:30 2.3 *************** *** 2,6 **** * * Secret Labs' Regular Expression Engine ! * $Id: _sre.c,v 2.2 2000/04/10 17:06:55 guido Exp $ * * simple regular expression matching engine --- 2,6 ---- * * Secret Labs' Regular Expression Engine ! * $Id: _sre.c,v 2.3 2000/05/03 23:44:30 guido Exp $ * * simple regular expression matching engine *************** *** 849,853 **** return NULL; ! self = PyObject_NEW(PatternObject, &Pattern_Type); if (self == NULL) return NULL; --- 849,853 ---- return NULL; ! self = PyObject_New(PatternObject, &Pattern_Type); if (self == NULL) return NULL; *************** *** 887,891 **** /* create match object (with room for extra group marks) */ ! match = PyObject_NEW_VAR(MatchObject, &Match_Type, 2*pattern->groups); if (match == NULL) return NULL; --- 887,891 ---- /* create match object (with room for extra group marks) */ ! match = PyObject_NewVar(MatchObject, &Match_Type, 2*pattern->groups); if (match == NULL) return NULL; *************** *** 1003,1007 **** Py_XDECREF(self->pattern); Py_XDECREF(self->groupindex); ! PyMem_DEL(self); } --- 1003,1007 ---- Py_XDECREF(self->pattern); Py_XDECREF(self->groupindex); ! PyObject_Del(self); } *************** *** 1164,1168 **** Py_XDECREF(self->string); Py_DECREF(self->pattern); ! PyMem_DEL(self); } --- 1164,1168 ---- Py_XDECREF(self->string); Py_DECREF(self->pattern); ! PyObject_Del(self); } Index: _tkinter.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/_tkinter.c,v retrieving revision 1.96 retrieving revision 1.97 diff -C2 -r1.96 -r1.97 *** _tkinter.c 2000/04/27 20:14:31 1.96 --- _tkinter.c 2000/05/03 23:44:31 1.97 *************** *** 470,474 **** char *argv0; ! v = PyObject_NEW(TkappObject, &Tkapp_Type); if (v == NULL) return NULL; --- 470,474 ---- char *argv0; ! v = PyObject_New(TkappObject, &Tkapp_Type); if (v == NULL) return NULL; *************** *** 1641,1645 **** TkttObject *v; ! v = PyObject_NEW(TkttObject, &Tktt_Type); if (v == NULL) return NULL; --- 1641,1645 ---- TkttObject *v; ! v = PyObject_New(TkttObject, &Tktt_Type); if (v == NULL) return NULL; *************** *** 1663,1667 **** Py_XDECREF(func); ! PyMem_DEL(self); } --- 1663,1667 ---- Py_XDECREF(func); ! PyObject_Del(self); } *************** *** 1911,1915 **** Tcl_DeleteInterp(Tkapp_Interp(self)); LEAVE_TCL ! PyMem_DEL(self); DisableEventHook(); } --- 1911,1915 ---- Tcl_DeleteInterp(Tkapp_Interp(self)); LEAVE_TCL ! PyObject_Del(self); DisableEventHook(); } Index: almodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/almodule.c,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** almodule.c 2000/02/29 13:59:22 1.23 --- almodule.c 2000/05/03 23:44:31 1.24 *************** *** 649,653 **** alcobject *self; ! self = PyObject_NEW(alcobject, &Alctype); if (self == NULL) return NULL; --- 649,653 ---- alcobject *self; ! self = PyObject_New(alcobject, &Alctype); if (self == NULL) return NULL; *************** *** 668,672 **** (void) ALfreeconfig(self->config); /* ignore errors */ #endif ! PyMem_DEL(self); } --- 668,672 ---- (void) ALfreeconfig(self->config); /* ignore errors */ #endif ! PyObject_Del(self); } *************** *** 1422,1426 **** alpobject *self; ! self = PyObject_NEW(alpobject, &Alptype); if (self == NULL) return NULL; --- 1422,1426 ---- alpobject *self; ! self = PyObject_New(alpobject, &Alptype); if (self == NULL) return NULL; *************** *** 1443,1447 **** #endif } ! PyMem_DEL(self); } --- 1443,1447 ---- #endif } ! PyObject_Del(self); } Index: arraymodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/arraymodule.c,v retrieving revision 2.38 retrieving revision 2.39 diff -C2 -r2.38 -r2.39 *** arraymodule.c 2000/02/04 20:33:49 2.38 --- arraymodule.c 2000/05/03 23:44:31 2.39 *************** *** 347,351 **** return PyErr_NoMemory(); } ! op = PyMem_NEW(arrayobject, 1); if (op == NULL) { return PyErr_NoMemory(); --- 347,351 ---- return PyErr_NoMemory(); } ! op = PyObject_NewVar(arrayobject, &Arraytype, size); if (op == NULL) { return PyErr_NoMemory(); *************** *** 357,368 **** op->ob_item = PyMem_NEW(char, nbytes); if (op->ob_item == NULL) { ! PyMem_DEL(op); return PyErr_NoMemory(); } } - op->ob_type = &Arraytype; - op->ob_size = size; op->ob_descr = descr; - _Py_NewReference((PyObject *)op); return (PyObject *) op; } --- 357,365 ---- op->ob_item = PyMem_NEW(char, nbytes); if (op->ob_item == NULL) { ! PyObject_Del(op); return PyErr_NoMemory(); } } op->ob_descr = descr; return (PyObject *) op; } *************** *** 467,471 **** if (op->ob_item != NULL) PyMem_DEL(op->ob_item); ! PyMem_DEL(op); } --- 464,468 ---- if (op->ob_item != NULL) PyMem_DEL(op->ob_item); ! PyObject_Del(op); } Index: bsddbmodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/bsddbmodule.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** bsddbmodule.c 2000/02/29 13:59:22 1.17 --- bsddbmodule.c 2000/05/03 23:44:31 1.18 *************** *** 90,94 **** HASHINFO info; ! if ((dp = PyObject_NEW(bsddbobject, &Bsddbtype)) == NULL) return NULL; --- 90,94 ---- HASHINFO info; ! if ((dp = PyObject_New(bsddbobject, &Bsddbtype)) == NULL) return NULL; *************** *** 144,148 **** BTREEINFO info; ! if ((dp = PyObject_NEW(bsddbobject, &Bsddbtype)) == NULL) return NULL; --- 144,148 ---- BTREEINFO info; ! if ((dp = PyObject_New(bsddbobject, &Bsddbtype)) == NULL) return NULL; *************** *** 201,205 **** RECNOINFO info; ! if ((dp = PyObject_NEW(bsddbobject, &Bsddbtype)) == NULL) return NULL; --- 201,205 ---- RECNOINFO info; ! if ((dp = PyObject_New(bsddbobject, &Bsddbtype)) == NULL) return NULL; *************** *** 262,266 **** errno); } ! PyMem_DEL(dp); } --- 262,266 ---- errno); } ! PyObject_Del(dp); } Index: cPickle.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/cPickle.c,v retrieving revision 2.40 retrieving revision 2.41 diff -C2 -r2.40 -r2.41 *** cPickle.c 2000/04/21 20:49:36 2.40 --- cPickle.c 2000/05/03 23:44:31 2.41 *************** *** 172,176 **** if (self->data) free(self->data); ! PyMem_DEL(self); } --- 172,176 ---- if (self->data) free(self->data); ! PyObject_Del(self); } *************** *** 187,191 **** Pdata *self; ! UNLESS (self = PyObject_NEW(Pdata, &PdataType)) return NULL; self->size=8; self->length=0; --- 187,191 ---- Pdata *self; ! UNLESS (self = PyObject_New(Pdata, &PdataType)) return NULL; self->size=8; self->length=0; *************** *** 2133,2137 **** Picklerobject *self; ! UNLESS (self = PyObject_NEW(Picklerobject, &Picklertype)) return NULL; --- 2133,2137 ---- Picklerobject *self; ! UNLESS (self = PyObject_New(Picklerobject, &Picklertype)) return NULL; *************** *** 2244,2248 **** } ! PyMem_DEL(self); } --- 2244,2248 ---- } ! PyObject_Del(self); } *************** *** 2886,2890 **** PyErr_Clear(); ! UNLESS (inst=PyObject_NEW(PyInstanceObject, &PyInstance_Type)) goto err; inst->in_class=(PyClassObject*)cls; --- 2886,2890 ---- PyErr_Clear(); ! UNLESS (inst=PyObject_New(PyInstanceObject, &PyInstance_Type)) goto err; inst->in_class=(PyClassObject*)cls; *************** *** 4037,4041 **** Unpicklerobject *self; ! UNLESS (self = PyObject_NEW(Unpicklerobject, &Unpicklertype)) return NULL; --- 4037,4041 ---- Unpicklerobject *self; ! UNLESS (self = PyObject_New(Unpicklerobject, &Unpicklertype)) return NULL; *************** *** 4142,4146 **** } ! PyMem_DEL(self); } --- 4142,4146 ---- } ! PyObject_Del(self); } Index: cStringIO.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/cStringIO.c,v retrieving revision 2.19 retrieving revision 2.20 diff -C2 -r2.19 -r2.20 *** cStringIO.c 2000/04/12 22:04:01 2.19 --- cStringIO.c 2000/05/03 23:44:31 2.20 *************** *** 57,61 **** "This module provides a simple useful replacement for\n" "the StringIO module that is written in C. It does not provide the\n" ! "full generality if StringIO, but it provides anough for most\n" "applications and is especially useful in conjuction with the\n" "pickle module.\n" --- 57,61 ---- "This module provides a simple useful replacement for\n" "the StringIO module that is written in C. It does not provide the\n" ! "full generality if StringIO, but it provides enough for most\n" "applications and is especially useful in conjuction with the\n" "pickle module.\n" *************** *** 408,412 **** if (self->buf != NULL) free(self->buf); ! PyMem_DEL(self); } --- 408,412 ---- if (self->buf != NULL) free(self->buf); ! PyObject_Del(self); } *************** *** 466,470 **** Oobject *self; ! self = PyObject_NEW(Oobject, &Otype); if (self == NULL) return NULL; --- 466,470 ---- Oobject *self; ! self = PyObject_New(Oobject, &Otype); if (self == NULL) return NULL; *************** *** 537,541 **** I_dealloc(Iobject *self) { Py_XDECREF(self->pbuf); ! PyMem_DEL(self); } --- 537,541 ---- I_dealloc(Iobject *self) { Py_XDECREF(self->pbuf); ! PyObject_Del(self); } *************** *** 587,591 **** buf = PyString_AS_STRING(s); size = PyString_GET_SIZE(s); ! UNLESS(self = PyObject_NEW(Iobject, &Itype)) return NULL; Py_INCREF(s); self->buf=buf; --- 587,591 ---- buf = PyString_AS_STRING(s); size = PyString_GET_SIZE(s); ! UNLESS(self = PyObject_New(Iobject, &Itype)) return NULL; Py_INCREF(s); self->buf=buf; Index: cdmodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/cdmodule.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** cdmodule.c 2000/02/29 13:59:23 1.18 --- cdmodule.c 2000/05/03 23:44:31 1.19 *************** *** 448,452 **** if (self->ob_cdplayer != NULL) CDclose(self->ob_cdplayer); ! PyMem_DEL(self); } --- 448,452 ---- if (self->ob_cdplayer != NULL) CDclose(self->ob_cdplayer); ! PyObject_Del(self); } *************** *** 484,488 **** cdplayerobject *p; ! p = PyObject_NEW(cdplayerobject, &CdPlayertype); if (p == NULL) return NULL; --- 484,488 ---- cdplayerobject *p; ! p = PyObject_New(cdplayerobject, &CdPlayertype); if (p == NULL) return NULL; *************** *** 762,766 **** } CDdeleteparser(self->ob_cdparser); ! PyMem_DEL(self); } --- 762,766 ---- } CDdeleteparser(self->ob_cdparser); ! PyObject_Del(self); } *************** *** 800,804 **** int i; ! p = PyObject_NEW(cdparserobject, &CdParsertype); if (p == NULL) return NULL; --- 800,804 ---- int i; ! p = PyObject_New(cdparserobject, &CdParsertype); if (p == NULL) return NULL; Index: clmodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/clmodule.c,v retrieving revision 2.19 retrieving revision 2.20 diff -C2 -r2.19 -r2.20 *** clmodule.c 1997/10/08 15:26:28 2.19 --- clmodule.c 2000/05/03 23:44:31 2.20 *************** *** 674,678 **** clCloseDecompressor(SELF->ob_compressorHdl); } ! PyMem_DEL(self); } --- 674,678 ---- clCloseDecompressor(SELF->ob_compressorHdl); } ! PyObject_Del(self); } *************** *** 714,718 **** return NULL; ! new = PyObject_NEW(clobject, &Cltype); if (new == NULL) return NULL; --- 714,718 ---- return NULL; ! new = PyObject_New(clobject, &Cltype); if (new == NULL) return NULL; Index: cursesmodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/cursesmodule.c,v retrieving revision 2.19 retrieving revision 2.20 diff -C2 -r2.19 -r2.20 *** cursesmodule.c 1999/01/05 17:16:46 2.19 --- cursesmodule.c 2000/05/03 23:44:31 2.20 *************** *** 274,278 **** PyFileObject *out_fo; PyCursesScreenObject *xp; ! xp = PyObject_NEW(PyCursesScreenObject, &PyCursesScreen_Type); if (xp == NULL) return NULL; --- 274,278 ---- PyFileObject *out_fo; PyCursesScreenObject *xp; ! xp = PyObject_New(PyCursesScreenObject, &PyCursesScreen_Type); if (xp == NULL) return NULL; *************** *** 290,294 **** PyCursesWindowObject *wo; ! wo = PyObject_NEW(PyCursesWindowObject, &PyCursesWindow_Type); if (wo == NULL) return NULL; --- 290,294 ---- PyCursesWindowObject *wo; ! wo = PyObject_New(PyCursesWindowObject, &PyCursesWindow_Type); if (wo == NULL) return NULL; *************** *** 304,308 **** if (wo->win != stdscr) delwin(wo->win); ! PyMem_DEL(wo); } --- 304,308 ---- if (wo->win != stdscr) delwin(wo->win); ! PyObject_Del(wo); } *************** *** 1126,1130 **** { PyCursesPadObject *po; ! po = PyObject_NEW(PyCursesPadObject, &PyCursesPad_Type); if (po == NULL) return NULL; --- 1126,1130 ---- { PyCursesPadObject *po; ! po = PyObject_New(PyCursesPadObject, &PyCursesPad_Type); if (po == NULL) return NULL; Index: dbmmodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/dbmmodule.c,v retrieving revision 2.16 retrieving revision 2.17 diff -C2 -r2.16 -r2.17 *** dbmmodule.c 2000/02/29 13:59:23 2.16 --- dbmmodule.c 2000/05/03 23:44:32 2.17 *************** *** 63,67 **** dbmobject *dp; ! dp = PyObject_NEW(dbmobject, &Dbmtype); if (dp == NULL) return NULL; --- 63,67 ---- dbmobject *dp; ! dp = PyObject_New(dbmobject, &Dbmtype); if (dp == NULL) return NULL; *************** *** 83,87 **** if ( dp->di_dbm ) dbm_close(dp->di_dbm); ! PyMem_DEL(dp); } --- 83,87 ---- if ( dp->di_dbm ) dbm_close(dp->di_dbm); ! PyObject_Del(dp); } Index: dlmodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/dlmodule.c,v retrieving revision 2.6 retrieving revision 2.7 diff -C2 -r2.6 -r2.7 *** dlmodule.c 1997/12/16 23:58:15 2.6 --- dlmodule.c 2000/05/03 23:44:32 2.7 *************** *** 55,59 **** { dlobject *xp; ! xp = PyObject_NEW(dlobject, &Dltype); if (xp == NULL) return NULL; --- 55,59 ---- { dlobject *xp; ! xp = PyObject_New(dlobject, &Dltype); if (xp == NULL) return NULL; *************** *** 68,72 **** if (xp->dl_handle != NULL) dlclose(xp->dl_handle); ! PyMem_DEL(xp); } --- 68,72 ---- if (xp->dl_handle != NULL) dlclose(xp->dl_handle); ! PyObject_Del(xp); } Index: flmodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/flmodule.c,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -r1.35 -r1.36 *** flmodule.c 1998/12/04 18:49:46 1.35 --- flmodule.c 2000/05/03 23:44:32 1.36 *************** *** 333,337 **** Py_XDECREF(g->ob_callback); Py_XDECREF(g->ob_callback_arg); ! PyMem_DEL(g); } --- 333,337 ---- Py_XDECREF(g->ob_callback); Py_XDECREF(g->ob_callback_arg); ! PyObject_Del(g); } *************** *** 462,466 **** { genericobject *g; ! g = PyObject_NEW(genericobject, &GenericObjecttype); if (g == NULL) return NULL; --- 462,466 ---- { genericobject *g; ! g = PyObject_New(genericobject, &GenericObjecttype); if (g == NULL) return NULL; *************** *** 1853,1857 **** fl_hide_form(f->ob_form); fl_free_form(f->ob_form); ! PyMem_DEL(f); } --- 1853,1857 ---- fl_hide_form(f->ob_form); fl_free_form(f->ob_form); ! PyObject_Del(f); } *************** *** 1932,1936 **** { formobject *f; ! f = PyObject_NEW(formobject, &Formtype); if (f == NULL) return NULL; --- 1932,1936 ---- { formobject *f; ! f = PyObject_New(formobject, &Formtype); if (f == NULL) return NULL; Index: fmmodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/fmmodule.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** fmmodule.c 1997/01/17 16:08:55 1.10 --- fmmodule.c 2000/05/03 23:44:32 1.11 *************** *** 60,64 **** return NULL; } ! fhp = PyObject_NEW(fhobject, &Fhtype); if (fhp == NULL) return NULL; --- 60,64 ---- return NULL; } ! fhp = PyObject_New(fhobject, &Fhtype); if (fhp == NULL) return NULL; *************** *** 197,201 **** { fmfreefont(fhp->fh_fh); ! PyMem_DEL(fhp); } --- 197,201 ---- { fmfreefont(fhp->fh_fh); ! PyObject_Del(fhp); } Index: gdbmmodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/gdbmmodule.c,v retrieving revision 2.21 retrieving revision 2.22 diff -C2 -r2.21 -r2.22 *** gdbmmodule.c 2000/02/29 13:59:23 2.21 --- gdbmmodule.c 2000/05/03 23:44:32 2.22 *************** *** 94,98 **** dbmobject *dp; ! dp = PyObject_NEW(dbmobject, &Dbmtype); if (dp == NULL) return NULL; --- 94,98 ---- dbmobject *dp; ! dp = PyObject_New(dbmobject, &Dbmtype); if (dp == NULL) return NULL; *************** *** 118,122 **** if ( dp->di_dbm ) gdbm_close(dp->di_dbm); ! PyMem_DEL(dp); } --- 118,122 ---- if ( dp->di_dbm ) gdbm_close(dp->di_dbm); ! PyObject_Del(dp); } Index: getpath.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/getpath.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -r1.20 -r1.21 *** getpath.c 1999/01/27 17:52:00 1.20 --- getpath.c 2000/05/03 23:44:32 1.21 *************** *** 530,534 **** /* This is the only malloc call in this file */ ! buf = malloc(bufsz); if (buf == NULL) { --- 530,534 ---- /* This is the only malloc call in this file */ ! buf = PyMem_Malloc(bufsz); if (buf == NULL) { Index: linuxaudiodev.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/linuxaudiodev.c,v retrieving revision 2.1 retrieving revision 2.2 diff -C2 -r2.1 -r2.2 *** linuxaudiodev.c 2000/03/31 16:56:32 2.1 --- linuxaudiodev.c 2000/05/03 23:44:32 2.2 *************** *** 105,109 **** /* Create and initialize the object */ ! if ((xp = PyObject_NEW(lad_t, &Ladtype)) == NULL) { close(fd); return NULL; --- 105,109 ---- /* Create and initialize the object */ ! if ((xp = PyObject_New(lad_t, &Ladtype)) == NULL) { close(fd); return NULL; *************** *** 119,123 **** { close(xp->x_fd); ! PyMem_DEL(xp); } --- 119,123 ---- { close(xp->x_fd); ! PyObject_Del(xp); } Index: md5module.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/md5module.c,v retrieving revision 2.14 retrieving revision 2.15 diff -C2 -r2.14 -r2.15 *** md5module.c 2000/02/29 13:59:23 2.14 --- md5module.c 2000/05/03 23:44:32 2.15 *************** *** 57,61 **** md5object *md5p; ! md5p = PyObject_NEW(md5object, &MD5type); if (md5p == NULL) return NULL; --- 57,61 ---- md5object *md5p; ! md5p = PyObject_New(md5object, &MD5type); if (md5p == NULL) return NULL; *************** *** 72,76 **** md5object *md5p; { ! PyMem_DEL(md5p); } --- 72,76 ---- md5object *md5p; { ! PyObject_Del(md5p); } Index: mmapmodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/mmapmodule.c,v retrieving revision 2.7 retrieving revision 2.8 diff -C2 -r2.7 -r2.8 *** mmapmodule.c 2000/04/10 21:34:37 2.7 --- mmapmodule.c 2000/05/03 23:44:32 2.8 *************** *** 2,6 **** / Author: Sam Rushing / Hacked for Unix by A.M. Kuchling ! / $Id: mmapmodule.c,v 2.7 2000/04/10 21:34:37 guido Exp $ / mmapmodule.cpp -- map a view of a file into memory --- 2,6 ---- / Author: Sam Rushing / Hacked for Unix by A.M. Kuchling ! / $Id: mmapmodule.c,v 2.8 2000/05/03 23:44:32 guido Exp $ / mmapmodule.cpp -- map a view of a file into memory *************** *** 70,74 **** #endif /* UNIX */ ! PyMem_DEL(m_obj); } --- 70,74 ---- #endif /* UNIX */ ! PyObject_Del(m_obj); } *************** *** 707,711 **** return NULL; ! m_obj = PyObject_NEW (mmap_object, &mmap_object_type); if (m_obj == NULL) {return NULL;} m_obj->size = (size_t) map_size; --- 707,711 ---- return NULL; ! m_obj = PyObject_New (mmap_object, &mmap_object_type); if (m_obj == NULL) {return NULL;} m_obj->size = (size_t) map_size; *************** *** 758,762 **** } ! m_obj = PyObject_NEW (mmap_object, &mmap_object_type); if (fh) { --- 758,762 ---- } ! m_obj = PyObject_New (mmap_object, &mmap_object_type); if (fh) { Index: mpzmodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/mpzmodule.c,v retrieving revision 2.22 retrieving revision 2.23 diff -C2 -r2.22 -r2.23 *** mpzmodule.c 2000/02/25 22:23:31 2.22 --- mpzmodule.c 2000/05/03 23:44:32 2.23 *************** *** 124,128 **** fputs( "mpz_object() called...\n", stderr ); #endif /* def MPZ_DEBUG */ ! mpzp = PyObject_NEW(mpzobject, &MPZtype); if (mpzp == NULL) return NULL; --- 124,128 ---- fputs( "mpz_object() called...\n", stderr ); #endif /* def MPZ_DEBUG */ ! mpzp = PyObject_New(mpzobject, &MPZtype); if (mpzp == NULL) return NULL; *************** *** 286,290 **** #endif /* def MPZ_DEBUG */ mpz_clear(&mpzp->mpz); ! PyMem_DEL(mpzp); } /* mpz_dealloc() */ --- 286,290 ---- #endif /* def MPZ_DEBUG */ mpz_clear(&mpzp->mpz); ! PyObject_Del(mpzp); } /* mpz_dealloc() */ Index: newmodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/newmodule.c,v retrieving revision 2.19 retrieving revision 2.20 diff -C2 -r2.19 -r2.20 *** newmodule.c 2000/02/29 13:59:23 2.19 --- newmodule.c 2000/05/03 23:44:32 2.20 *************** *** 50,54 **** &PyDict_Type, &dict)) return NULL; ! inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); if (inst == NULL) return NULL; --- 50,54 ---- &PyDict_Type, &dict)) return NULL; ! inst = PyObject_New(PyInstanceObject, &PyInstance_Type); if (inst == NULL) return NULL; Index: nismodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/nismodule.c,v retrieving revision 2.15 retrieving revision 2.16 diff -C2 -r2.15 -r2.16 *** nismodule.c 2000/02/29 15:52:40 2.15 --- nismodule.c 2000/05/03 23:44:32 2.16 *************** *** 354,362 **** goto finally; ! PyMem_DEL(server); return list->maps; finally: ! PyMem_DEL(server); return NULL; } --- 354,362 ---- goto finally; ! free(server); return list->maps; finally: ! free(server); return NULL; } Index: parsermodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/parsermodule.c,v retrieving revision 2.38 retrieving revision 2.39 diff -C2 -r2.38 -r2.39 *** parsermodule.c 2000/04/25 04:14:46 2.38 --- parsermodule.c 2000/05/03 23:44:32 2.39 *************** *** 296,300 **** parser_newastobject(node *ast, int type) { ! PyAST_Object* o = PyObject_NEW(PyAST_Object, &PyAST_Type); if (o != 0) { --- 296,300 ---- parser_newastobject(node *ast, int type) { ! PyAST_Object* o = PyObject_New(PyAST_Object, &PyAST_Type); if (o != 0) { *************** *** 318,322 **** { PyNode_Free(ast->ast_node); ! PyMem_DEL(ast); } --- 318,322 ---- { PyNode_Free(ast->ast_node); ! PyObject_Del(ast); } *************** *** 791,798 **** /* check_terminal_tuple() already verified it's a string */ ! strn = (char *)malloc(PyString_GET_SIZE(temp) + 1); if (strn != NULL) (void) strcpy(strn, PyString_AS_STRING(temp)); ! Py_XDECREF(temp); if (PyObject_Length(elem) == 3) { --- 791,798 ---- /* check_terminal_tuple() already verified it's a string */ ! strn = (char *)PyMem_MALLOC(PyString_GET_SIZE(temp) + 1); if (strn != NULL) (void) strcpy(strn, PyString_AS_STRING(temp)); ! Py_DECREF(temp); if (PyObject_Length(elem) == 3) { Index: pcremodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/pcremodule.c,v retrieving revision 2.18 retrieving revision 2.19 diff -C2 -r2.18 -r2.19 *** pcremodule.c 2000/04/25 15:59:32 2.18 --- pcremodule.c 2000/05/03 23:44:32 2.19 *************** *** 80,84 **** { PcreObject *self; ! self = PyObject_NEW(PcreObject, &Pcre_Type); if (self == NULL) return NULL; --- 80,84 ---- { PcreObject *self; ! self = PyObject_New(PcreObject, &Pcre_Type); if (self == NULL) return NULL; *************** *** 96,100 **** if (self->regex) (pcre_free)(self->regex); if (self->regex_extra) (pcre_free)(self->regex_extra); ! PyMem_DEL(self); } --- 96,100 ---- if (self->regex) (pcre_free)(self->regex); if (self->regex_extra) (pcre_free)(self->regex_extra); ! PyObject_Del(self); } Index: pyexpat.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/pyexpat.c,v retrieving revision 2.3 retrieving revision 2.4 diff -C2 -r2.3 -r2.4 *** pyexpat.c 2000/04/10 12:46:05 2.3 --- pyexpat.c 2000/05/03 23:44:33 2.4 *************** *** 472,476 **** xmlparseobject *self; ! self = PyObject_NEW(xmlparseobject, &Xmlparsetype); if (self == NULL) return NULL; --- 472,476 ---- xmlparseobject *self; ! self = PyObject_New(xmlparseobject, &Xmlparsetype); if (self == NULL) return NULL; *************** *** 513,517 **** Py_XDECREF( self->handlers[i] ); } ! PyMem_DEL(self); } --- 513,517 ---- Py_XDECREF( self->handlers[i] ); } ! PyObject_Del(self); } *************** *** 684,688 **** initpyexpat(){ PyObject *m, *d; ! char *rev="$Revision: 2.3 $"; PyObject *errors_module, *errors_dict; --- 684,688 ---- initpyexpat(){ PyObject *m, *d; ! char *rev="$Revision: 2.4 $"; PyObject *errors_module, *errors_dict; Index: readline.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/readline.c,v retrieving revision 2.16 retrieving revision 2.17 diff -C2 -r2.16 -r2.17 *** readline.c 2000/02/29 13:59:23 2.16 --- readline.c 2000/05/03 23:44:33 2.17 *************** *** 378,382 **** { int n; ! char *p; RETSIGTYPE (*old_inthandler)(); old_inthandler = signal(SIGINT, onintr); --- 378,382 ---- { int n; ! char *p, *q; RETSIGTYPE (*old_inthandler)(); old_inthandler = signal(SIGINT, onintr); *************** *** 392,397 **** p = readline(prompt); signal(SIGINT, old_inthandler); if (p == NULL) { ! p = malloc(1); if (p != NULL) *p = '\0'; --- 392,399 ---- p = readline(prompt); signal(SIGINT, old_inthandler); + + /* We must return a buffer allocated with PyMem_Malloc. */ if (p == NULL) { ! p = PyMem_Malloc(1); if (p != NULL) *p = '\0'; *************** *** 401,408 **** if (n > 0) add_history(p); ! if ((p = realloc(p, n+2)) != NULL) { p[n] = '\n'; p[n+1] = '\0'; } return p; } --- 403,416 ---- if (n > 0) add_history(p); ! /* Copy the malloc'ed buffer into a PyMem_Malloc'ed one and ! release the original. */ ! q = p; ! p = PyMem_Malloc(n+2); ! if (p != NULL) { ! strncpy(p, q, n); p[n] = '\n'; p[n+1] = '\0'; } + free(q); return p; } Index: regexmodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/regexmodule.c,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -r1.33 -r1.34 *** regexmodule.c 2000/02/29 13:59:23 1.33 --- regexmodule.c 2000/05/03 23:44:33 1.34 *************** *** 65,69 **** regexobject *re; { ! PyMem_XDEL(re->re_patbuf.buffer); Py_XDECREF(re->re_translate); Py_XDECREF(re->re_lastok); --- 65,70 ---- regexobject *re; { ! if (re->re_patbuf.buffer) ! PyMem_DEL(re->re_patbuf.buffer); Py_XDECREF(re->re_translate); Py_XDECREF(re->re_lastok); *************** *** 71,75 **** Py_XDECREF(re->re_givenpat); Py_XDECREF(re->re_realpat); ! PyMem_DEL(re); } --- 72,76 ---- Py_XDECREF(re->re_givenpat); Py_XDECREF(re->re_realpat); ! PyObject_Del(re); } *************** *** 419,423 **** return NULL; } ! re = PyObject_NEW(regexobject, &Regextype); if (re != NULL) { char *error; --- 420,424 ---- return NULL; } ! re = PyObject_New(regexobject, &Regextype); if (re != NULL) { char *error; Index: rotormodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/rotormodule.c,v retrieving revision 2.22 retrieving revision 2.23 diff -C2 -r2.22 -r2.23 *** rotormodule.c 2000/02/29 13:59:23 2.22 --- rotormodule.c 2000/05/03 23:44:33 2.23 *************** *** 179,183 **** Rotorobj *xp; ! xp = PyObject_NEW(Rotorobj, &Rotor_Type); if (xp == NULL) return NULL; --- 179,183 ---- Rotorobj *xp; ! xp = PyObject_New(Rotorobj, &Rotor_Type); if (xp == NULL) return NULL; *************** *** 205,212 **** finally: ! PyMem_XDEL(xp->e_rotor); ! PyMem_XDEL(xp->d_rotor); ! PyMem_XDEL(xp->positions); ! PyMem_XDEL(xp->advances); Py_DECREF(xp); return (Rotorobj*)PyErr_NoMemory(); --- 205,216 ---- finally: ! if (xp->e_rotor) ! PyMem_DEL(xp->e_rotor); ! if (xp->d_rotor) ! PyMem_DEL(xp->d_rotor); ! if (xp->positions) ! PyMem_DEL(xp->positions); ! if (xp->advances) ! PyMem_DEL(xp->advances); Py_DECREF(xp); return (Rotorobj*)PyErr_NoMemory(); *************** *** 474,482 **** Rotorobj *xp; { ! PyMem_XDEL(xp->e_rotor); ! PyMem_XDEL(xp->d_rotor); ! PyMem_XDEL(xp->positions); ! PyMem_XDEL(xp->advances); ! PyMem_DEL(xp); } --- 478,490 ---- Rotorobj *xp; { ! if (xp->e_rotor) ! PyMem_DEL(xp->e_rotor); ! if (xp->d_rotor) ! PyMem_DEL(xp->d_rotor); ! if (xp->positions) ! PyMem_DEL(xp->positions); ! if (xp->advances) ! PyMem_DEL(xp->advances); ! PyObject_Del(xp); } Index: selectmodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/selectmodule.c,v retrieving revision 2.31 retrieving revision 2.32 diff -C2 -r2.31 -r2.32 *** selectmodule.c 2000/02/29 13:59:23 2.31 --- selectmodule.c 2000/05/03 23:44:33 2.32 *************** *** 279,285 **** efd2obj = PyMem_NEW(pylist, FD_SETSIZE + 3); if (rfd2obj == NULL || wfd2obj == NULL || efd2obj == NULL) { ! PyMem_XDEL(rfd2obj); ! PyMem_XDEL(wfd2obj); ! PyMem_XDEL(efd2obj); return NULL; } --- 279,285 ---- efd2obj = PyMem_NEW(pylist, FD_SETSIZE + 3); if (rfd2obj == NULL || wfd2obj == NULL || efd2obj == NULL) { ! if (rfd2obj) PyMem_DEL(rfd2obj); ! if (wfd2obj) PyMem_DEL(wfd2obj); ! if (efd2obj) PyMem_DEL(efd2obj); return NULL; } Index: shamodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/shamodule.c,v retrieving revision 2.4 retrieving revision 2.5 diff -C2 -r2.4 -r2.5 *** shamodule.c 2000/02/29 13:59:23 2.4 --- shamodule.c 2000/05/03 23:44:33 2.5 *************** *** 381,385 **** newSHAobject() { ! return (SHAobject *)PyObject_NEW(SHAobject, &SHAtype); } --- 381,385 ---- newSHAobject() { ! return (SHAobject *)PyObject_New(SHAobject, &SHAtype); } *************** *** 390,394 **** PyObject *ptr; { ! PyMem_DEL(ptr); } --- 390,394 ---- PyObject *ptr; { ! PyObject_Del(ptr); } Index: socketmodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.106 retrieving revision 1.107 diff -C2 -r1.106 -r1.107 *** socketmodule.c 2000/04/25 21:53:58 1.106 --- socketmodule.c 2000/05/03 23:44:33 1.107 *************** *** 390,394 **** PySocketSockObject *s; PySocketSock_Type.ob_type = &PyType_Type; ! s = PyObject_NEW(PySocketSockObject, &PySocketSock_Type); if (s != NULL) { s->sock_fd = fd; --- 390,394 ---- PySocketSockObject *s; PySocketSock_Type.ob_type = &PyType_Type; ! s = PyObject_New(PySocketSockObject, &PySocketSock_Type); if (s != NULL) { s->sock_fd = fd; *************** *** 1369,1373 **** if (s->sock_fd != -1) (void) SOCKETCLOSE(s->sock_fd); ! PyMem_DEL(s); } --- 1369,1373 ---- if (s->sock_fd != -1) (void) SOCKETCLOSE(s->sock_fd); ! PyObject_Del(s); } *************** *** 1949,1953 **** #endif ! self = PyObject_NEW(SSLObject, &SSL_Type); /* Create new object */ if (self == NULL){ PyErr_SetObject(SSLErrorObject, --- 1949,1953 ---- #endif ! self = PyObject_New(SSLObject, &SSL_Type); /* Create new object */ if (self == NULL){ PyErr_SetObject(SSLErrorObject, *************** *** 1963,1967 **** PyErr_SetObject(SSLErrorObject, PyString_FromString("SSL_CTX_new error")); ! PyMem_DEL(self); return NULL; } --- 1963,1967 ---- PyErr_SetObject(SSLErrorObject, PyString_FromString("SSL_CTX_new error")); ! PyObject_Del(self); return NULL; } *************** *** 1972,1976 **** PyString_FromString( "Both the key & certificate files must be specified")); ! PyMem_DEL(self); return NULL; } --- 1972,1976 ---- PyString_FromString( "Both the key & certificate files must be specified")); ! PyObject_Del(self); return NULL; } *************** *** 1984,1988 **** PyString_FromString( "SSL_CTX_use_PrivateKey_file error")); ! PyMem_DEL(self); return NULL; } --- 1984,1988 ---- PyString_FromString( "SSL_CTX_use_PrivateKey_file error")); ! PyObject_Del(self); return NULL; } *************** *** 1994,1998 **** PyString_FromString( "SSL_CTX_use_certificate_chain_file error")); ! PyMem_DEL(self); return NULL; } --- 1994,1998 ---- PyString_FromString( "SSL_CTX_use_certificate_chain_file error")); ! PyObject_Del(self); return NULL; } *************** *** 2009,2013 **** PyErr_SetObject(SSLErrorObject, PyString_FromString("SSL_connect error")); ! PyMem_DEL(self); return NULL; } --- 2009,2013 ---- PyErr_SetObject(SSLErrorObject, PyString_FromString("SSL_connect error")); ! PyObject_Del(self); return NULL; } *************** *** 2080,2084 **** Py_XDECREF(self->x_attr); Py_XDECREF(self->Socket); ! PyMem_DEL(self); } --- 2080,2084 ---- Py_XDECREF(self->x_attr); Py_XDECREF(self->Socket); ! PyObject_Del(self); } Index: stropmodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/stropmodule.c,v retrieving revision 2.62 retrieving revision 2.63 diff -C2 -r2.62 -r2.63 *** stropmodule.c 2000/03/20 16:36:39 2.62 --- stropmodule.c 2000/05/03 23:44:33 2.63 *************** *** 1153,1157 **** new_len = len + nfound*(sub_len - pat_len); ! new_s = (char *)malloc(new_len); if (new_s == NULL) return NULL; --- 1153,1157 ---- new_len = len + nfound*(sub_len - pat_len); ! new_s = (char *)PyMem_MALLOC(new_len); if (new_s == NULL) return NULL; *************** *** 1226,1230 **** else { new = PyString_FromStringAndSize(new_s, out_len); ! free(new_s); } return new; --- 1226,1230 ---- else { new = PyString_FromStringAndSize(new_s, out_len); ! PyMem_FREE(new_s); } return new; Index: sunaudiodev.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/sunaudiodev.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** sunaudiodev.c 1998/10/31 22:52:54 1.16 --- sunaudiodev.c 2000/05/03 23:44:33 1.17 *************** *** 140,144 **** /* Create and initialize the object */ ! xp = PyObject_NEW(sadobject, &Sadtype); if (xp == NULL) { close(fd); --- 140,144 ---- /* Create and initialize the object */ ! xp = PyObject_New(sadobject, &Sadtype); if (xp == NULL) { close(fd); *************** *** 159,163 **** { close(xp->x_fd); ! PyMem_DEL(xp); } --- 159,163 ---- { close(xp->x_fd); ! PyObject_Del(xp); } *************** *** 413,417 **** static sadstatusobject * sads_alloc() { ! return PyObject_NEW(sadstatusobject, &Sadstatustype); } --- 413,417 ---- static sadstatusobject * sads_alloc() { ! return PyObject_New(sadstatusobject, &Sadstatustype); } Index: svmodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/svmodule.c,v retrieving revision 2.10 retrieving revision 2.11 diff -C2 -r2.10 -r2.11 *** svmodule.c 1997/10/01 04:28:58 2.10 --- svmodule.c 2000/05/03 23:44:33 2.11 *************** *** 341,345 **** self->ob_svideo = NULL; } ! PyMem_DEL(self); } --- 341,345 ---- self->ob_svideo = NULL; } ! PyObject_Del(self); } *************** *** 375,379 **** captureobject *p; ! p = PyObject_NEW(captureobject, &Capturetype); if (p == NULL) return NULL; --- 375,379 ---- captureobject *p; ! p = PyObject_New(captureobject, &Capturetype); if (p == NULL) return NULL; *************** *** 995,999 **** if (self->ob_svideo != NULL) (void) svCloseVideo(self->ob_svideo); ! PyMem_DEL(self); } --- 995,999 ---- if (self->ob_svideo != NULL) (void) svCloseVideo(self->ob_svideo); ! PyObject_Del(self); } *************** *** 1027,1031 **** svobject *p; ! p = PyObject_NEW(svobject, &Svtype); if (p == NULL) return NULL; --- 1027,1031 ---- svobject *p; ! p = PyObject_New(svobject, &Svtype); if (p == NULL) return NULL; Index: threadmodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/threadmodule.c,v retrieving revision 2.30 retrieving revision 2.31 diff -C2 -r2.30 -r2.31 *** threadmodule.c 2000/02/29 13:59:24 2.30 --- threadmodule.c 2000/05/03 23:44:33 2.31 *************** *** 59,68 **** { lockobject *self; ! self = PyObject_NEW(lockobject, &Locktype); if (self == NULL) return NULL; self->lock_lock = PyThread_allocate_lock(); if (self->lock_lock == NULL) { ! PyMem_DEL(self); self = NULL; PyErr_SetString(ThreadError, "can't allocate lock"); --- 59,68 ---- { lockobject *self; ! self = PyObject_New(lockobject, &Locktype); if (self == NULL) return NULL; self->lock_lock = PyThread_allocate_lock(); if (self->lock_lock == NULL) { ! PyObject_Del(self); self = NULL; PyErr_SetString(ThreadError, "can't allocate lock"); *************** *** 80,84 **** PyThread_free_lock(self->lock_lock); ! PyMem_DEL(self); } --- 80,84 ---- PyThread_free_lock(self->lock_lock); ! PyObject_Del(self); } Index: xxmodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/xxmodule.c,v retrieving revision 2.15 retrieving revision 2.16 diff -C2 -r2.15 -r2.16 *** xxmodule.c 2000/02/29 13:59:24 2.15 --- xxmodule.c 2000/05/03 23:44:33 2.16 *************** *** 63,67 **** { XxoObject *self; ! self = PyObject_NEW(XxoObject, &Xxo_Type); if (self == NULL) return NULL; --- 63,67 ---- { XxoObject *self; ! self = PyObject_New(XxoObject, &Xxo_Type); if (self == NULL) return NULL; *************** *** 77,81 **** { Py_XDECREF(self->x_attr); ! PyMem_DEL(self); } --- 77,81 ---- { Py_XDECREF(self->x_attr); ! PyObject_Del(self); } Index: zlibmodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/zlibmodule.c,v retrieving revision 2.31 retrieving revision 2.32 diff -C2 -r2.31 -r2.32 *** zlibmodule.c 2000/04/06 13:20:38 2.31 --- zlibmodule.c 2000/05/03 23:44:33 2.32 *************** *** 47,51 **** { compobject *self; ! self = PyObject_NEW(compobject, type); if (self == NULL) return NULL; --- 47,51 ---- { compobject *self; ! self = PyObject_New(compobject, type); if (self == NULL) return NULL; *************** *** 370,374 **** deflateEnd(&self->zst); Py_XDECREF(self->unused_data); ! PyMem_DEL(self); } --- 370,374 ---- deflateEnd(&self->zst); Py_XDECREF(self->unused_data); ! PyObject_Del(self); } *************** *** 379,383 **** inflateEnd(&self->zst); Py_XDECREF(self->unused_data); ! PyMem_DEL(self); } --- 379,383 ---- inflateEnd(&self->zst); Py_XDECREF(self->unused_data); ! PyObject_Del(self); } From python-dev@python.org Thu May 4 00:45:13 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 3 May 2000 19:45:13 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Objects bufferobject.c,2.6,2.7 classobject.c,2.85,2.86 cobject.c,2.7,2.8 complexobject.c,2.23,2.24 dictobject.c,2.51,2.52 fileobject.c,2.72,2.73 floatobject.c,2.56,2.57 frameobject.c,2.38,2.39 funcobject.c,2.19,2.20 intobject.c,2.40,2.41 listobject.c,2.68,2.69 longobject.c,1.56,1.57 methodobject.c,2.25,2.26 moduleobject.c,2.24,2.25 object.c,2.69,2.70 rangeobject.c,2.11,2.12 sliceobject.c,2.3,2.4 stringobject.c,2.62,2.63 tupleobject.c,2.32,2.33 unicodeobject.c,2.15,2.16 xxobject.c,2.14,2.15 Message-ID: <200005032345.TAA06651@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Objects In directory eric:/projects/python/develop/guido/clean/Objects Modified Files: bufferobject.c classobject.c cobject.c complexobject.c dictobject.c fileobject.c floatobject.c frameobject.c funcobject.c intobject.c listobject.c longobject.c methodobject.c moduleobject.c object.c rangeobject.c sliceobject.c stringobject.c tupleobject.c unicodeobject.c xxobject.c Log Message: Vladimir Marangozov's long-awaited malloc restructuring. For more comments, read the patches@python.org archives. For documentation read the comments in mymalloc.h and objimpl.h. (This is not exactly what Vladimir posted to the patches list; I've made a few changes, and Vladimir sent me a fix in private email for a problem that only occurs in debug mode. I'm also holding back on his change to main.c, which seems unnecessary to me.) Index: bufferobject.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Objects/bufferobject.c,v retrieving revision 2.6 retrieving revision 2.7 diff -C2 -r2.6 -r2.7 *** bufferobject.c 1999/08/04 13:08:19 2.6 --- bufferobject.c 2000/05/03 23:44:34 2.7 *************** *** 189,197 **** return NULL; } ! b = (PyBufferObject *)malloc(sizeof(*b) + size); if ( b == NULL ) return PyErr_NoMemory(); ! b->ob_type = &PyBuffer_Type; ! _Py_NewReference((PyObject *)b); b->b_base = NULL; --- 189,197 ---- return NULL; } ! /* PyObject_New is inlined */ ! b = (PyBufferObject *) PyObject_MALLOC(sizeof(*b) + size); if ( b == NULL ) return PyErr_NoMemory(); ! PyObject_INIT((PyObject *)b, &PyBuffer_Type); b->b_base = NULL; *************** *** 213,217 **** { Py_XDECREF(self->b_base); ! free((void *)self); } --- 213,217 ---- { Py_XDECREF(self->b_base); ! PyObject_DEL(self); } Index: classobject.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Objects/classobject.c,v retrieving revision 2.85 retrieving revision 2.86 diff -C2 -r2.85 -r2.86 *** classobject.c 2000/04/26 20:39:20 2.85 --- classobject.c 2000/05/03 23:44:34 2.86 *************** *** 148,152 **** Py_XDECREF(op->cl_setattr); Py_XDECREF(op->cl_delattr); ! free((ANY *)op); } --- 148,152 ---- Py_XDECREF(op->cl_setattr); Py_XDECREF(op->cl_delattr); ! PyObject_DEL(op); } *************** *** 562,566 **** Py_DECREF(inst->in_class); Py_XDECREF(inst->in_dict); ! free((ANY *)inst); } --- 562,566 ---- Py_DECREF(inst->in_class); Py_XDECREF(inst->in_dict); ! PyObject_DEL(inst); } *************** *** 1499,1504 **** if (im != NULL) { free_list = (PyMethodObject *)(im->im_self); ! im->ob_type = &PyMethod_Type; ! _Py_NewReference((PyObject *)im); } else { --- 1499,1503 ---- if (im != NULL) { free_list = (PyMethodObject *)(im->im_self); ! PyObject_INIT(im, &PyMethod_Type); } else { *************** *** 1692,1698 **** { while (free_list) { ! PyMethodObject *v = free_list; ! free_list = (PyMethodObject *)(v->im_self); ! PyMem_DEL(v); } } --- 1691,1697 ---- { while (free_list) { ! PyMethodObject *im = free_list; ! free_list = (PyMethodObject *)(im->im_self); ! PyObject_DEL(im); } } Index: cobject.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Objects/cobject.c,v retrieving revision 2.7 retrieving revision 2.8 diff -C2 -r2.7 -r2.8 *** cobject.c 1997/10/21 19:48:35 2.7 --- cobject.c 2000/05/03 23:44:34 2.8 *************** *** 152,156 **** (self->destructor)(self->cobject); } ! PyMem_DEL(self); } --- 152,156 ---- (self->destructor)(self->cobject); } ! PyObject_DEL(self); } Index: complexobject.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Objects/complexobject.c,v retrieving revision 2.23 retrieving revision 2.24 diff -C2 -r2.23 -r2.24 *** complexobject.c 2000/02/29 13:59:28 2.23 --- complexobject.c 2000/05/03 23:44:34 2.24 *************** *** 167,177 **** Py_complex cval; { ! register PyComplexObject *op = ! (PyComplexObject *) malloc(sizeof(PyComplexObject)); if (op == NULL) return PyErr_NoMemory(); ! op->ob_type = &PyComplex_Type; op->cval = cval; - _Py_NewReference((PyObject *)op); return (PyObject *) op; } --- 167,178 ---- Py_complex cval; { ! register PyComplexObject *op; ! ! /* PyObject_New is inlined */ ! op = (PyComplexObject *) PyObject_MALLOC(sizeof(PyComplexObject)); if (op == NULL) return PyErr_NoMemory(); ! PyObject_INIT(op, &PyComplex_Type); op->cval = cval; return (PyObject *) op; } *************** *** 227,231 **** PyObject *op; { ! PyMem_DEL(op); } --- 228,232 ---- PyObject *op; { ! PyObject_DEL(op); } Index: dictobject.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Objects/dictobject.c,v retrieving revision 2.51 retrieving revision 2.52 diff -C2 -r2.51 -r2.52 *** dictobject.c 2000/03/30 22:27:31 2.51 --- dictobject.c 2000/05/03 23:44:34 2.52 *************** *** 278,282 **** } } ! newtable = (dictentry *) malloc(sizeof(dictentry) * newsize); if (newtable == NULL) { PyErr_NoMemory(); --- 278,282 ---- } } ! newtable = PyMem_NEW(dictentry, newsize); if (newtable == NULL) { PyErr_NoMemory(); *************** *** 302,306 **** } ! PyMem_XDEL(oldtable); return 0; } --- 302,307 ---- } ! if (oldtable != NULL) ! PyMem_DEL(oldtable); return 0; } *************** *** 489,494 **** } } ! PyMem_XDEL(mp->ma_table); ! PyMem_DEL(mp); Py_TRASHCAN_SAFE_END(mp) } --- 490,496 ---- } } ! if (mp->ma_table != NULL) ! PyMem_DEL(mp->ma_table); ! PyObject_DEL(mp); Py_TRASHCAN_SAFE_END(mp) } Index: fileobject.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Objects/fileobject.c,v retrieving revision 2.72 retrieving revision 2.73 diff -C2 -r2.72 -r2.73 *** fileobject.c 2000/03/13 16:27:06 2.72 --- fileobject.c 2000/05/03 23:44:34 2.73 *************** *** 216,220 **** Py_DECREF(f->f_mode); } ! free((char *)f); } --- 216,220 ---- Py_DECREF(f->f_mode); } ! PyObject_DEL(f); } Index: floatobject.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Objects/floatobject.c,v retrieving revision 2.56 retrieving revision 2.57 diff -C2 -r2.56 -r2.57 *** floatobject.c 2000/04/05 20:11:20 2.56 --- floatobject.c 2000/05/03 23:44:34 2.57 *************** *** 99,105 **** #define N_FLOATOBJECTS ((BLOCK_SIZE - BHEAD_SIZE) / sizeof(PyFloatObject)) - #define PyMem_MALLOC malloc - #define PyMem_FREE free - struct _floatblock { struct _floatblock *next; --- 99,102 ---- *************** *** 116,122 **** { PyFloatObject *p, *q; ! p = (PyFloatObject *)PyMem_MALLOC(sizeof(PyFloatBlock)); if (p == NULL) ! return (PyFloatObject *)PyErr_NoMemory(); ((PyFloatBlock *)p)->next = block_list; block_list = (PyFloatBlock *)p; --- 113,120 ---- { PyFloatObject *p, *q; ! /* XXX Float blocks escape the object heap. Use PyObject_MALLOC ??? */ ! p = (PyFloatObject *) PyMem_MALLOC(sizeof(PyFloatBlock)); if (p == NULL) ! return (PyFloatObject *) PyErr_NoMemory(); ((PyFloatBlock *)p)->next = block_list; block_list = (PyFloatBlock *)p; *************** *** 142,150 **** return NULL; } op = free_list; free_list = (PyFloatObject *)op->ob_type; ! op->ob_type = &PyFloat_Type; op->ob_fval = fval; - _Py_NewReference((PyObject *)op); return (PyObject *) op; } --- 140,148 ---- return NULL; } + /* PyObject_New is inlined */ op = free_list; free_list = (PyFloatObject *)op->ob_type; ! PyObject_INIT(op, &PyFloat_Type); op->ob_fval = fval; return (PyObject *) op; } *************** *** 780,784 **** } else { ! PyMem_FREE(list); bf++; } --- 778,782 ---- } else { ! PyMem_FREE(list); /* XXX PyObject_FREE ??? */ bf++; } Index: frameobject.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Objects/frameobject.c,v retrieving revision 2.38 retrieving revision 2.39 diff -C2 -r2.38 -r2.39 *** frameobject.c 2000/03/13 16:01:29 2.38 --- frameobject.c 2000/05/03 23:44:34 2.39 *************** *** 181,191 **** builtins = NULL; if (free_list == NULL) { f = (PyFrameObject *) ! malloc(sizeof(PyFrameObject) + ! extras*sizeof(PyObject *)); if (f == NULL) return (PyFrameObject *)PyErr_NoMemory(); ! f->ob_type = &PyFrame_Type; ! _Py_NewReference((PyObject *)f); } else { --- 181,191 ---- builtins = NULL; if (free_list == NULL) { + /* PyObject_New is inlined */ f = (PyFrameObject *) ! PyObject_MALLOC(sizeof(PyFrameObject) + ! extras*sizeof(PyObject *)); if (f == NULL) return (PyFrameObject *)PyErr_NoMemory(); ! PyObject_INIT(f, &PyFrame_Type); } else { *************** *** 194,199 **** if (f->f_nlocals + f->f_stacksize < extras) { f = (PyFrameObject *) ! realloc(f, sizeof(PyFrameObject) + ! extras*sizeof(PyObject *)); if (f == NULL) return (PyFrameObject *)PyErr_NoMemory(); --- 194,199 ---- if (f->f_nlocals + f->f_stacksize < extras) { f = (PyFrameObject *) ! PyObject_REALLOC(f, sizeof(PyFrameObject) + ! extras*sizeof(PyObject *)); if (f == NULL) return (PyFrameObject *)PyErr_NoMemory(); *************** *** 201,206 **** else extras = f->f_nlocals + f->f_stacksize; ! f->ob_type = &PyFrame_Type; ! _Py_NewReference((PyObject *)f); } if (builtins == NULL) { --- 201,205 ---- else extras = f->f_nlocals + f->f_stacksize; ! PyObject_INIT(f, &PyFrame_Type); } if (builtins == NULL) { *************** *** 377,381 **** PyFrameObject *f = free_list; free_list = free_list->f_back; ! PyMem_DEL(f); } } --- 376,380 ---- PyFrameObject *f = free_list; free_list = free_list->f_back; ! PyObject_DEL(f); } } Index: funcobject.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Objects/funcobject.c,v retrieving revision 2.19 retrieving revision 2.20 diff -C2 -r2.19 -r2.20 *** funcobject.c 2000/04/27 20:14:13 2.19 --- funcobject.c 2000/05/03 23:44:35 2.20 *************** *** 192,196 **** Py_XDECREF(op->func_defaults); Py_XDECREF(op->func_doc); ! PyMem_DEL(op); } --- 192,196 ---- Py_XDECREF(op->func_defaults); Py_XDECREF(op->func_doc); ! PyObject_DEL(op); } Index: intobject.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Objects/intobject.c,v retrieving revision 2.40 retrieving revision 2.41 diff -C2 -r2.40 -r2.41 *** intobject.c 2000/04/05 20:11:20 2.40 --- intobject.c 2000/05/03 23:44:35 2.41 *************** *** 95,101 **** #define N_INTOBJECTS ((BLOCK_SIZE - BHEAD_SIZE) / sizeof(PyIntObject)) - #define PyMem_MALLOC malloc - #define PyMem_FREE free - struct _intblock { struct _intblock *next; --- 95,98 ---- *************** *** 112,118 **** { PyIntObject *p, *q; ! p = (PyIntObject *)PyMem_MALLOC(sizeof(PyIntBlock)); if (p == NULL) ! return (PyIntObject *)PyErr_NoMemory(); ((PyIntBlock *)p)->next = block_list; block_list = (PyIntBlock *)p; --- 109,116 ---- { PyIntObject *p, *q; ! /* XXX Int blocks escape the object heap. Use PyObject_MALLOC ??? */ ! p = (PyIntObject *) PyMem_MALLOC(sizeof(PyIntBlock)); if (p == NULL) ! return (PyIntObject *) PyErr_NoMemory(); ((PyIntBlock *)p)->next = block_list; block_list = (PyIntBlock *)p; *************** *** 165,173 **** return NULL; } v = free_list; free_list = (PyIntObject *)v->ob_type; ! v->ob_type = &PyInt_Type; v->ob_ival = ival; - _Py_NewReference((PyObject *)v); #if NSMALLNEGINTS + NSMALLPOSINTS > 0 if (-NSMALLNEGINTS <= ival && ival < NSMALLPOSINTS) { --- 163,171 ---- return NULL; } + /* PyObject_New is inlined */ v = free_list; free_list = (PyIntObject *)v->ob_type; ! PyObject_INIT(v, &PyInt_Type); v->ob_ival = ival; #if NSMALLNEGINTS + NSMALLPOSINTS > 0 if (-NSMALLNEGINTS <= ival && ival < NSMALLPOSINTS) { *************** *** 934,938 **** } else { ! PyMem_FREE(list); bf++; } --- 932,936 ---- } else { ! PyMem_FREE(list); /* XXX PyObject_FREE ??? */ bf++; } Index: listobject.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Objects/listobject.c,v retrieving revision 2.68 retrieving revision 2.69 diff -C2 -r2.68 -r2.69 *** listobject.c 2000/04/27 21:41:03 2.68 --- listobject.c 2000/05/03 23:44:35 2.69 *************** *** 71,75 **** return PyErr_NoMemory(); } ! op = (PyListObject *) malloc(sizeof(PyListObject)); if (op == NULL) { return PyErr_NoMemory(); --- 71,76 ---- return PyErr_NoMemory(); } ! /* PyObject_NewVar is inlined */ ! op = (PyListObject *) PyObject_MALLOC(sizeof(PyListObject)); if (op == NULL) { return PyErr_NoMemory(); *************** *** 79,93 **** } else { ! op->ob_item = (PyObject **) malloc(nbytes); if (op->ob_item == NULL) { ! free((ANY *)op); return PyErr_NoMemory(); } } ! op->ob_type = &PyList_Type; ! op->ob_size = size; for (i = 0; i < size; i++) op->ob_item[i] = NULL; - _Py_NewReference((PyObject *)op); return (PyObject *) op; } --- 80,92 ---- } else { ! op->ob_item = (PyObject **) PyMem_MALLOC(nbytes); if (op->ob_item == NULL) { ! PyObject_FREE(op); return PyErr_NoMemory(); } } ! PyObject_INIT_VAR(op, &PyList_Type, size); for (i = 0; i < size; i++) op->ob_item[i] = NULL; return (PyObject *) op; } *************** *** 226,232 **** Py_XDECREF(op->ob_item[i]); } ! free((ANY *)op->ob_item); } ! free((ANY *)op); Py_TRASHCAN_SAFE_END(op) } --- 225,231 ---- Py_XDECREF(op->ob_item[i]); } ! PyMem_FREE(op->ob_item); } ! PyObject_DEL(op); Py_TRASHCAN_SAFE_END(op) } *************** *** 502,506 **** NRESIZE(item, PyObject *, a->ob_size + d); if (item == NULL) { ! PyMem_XDEL(recycle); PyErr_NoMemory(); return -1; --- 501,506 ---- NRESIZE(item, PyObject *, a->ob_size + d); if (item == NULL) { ! if (recycle != NULL) ! PyMem_DEL(recycle); PyErr_NoMemory(); return -1; Index: longobject.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Objects/longobject.c,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -r1.56 -r1.57 *** longobject.c 2000/04/10 17:31:58 1.56 --- longobject.c 2000/05/03 23:44:35 1.57 *************** *** 996,1000 **** PyObject *v; { ! PyMem_DEL(v); } --- 996,1000 ---- PyObject *v; { ! PyObject_DEL(v); } Index: methodobject.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Objects/methodobject.c,v retrieving revision 2.25 retrieving revision 2.26 diff -C2 -r2.25 -r2.26 *** methodobject.c 2000/01/20 22:32:54 2.25 --- methodobject.c 2000/05/03 23:44:35 2.26 *************** *** 47,52 **** if (op != NULL) { free_list = (PyCFunctionObject *)(op->m_self); ! op->ob_type = &PyCFunction_Type; ! _Py_NewReference((PyObject *)op); } else { --- 47,51 ---- if (op != NULL) { free_list = (PyCFunctionObject *)(op->m_self); ! PyObject_INIT(op, &PyCFunction_Type); } else { *************** *** 289,293 **** PyCFunctionObject *v = free_list; free_list = (PyCFunctionObject *)(v->m_self); ! PyMem_DEL(v); } } --- 288,292 ---- PyCFunctionObject *v = free_list; free_list = (PyCFunctionObject *)(v->m_self); ! PyObject_DEL(v); } } Index: moduleobject.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Objects/moduleobject.c,v retrieving revision 2.24 retrieving revision 2.25 diff -C2 -r2.24 -r2.25 *** moduleobject.c 1999/02/15 14:47:16 2.24 --- moduleobject.c 2000/05/03 23:44:35 2.25 *************** *** 171,175 **** Py_DECREF(m->md_dict); } ! free((char *)m); } --- 171,175 ---- Py_DECREF(m->md_dict); } ! PyObject_DEL(m); } Index: object.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Objects/object.c,v retrieving revision 2.69 retrieving revision 2.70 diff -C2 -r2.69 -r2.70 *** object.c 2000/04/24 15:40:53 2.69 --- object.c 2000/05/03 23:44:35 2.70 *************** *** 113,132 **** #endif - #ifndef MS_COREDLL PyObject * ! _PyObject_New(tp) ! PyTypeObject *tp; ! #else ! PyObject * ! _PyObject_New(tp,op) ! PyTypeObject *tp; PyObject *op; ! #endif { ! #ifndef MS_COREDLL ! PyObject *op = (PyObject *) malloc(tp->tp_basicsize); ! #endif ! if (op == NULL) ! return PyErr_NoMemory(); op->ob_type = tp; _Py_NewReference(op); --- 113,127 ---- #endif PyObject * ! PyObject_Init(op, tp) PyObject *op; ! PyTypeObject *tp; { ! if (op == NULL) { ! PyErr_SetString(PyExc_SystemError, ! "NULL object passed to PyObject_Init"); ! return op; ! } ! /* Any changes should be reflected in PyObject_INIT (objimpl.h) */ op->ob_type = tp; _Py_NewReference(op); *************** *** 134,162 **** } - #ifndef MS_COREDLL PyVarObject * ! _PyObject_NewVar(tp, size) PyTypeObject *tp; int size; ! #else PyVarObject * ! _PyObject_NewVar(tp, size, op) PyTypeObject *tp; int size; - PyVarObject *op; - #endif { ! #ifndef MS_COREDLL ! PyVarObject *op = (PyVarObject *) ! malloc(tp->tp_basicsize + size * tp->tp_itemsize); ! #endif if (op == NULL) return (PyVarObject *)PyErr_NoMemory(); ! op->ob_type = tp; ! op->ob_size = size; ! _Py_NewReference((PyObject *)op); ! return op; } int PyObject_Print(op, fp, flags) --- 129,180 ---- } PyVarObject * ! PyObject_InitVar(op, tp, size) ! PyVarObject *op; PyTypeObject *tp; int size; ! { ! if (op == NULL) { ! PyErr_SetString(PyExc_SystemError, ! "NULL object passed to PyObject_InitVar"); ! return op; ! } ! /* Any changes should be reflected in PyObject_INIT_VAR */ ! op->ob_size = size; ! op->ob_type = tp; ! _Py_NewReference((PyObject *)op); ! return op; ! } ! ! PyObject * ! _PyObject_New(tp) ! PyTypeObject *tp; ! { ! PyObject *op; ! op = (PyObject *) PyObject_MALLOC(_PyObject_SIZE(tp)); ! if (op == NULL) ! return PyErr_NoMemory(); ! return PyObject_INIT(op, tp); ! } ! PyVarObject * ! _PyObject_NewVar(tp, size) PyTypeObject *tp; int size; { ! PyVarObject *op; ! op = (PyVarObject *) PyObject_MALLOC(_PyObject_VAR_SIZE(tp, size)); if (op == NULL) return (PyVarObject *)PyErr_NoMemory(); ! return PyObject_INIT_VAR(op, tp, size); } + void + _PyObject_Del(op) + PyObject *op; + { + PyObject_FREE(op); + } + int PyObject_Print(op, fp, flags) *************** *** 888,916 **** int (*_Py_abstract_hack) Py_FPROTO((PyObject *)) = &PyObject_Length; - - /* Malloc wrappers (see mymalloc.h) */ ! /* The Py_{Malloc,Realloc} wrappers call PyErr_NoMemory() on failure */ ANY * ! Py_Malloc(nbytes) size_t nbytes; { - ANY *p; #if _PyMem_EXTRA > 0 if (nbytes == 0) nbytes = _PyMem_EXTRA; #endif ! p = malloc(nbytes); ! if (p != NULL) ! return p; ! else { ! PyErr_NoMemory(); ! return NULL; ! } } ANY * ! Py_Realloc(p, nbytes) ANY *p; size_t nbytes; --- 906,925 ---- int (*_Py_abstract_hack) Py_FPROTO((PyObject *)) = &PyObject_Length; ! /* Python's malloc wrappers (see mymalloc.h) */ ANY * ! PyMem_Malloc(nbytes) size_t nbytes; { #if _PyMem_EXTRA > 0 if (nbytes == 0) nbytes = _PyMem_EXTRA; #endif ! return PyMem_MALLOC(nbytes); } ANY * ! PyMem_Realloc(p, nbytes) ANY *p; size_t nbytes; *************** *** 920,969 **** nbytes = _PyMem_EXTRA; #endif ! p = realloc(p, nbytes); ! if (p != NULL) ! return p; ! else { ! PyErr_NoMemory(); ! return NULL; ! } } void ! Py_Free(p) ANY *p; { ! free(p); } - /* The PyMem_{Malloc,Realloc} wrappers don't call anything on failure */ ANY * ! PyMem_Malloc(nbytes) size_t nbytes; { ! #if _PyMem_EXTRA > 0 ! if (nbytes == 0) ! nbytes = _PyMem_EXTRA; ! #endif ! return malloc(nbytes); } ANY * ! PyMem_Realloc(p, nbytes) ANY *p; size_t nbytes; { ! #if _PyMem_EXTRA > 0 ! if (nbytes == 0) ! nbytes = _PyMem_EXTRA; ! #endif ! return realloc(p, nbytes); } void ! PyMem_Free(p) ANY *p; { ! free(p); } --- 929,965 ---- nbytes = _PyMem_EXTRA; #endif ! return PyMem_REALLOC(p, nbytes); } void ! PyMem_Free(p) ANY *p; { ! PyMem_FREE(p); } + /* Python's object malloc wrappers (see objimpl.h) */ + ANY * ! PyObject_Malloc(nbytes) size_t nbytes; { ! return PyObject_MALLOC(nbytes); } ANY * ! PyObject_Realloc(p, nbytes) ANY *p; size_t nbytes; { ! return PyObject_REALLOC(p, nbytes); } void ! PyObject_Free(p) ANY *p; { ! PyObject_FREE(p); } Index: rangeobject.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Objects/rangeobject.c,v retrieving revision 2.11 retrieving revision 2.12 diff -C2 -r2.11 -r2.12 *** rangeobject.c 1999/01/09 21:40:35 2.11 --- rangeobject.c 2000/05/03 23:44:35 2.12 *************** *** 62,66 **** rangeobject *r; { ! PyMem_DEL(r); } --- 62,66 ---- rangeobject *r; { ! PyObject_DEL(r); } Index: sliceobject.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Objects/sliceobject.c,v retrieving revision 2.3 retrieving revision 2.4 diff -C2 -r2.3 -r2.4 *** sliceobject.c 1996/10/11 16:25:09 2.3 --- sliceobject.c 2000/05/03 23:44:35 2.4 *************** *** 58,63 **** PyObject *step; { ! PySliceObject *obj = ! (PySliceObject *) PyObject_NEW(PySliceObject, &PySlice_Type); if (step == NULL) step = Py_None; --- 58,62 ---- PyObject *step; { ! PySliceObject *obj = PyObject_NEW(PySliceObject, &PySlice_Type); if (step == NULL) step = Py_None; *************** *** 116,120 **** Py_DECREF(r->start); Py_DECREF(r->stop); ! PyMem_DEL(r); } --- 115,119 ---- Py_DECREF(r->start); Py_DECREF(r->stop); ! PyObject_DEL(r); } Index: stringobject.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Objects/stringobject.c,v retrieving revision 2.62 retrieving revision 2.63 diff -C2 -r2.62 -r2.63 *** stringobject.c 2000/04/11 15:39:26 2.62 --- stringobject.c 2000/05/03 23:44:35 2.63 *************** *** 93,102 **** } #endif /* DONT_SHARE_SHORT_STRINGS */ op = (PyStringObject *) ! malloc(sizeof(PyStringObject) + size * sizeof(char)); if (op == NULL) return PyErr_NoMemory(); ! op->ob_type = &PyString_Type; ! op->ob_size = size; #ifdef CACHE_HASH op->ob_shash = -1; --- 93,103 ---- } #endif /* DONT_SHARE_SHORT_STRINGS */ + + /* PyObject_NewVar is inlined */ op = (PyStringObject *) ! PyObject_MALLOC(sizeof(PyStringObject) + size * sizeof(char)); if (op == NULL) return PyErr_NoMemory(); ! PyObject_INIT_VAR(op, &PyString_Type, size); #ifdef CACHE_HASH op->ob_shash = -1; *************** *** 105,109 **** op->ob_sinterned = NULL; #endif - _Py_NewReference((PyObject *)op); if (str != NULL) memcpy(op->ob_sval, str, size); --- 106,109 ---- *************** *** 143,152 **** } #endif /* DONT_SHARE_SHORT_STRINGS */ op = (PyStringObject *) ! malloc(sizeof(PyStringObject) + size * sizeof(char)); if (op == NULL) return PyErr_NoMemory(); ! op->ob_type = &PyString_Type; ! op->ob_size = size; #ifdef CACHE_HASH op->ob_shash = -1; --- 143,153 ---- } #endif /* DONT_SHARE_SHORT_STRINGS */ + + /* PyObject_NewVar is inlined */ op = (PyStringObject *) ! PyObject_MALLOC(sizeof(PyStringObject) + size * sizeof(char)); if (op == NULL) return PyErr_NoMemory(); ! PyObject_INIT_VAR(op, &PyString_Type, size); #ifdef CACHE_HASH op->ob_shash = -1; *************** *** 155,159 **** op->ob_sinterned = NULL; #endif - _Py_NewReference((PyObject *)op); strcpy(op->ob_sval, str); #ifndef DONT_SHARE_SHORT_STRINGS --- 156,159 ---- *************** *** 173,177 **** PyObject *op; { ! PyMem_DEL(op); } --- 173,177 ---- PyObject *op; { ! PyObject_DEL(op); } *************** *** 308,317 **** } size = a->ob_size + b->ob_size; op = (PyStringObject *) ! malloc(sizeof(PyStringObject) + size * sizeof(char)); if (op == NULL) return PyErr_NoMemory(); ! op->ob_type = &PyString_Type; ! op->ob_size = size; #ifdef CACHE_HASH op->ob_shash = -1; --- 308,317 ---- } size = a->ob_size + b->ob_size; + /* PyObject_NewVar is inlined */ op = (PyStringObject *) ! PyObject_MALLOC(sizeof(PyStringObject) + size * sizeof(char)); if (op == NULL) return PyErr_NoMemory(); ! PyObject_INIT_VAR(op, &PyString_Type, size); #ifdef CACHE_HASH op->ob_shash = -1; *************** *** 320,324 **** op->ob_sinterned = NULL; #endif - _Py_NewReference((PyObject *)op); memcpy(op->ob_sval, a->ob_sval, (int) a->ob_size); memcpy(op->ob_sval + a->ob_size, b->ob_sval, (int) b->ob_size); --- 320,323 ---- *************** *** 343,352 **** return (PyObject *)a; } op = (PyStringObject *) ! malloc(sizeof(PyStringObject) + size * sizeof(char)); if (op == NULL) return PyErr_NoMemory(); ! op->ob_type = &PyString_Type; ! op->ob_size = size; #ifdef CACHE_HASH op->ob_shash = -1; --- 342,351 ---- return (PyObject *)a; } + /* PyObject_NewVar is inlined */ op = (PyStringObject *) ! PyObject_MALLOC(sizeof(PyStringObject) + size * sizeof(char)); if (op == NULL) return PyErr_NoMemory(); ! PyObject_INIT_VAR(op, &PyString_Type, size); #ifdef CACHE_HASH op->ob_shash = -1; *************** *** 355,359 **** op->ob_sinterned = NULL; #endif - _Py_NewReference((PyObject *)op); for (i = 0; i < size; i += a->ob_size) memcpy(op->ob_sval+i, a->ob_sval, (int) a->ob_size); --- 354,357 ---- *************** *** 1499,1503 **** new_len = len + nfound*(sub_len - pat_len); ! new_s = (char *)malloc(new_len); if (new_s == NULL) return NULL; --- 1497,1501 ---- new_len = len + nfound*(sub_len - pat_len); ! new_s = (char *)PyMem_MALLOC(new_len); if (new_s == NULL) return NULL; *************** *** 1594,1598 **** else { new = PyString_FromStringAndSize(new_s, out_len); ! free(new_s); } return new; --- 1592,1596 ---- else { new = PyString_FromStringAndSize(new_s, out_len); ! PyMem_FREE(new_s); } return new; *************** *** 2274,2281 **** _Py_ForgetReference(v); *pv = (PyObject *) ! realloc((char *)v, sizeof(PyStringObject) + newsize * sizeof(char)); if (*pv == NULL) { ! PyMem_DEL(v); PyErr_NoMemory(); return -1; --- 2272,2279 ---- _Py_ForgetReference(v); *pv = (PyObject *) ! PyObject_REALLOC((char *)v, sizeof(PyStringObject) + newsize * sizeof(char)); if (*pv == NULL) { ! PyObject_DEL(v); PyErr_NoMemory(); return -1; Index: tupleobject.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Objects/tupleobject.c,v retrieving revision 2.32 retrieving revision 2.33 diff -C2 -r2.32 -r2.33 *** tupleobject.c 2000/04/27 21:41:03 2.32 --- tupleobject.c 2000/05/03 23:44:36 2.33 *************** *** 81,88 **** fast_tuple_allocs++; #endif #ifdef Py_TRACE_REFS - op->ob_type = &PyTuple_Type; op->ob_size = size; #endif } else --- 81,90 ---- fast_tuple_allocs++; #endif + /* PyObject_InitVar is inlined */ #ifdef Py_TRACE_REFS op->ob_size = size; + op->ob_type = &PyTuple_Type; #endif + _Py_NewReference((PyObject *)op); } else *************** *** 97,111 **** return PyErr_NoMemory(); } ! ; ! op = (PyTupleObject *) malloc(nbytes); if (op == NULL) return PyErr_NoMemory(); ! op->ob_type = &PyTuple_Type; ! op->ob_size = size; } for (i = 0; i < size; i++) op->ob_item[i] = NULL; - _Py_NewReference((PyObject *)op); #if MAXSAVESIZE > 0 if (size == 0) { --- 99,111 ---- return PyErr_NoMemory(); } ! /* PyObject_NewVar is inlined */ ! op = (PyTupleObject *) PyObject_MALLOC(nbytes); if (op == NULL) return PyErr_NoMemory(); ! PyObject_INIT_VAR(op, &PyTuple_Type, size); } for (i = 0; i < size; i++) op->ob_item[i] = NULL; #if MAXSAVESIZE > 0 if (size == 0) { *************** *** 194,198 **** #endif } ! free((ANY *)op); done: Py_TRASHCAN_SAFE_END(op) --- 194,198 ---- #endif } ! PyObject_DEL(op); done: Py_TRASHCAN_SAFE_END(op) *************** *** 531,539 **** { sv = (PyTupleObject *) ! realloc((char *)v, sizeof(PyTupleObject) + newsize * sizeof(PyObject *)); *pv = (PyObject *) sv; if (sv == NULL) { ! PyMem_DEL(v); PyErr_NoMemory(); return -1; --- 531,539 ---- { sv = (PyTupleObject *) ! PyObject_REALLOC((char *)v, sizeof(PyTupleObject) + newsize * sizeof(PyObject *)); *pv = (PyObject *) sv; if (sv == NULL) { ! PyObject_DEL(v); PyErr_NoMemory(); return -1; *************** *** 570,574 **** q = p; p = (PyTupleObject *)(p->ob_item[0]); ! PyMem_DEL(q); } } --- 570,574 ---- q = p; p = (PyTupleObject *)(p->ob_item[0]); ! PyObject_DEL(q); } } Index: unicodeobject.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.15 retrieving revision 2.16 diff -C2 -r2.15 -r2.16 *** unicodeobject.c 2000/05/03 12:27:22 2.15 --- unicodeobject.c 2000/05/03 23:44:36 2.16 *************** *** 201,206 **** unicode_freelist = *(PyUnicodeObject **)unicode_freelist; unicode_freelist_size--; ! unicode->ob_type = &PyUnicode_Type; ! _Py_NewReference((PyObject *)unicode); if (unicode->str) { /* Keep-Alive optimization: we only upsize the buffer, --- 201,205 ---- unicode_freelist = *(PyUnicodeObject **)unicode_freelist; unicode_freelist_size--; ! PyObject_INIT(unicode, &PyUnicode_Type); if (unicode->str) { /* Keep-Alive optimization: we only upsize the buffer, *************** *** 208,212 **** if ((unicode->length < length) && _PyUnicode_Resize(unicode, length)) { ! free(unicode->str); goto onError; } --- 207,211 ---- if ((unicode->length < length) && _PyUnicode_Resize(unicode, length)) { ! PyMem_DEL(unicode->str); goto onError; } *************** *** 234,238 **** onError: _Py_ForgetReference((PyObject *)unicode); ! PyMem_DEL(unicode); return NULL; } --- 233,237 ---- onError: _Py_ForgetReference((PyObject *)unicode); ! PyObject_DEL(unicode); return NULL; } *************** *** 244,248 **** /* Keep-Alive optimization */ if (unicode->length >= KEEPALIVE_SIZE_LIMIT) { ! free(unicode->str); unicode->str = NULL; unicode->length = 0; --- 243,247 ---- /* Keep-Alive optimization */ if (unicode->length >= KEEPALIVE_SIZE_LIMIT) { ! PyMem_DEL(unicode->str); unicode->str = NULL; unicode->length = 0; *************** *** 258,264 **** } else { ! free(unicode->str); Py_XDECREF(unicode->utf8str); ! PyMem_DEL(unicode); } } --- 257,263 ---- } else { ! PyMem_DEL(unicode->str); Py_XDECREF(unicode->utf8str); ! PyObject_DEL(unicode); } } *************** *** 4663,4669 **** u = *(PyUnicodeObject **)u; if (v->str) ! free(v->str); Py_XDECREF(v->utf8str); ! free(v); } Py_XDECREF(unicode_empty); --- 4662,4668 ---- u = *(PyUnicodeObject **)u; if (v->str) ! PyMem_DEL(v->str); Py_XDECREF(v->utf8str); ! PyObject_DEL(v); } Py_XDECREF(unicode_empty); Index: xxobject.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Objects/xxobject.c,v retrieving revision 2.14 retrieving revision 2.15 diff -C2 -r2.14 -r2.15 *** xxobject.c 1999/01/29 14:39:12 2.14 --- xxobject.c 2000/05/03 23:44:36 2.15 *************** *** 72,76 **** { Py_XDECREF(xp->x_attr); ! PyMem_DEL(xp); } --- 72,76 ---- { Py_XDECREF(xp->x_attr); ! PyObject_DEL(xp); } From python-dev@python.org Thu May 4 00:45:14 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 3 May 2000 19:45:14 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.157,2.158 ceval.c,2.176,2.177 compile.c,2.107,2.108 import.c,2.133,2.134 marshal.c,1.46,1.47 pythonrun.c,2.95,2.96 traceback.c,2.26,2.27 Message-ID: <200005032345.TAA06666@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Python In directory eric:/projects/python/develop/guido/clean/Python Modified Files: bltinmodule.c ceval.c compile.c import.c marshal.c pythonrun.c traceback.c Log Message: Vladimir Marangozov's long-awaited malloc restructuring. For more comments, read the patches@python.org archives. For documentation read the comments in mymalloc.h and objimpl.h. (This is not exactly what Vladimir posted to the patches list; I've made a few changes, and Vladimir sent me a fix in private email for a problem that only occurs in debug mode. I'm also holding back on his change to main.c, which seems unnecessary to me.) Index: bltinmodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.157 retrieving revision 2.158 diff -C2 -r2.157 -r2.158 *** bltinmodule.c 2000/05/03 22:03:46 2.157 --- bltinmodule.c 2000/05/03 23:44:38 2.158 *************** *** 1876,1880 **** result = PyString_FromStringAndSize(s, strlen(s)-1); } ! free(s); return result; } --- 1876,1880 ---- result = PyString_FromStringAndSize(s, strlen(s)-1); } ! PyMem_FREE(s); return result; } Index: ceval.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Python/ceval.c,v retrieving revision 2.176 retrieving revision 2.177 diff -C2 -r2.176 -r2.177 *** ceval.c 2000/04/21 21:17:39 2.176 --- ceval.c 2000/05/03 23:44:38 2.177 *************** *** 2559,2563 **** Py_DECREF(arg); ! PyMem_XDEL(k); return result; --- 2559,2564 ---- Py_DECREF(arg); ! if (k != NULL) ! PyMem_DEL(k); return result; Index: compile.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Python/compile.c,v retrieving revision 2.107 retrieving revision 2.108 diff -C2 -r2.107 -r2.108 *** compile.c 2000/05/01 17:54:56 2.107 --- compile.c 2000/05/03 23:44:38 2.108 *************** *** 113,117 **** Py_XDECREF(co->co_name); Py_XDECREF(co->co_lnotab); ! PyMem_DEL(co); } --- 113,117 ---- Py_XDECREF(co->co_name); Py_XDECREF(co->co_lnotab); ! PyObject_DEL(co); } Index: import.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Python/import.c,v retrieving revision 2.133 retrieving revision 2.134 diff -C2 -r2.133 -r2.134 *** import.c 2000/05/01 20:19:08 2.133 --- import.c 2000/05/03 23:44:39 2.134 *************** *** 125,129 **** for (scan = _PyImport_StandardFiletab; scan->suffix != NULL; ++scan) ++countS; ! filetab = malloc((countD + countS + 1) * sizeof(struct filedescr)); memcpy(filetab, _PyImport_DynLoadFiletab, countD * sizeof(struct filedescr)); --- 125,129 ---- for (scan = _PyImport_StandardFiletab; scan->suffix != NULL; ++scan) ++countS; ! filetab = PyMem_NEW(struct filedescr, countD + countS + 1); memcpy(filetab, _PyImport_DynLoadFiletab, countD * sizeof(struct filedescr)); *************** *** 2399,2406 **** ! /* API for embedding applications that want to add their own entries to the ! table of built-in modules. This should normally be called *before* ! Py_Initialize(). When the malloc() or realloc() call fails, -1 is returned ! and the existing table is unchanged. After a similar function by Just van Rossum. */ --- 2399,2406 ---- ! /* API for embedding applications that want to add their own entries ! to the table of built-in modules. This should normally be called ! *before* Py_Initialize(). When the table resize fails, -1 is ! returned and the existing table is unchanged. After a similar function by Just van Rossum. */ *************** *** 2423,2430 **** /* Allocate new memory for the combined table */ ! if (our_copy == NULL) ! p = malloc((i+n+1) * sizeof(struct _inittab)); ! else ! p = realloc(our_copy, (i+n+1) * sizeof(struct _inittab)); if (p == NULL) return -1; --- 2423,2428 ---- /* Allocate new memory for the combined table */ ! p = our_copy; ! PyMem_RESIZE(p, struct _inittab, i+n+1); if (p == NULL) return -1; Index: marshal.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Python/marshal.c,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -r1.46 -r1.47 *** marshal.c 2000/03/31 00:37:41 1.46 --- marshal.c 2000/05/03 23:44:39 1.47 *************** *** 515,523 **** return NULL; } ! buffer = (char *)Py_Malloc(n); if (buffer == NULL) ! return NULL; if (r_string(buffer, (int)n, p) != n) { ! free(buffer); PyErr_SetString(PyExc_EOFError, "EOF read where object expected"); --- 515,523 ---- return NULL; } ! buffer = PyMem_NEW(char, n); if (buffer == NULL) ! return PyErr_NoMemory(); if (r_string(buffer, (int)n, p) != n) { ! PyMem_DEL(buffer); PyErr_SetString(PyExc_EOFError, "EOF read where object expected"); *************** *** 525,529 **** } v = PyUnicode_DecodeUTF8(buffer, n, NULL); ! free(buffer); return v; } --- 525,529 ---- } v = PyUnicode_DecodeUTF8(buffer, n, NULL); ! PyMem_DEL(buffer); return v; } Index: pythonrun.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Python/pythonrun.c,v retrieving revision 2.95 retrieving revision 2.96 diff -C2 -r2.95 -r2.96 *** pythonrun.c 2000/05/02 19:18:59 2.95 --- pythonrun.c 2000/05/03 23:44:39 2.96 *************** *** 544,548 **** if (err.error == E_EOF) { if (err.text) ! free(err.text); return E_EOF; } --- 544,548 ---- if (err.error == E_EOF) { if (err.text) ! PyMem_DEL(err.text); return E_EOF; } *************** *** 1010,1014 **** err->lineno, err->offset, err->text); if (err->text != NULL) { ! free(err->text); err->text = NULL; } --- 1010,1014 ---- err->lineno, err->offset, err->text); if (err->text != NULL) { ! PyMem_DEL(err->text); err->text = NULL; } Index: traceback.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Python/traceback.c,v retrieving revision 2.26 retrieving revision 2.27 diff -C2 -r2.26 -r2.27 *** traceback.c 2000/03/31 00:39:23 2.26 --- traceback.c 2000/05/03 23:44:39 2.27 *************** *** 72,76 **** Py_XDECREF(tb->tb_next); Py_XDECREF(tb->tb_frame); ! PyMem_DEL(tb); Py_TRASHCAN_SAFE_END(tb) } --- 72,76 ---- Py_XDECREF(tb->tb_next); Py_XDECREF(tb->tb_frame); ! PyObject_DEL(tb); Py_TRASHCAN_SAFE_END(tb) } From python-dev@python.org Thu May 4 00:58:32 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 3 May 2000 19:58:32 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.16,2.17 Message-ID: <200005032358.TAA07241@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Objects In directory eric:/projects/python/develop/guido/src/Objects Modified Files: unicodeobject.c Log Message: Fix warning detected by VC++ on assignment of Py_UNICODE to char. Index: unicodeobject.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.16 retrieving revision 2.17 diff -C2 -r2.16 -r2.17 *** unicodeobject.c 2000/05/03 23:44:36 2.16 --- unicodeobject.c 2000/05/03 23:58:29 2.17 *************** *** 2014,2018 **** } if (0 < ch && ch < 256) { ! *output++ = ch; continue; } --- 2014,2018 ---- } if (0 < ch && ch < 256) { ! *output++ = (char)ch; continue; } From python-dev@python.org Thu May 4 01:36:45 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 3 May 2000 20:36:45 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_fork1.py,1.3,1.4 Message-ID: <200005040036.UAA07408@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Lib/test In directory eric:/projects/python/develop/guido/src/Lib/test Modified Files: test_fork1.py Log Message: Raise ImportError when os.fork does not exist. Index: test_fork1.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/test/test_fork1.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** test_fork1.py 2000/04/24 14:07:03 1.3 --- test_fork1.py 2000/05/04 00:36:42 1.4 *************** *** 11,14 **** --- 11,19 ---- import os, sys, time, thread + try: + os.fork + except AttributeError: + raise ImportError, "os.fork not defined -- skipping test_fork1" + LONGSLEEP = 2 From python-dev@python.org Thu May 4 01:55:20 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 3 May 2000 20:55:20 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Python ceval.c,2.177,2.178 Message-ID: <200005040055.UAA07941@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Python In directory eric:/projects/python/develop/guido/src/Python Modified Files: ceval.c Log Message: Add useless 'return 1' to prtrace() to shut up VC++. Index: ceval.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Python/ceval.c,v retrieving revision 2.177 retrieving revision 2.178 diff -C2 -r2.177 -r2.178 *** ceval.c 2000/05/03 23:44:38 2.177 --- ceval.c 2000/05/04 00:55:17 2.178 *************** *** 2177,2180 **** --- 2177,2181 ---- PyErr_Clear(); /* Don't know what else to do */ printf("\n"); + return 1; } #endif From python-dev@python.org Thu May 4 16:07:19 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 4 May 2000 11:07:19 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Modules _tkinter.c,1.97,1.98 Message-ID: <200005041507.LAA10665@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Modules In directory eric:/projects/python/develop/guido/src/Modules Modified Files: _tkinter.c Log Message: Two changes to improve (I hope) Unicode support. 1. In Tcl 8.2 and later, use Tcl_NewUnicodeObj() when passing a Python Unicode object rather than going through UTF-8. (This function doesn't exist in Tcl 8.1, so there the original UTF-8 code is still used; in Tcl 8.0 there is no support for Unicode.) This assumes that Tcl_UniChar is the same thing as Py_UNICODE; a run-time error is issued if this is not the case. 2. In Tcl 8.1 and later (i.e., whenever Tcl supports Unicode), when a string returned from Tcl contains bytes with the top bit set, we assume it is encoded in UTF-8, and decode it into a Unicode string object. Notes: - Passing Unicode strings to Tcl 8.0 does not do the right thing; this isn't worth fixing. - When passing an 8-bit string to Tcl 8.1 or later that has bytes with the top bit set, Tcl tries to interpret it as UTF-8; it seems to fall back on Latin-1 for non-UTF-8 bytes. I'm not sure what to do about this besides telling the user to disambiguate such strings by converting them to Unicode (forcing the user to be explicit about the encoding). - Obviously it won't be possible to get binary data out of Tk this way. Do we need that ability? How to do it? Index: _tkinter.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/_tkinter.c,v retrieving revision 1.97 retrieving revision 1.98 diff -C2 -r1.97 -r1.98 *** _tkinter.c 2000/05/03 23:44:31 1.97 --- _tkinter.c 2000/05/04 15:07:16 1.98 *************** *** 551,554 **** --- 551,556 ---- } else if (PyUnicode_Check(value)) { + #if TKMAJORMINOR <= 8001 + /* In Tcl 8.1 we must use UTF-8 */ PyObject* utf8 = PyUnicode_AsUTF8String (value); if (!utf8) *************** *** 558,561 **** --- 560,574 ---- Py_DECREF(utf8); return result; + #else /* TKMAJORMINOR > 8001 */ + /* In Tcl 8.2 and later, use Tcl_NewUnicodeObj() */ + if (sizeof(Py_UNICODE) != sizeof(Tcl_UniChar)) { + /* XXX Should really test this at compile time */ + PyErr_SetString(PyExc_SystemError, + "Py_UNICODE and Tcl_UniChar differ in size"); + return 0; + } + return Tcl_NewUnicodeObj(PyUnicode_AS_UNICODE(value), + PyUnicode_GET_SIZE(value)); + #endif /* TKMAJORMINOR > 8001 */ } else { *************** *** 625,632 **** if (i == TCL_ERROR) Tkinter_Error(self); ! else /* We could request the object result here, but doing so would confuse applications that expect a string. */ ! res = PyString_FromString(Tcl_GetStringResult(interp)); LEAVE_OVERLAP_TCL --- 638,661 ---- if (i == TCL_ERROR) Tkinter_Error(self); ! else { /* We could request the object result here, but doing so would confuse applications that expect a string. */ ! char *s = Tcl_GetStringResult(interp); ! char *p = s; ! /* If the result contains any bytes with the top bit set, ! it's UTF-8 and we should decode it to Unicode */ ! while (*p != '\0') { ! if (*p & 0x80) ! break; ! p++; ! } ! if (*p == '\0') ! res = PyString_FromStringAndSize(s, (int)(p-s)); ! else { ! /* Convert UTF-8 to Unicode string */ ! p = strchr(p, '\0'); ! res = PyUnicode_DecodeUTF8(s, (int)(p-s), "ignore"); ! } ! } LEAVE_OVERLAP_TCL From python-dev@python.org Thu May 4 16:52:23 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 4 May 2000 11:52:23 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.17,2.18 Message-ID: <200005041552.LAA13355@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Objects In directory eric:/projects/python/develop/guido/src/Objects Modified Files: unicodeobject.c Log Message: Mark Hammond should get his act into gear (his words :-). Zero length strings _are_ valid! Index: unicodeobject.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.17 retrieving revision 2.18 diff -C2 -r2.17 -r2.18 *** unicodeobject.c 2000/05/03 23:58:29 2.17 --- unicodeobject.c 2000/05/04 15:52:20 2.18 *************** *** 1555,1559 **** /* First get the size of the result */ DWORD usize = MultiByteToWideChar(CP_ACP, 0, s, size, NULL, 0); ! if (usize==0) return PyErr_SetFromWindowsErrWithFilename(0, NULL); --- 1555,1559 ---- /* First get the size of the result */ DWORD usize = MultiByteToWideChar(CP_ACP, 0, s, size, NULL, 0); ! if (size > 0 && usize==0) return PyErr_SetFromWindowsErrWithFilename(0, NULL); *************** *** 1578,1584 **** PyObject *repr; char *s; /* First get the size of the result */ ! DWORD mbcssize = WideCharToMultiByte(CP_ACP, 0, p, size, NULL, 0, NULL, NULL); if (mbcssize==0) return PyErr_SetFromWindowsErrWithFilename(0, NULL); --- 1578,1589 ---- PyObject *repr; char *s; + DWORD mbcssize; + /* If there are no characters, bail now! */ + if (size==0) + return PyString_FromString(""); + /* First get the size of the result */ ! mbcssize = WideCharToMultiByte(CP_ACP, 0, p, size, NULL, 0, NULL, NULL); if (mbcssize==0) return PyErr_SetFromWindowsErrWithFilename(0, NULL); From python-dev@python.org Thu May 4 16:55:20 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 4 May 2000 11:55:20 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Modules _tkinter.c,1.98,1.99 Message-ID: <200005041555.LAA13390@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Modules In directory eric:/projects/python/develop/guido/src/Modules Modified Files: _tkinter.c Log Message: When the UTF-8 conversion to Unicode fails, return an 8-bit string instead. This seems more robust than returning an Unicode string with some unconverted charcters in it. This still doesn't support getting truly binary data out of Tcl, since we look for the trailing null byte; but the old (pre-Unicode) code did this too, so apparently there's no need. (Plus, I really don't feel like finding out how Tcl deals with this in each version.) Index: _tkinter.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/_tkinter.c,v retrieving revision 1.98 retrieving revision 1.99 diff -C2 -r1.98 -r1.99 *** _tkinter.c 2000/05/04 15:07:16 1.98 --- _tkinter.c 2000/05/04 15:55:17 1.99 *************** *** 655,659 **** /* Convert UTF-8 to Unicode string */ p = strchr(p, '\0'); ! res = PyUnicode_DecodeUTF8(s, (int)(p-s), "ignore"); } } --- 655,663 ---- /* Convert UTF-8 to Unicode string */ p = strchr(p, '\0'); ! res = PyUnicode_DecodeUTF8(s, (int)(p-s), "strict"); ! if (res == NULL) { ! PyErr_Clear(); ! res = PyString_FromStringAndSize(s, (int)(p-s)); ! } } } From python-dev@python.org Thu May 4 19:47:19 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 4 May 2000 14:47:19 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Python thread_nt.h,2.6,2.7 Message-ID: <200005041847.OAA13707@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Python In directory eric:/projects/python/develop/guido/src/Python Modified Files: thread_nt.h Log Message: Fast NonRecursiveMutex support by Yakov Markovitch, markovitch@iso.ru, who wrote: Here's the new version of thread_nt.h. More particular, there is a new version of thread lock that uses kernel object (e.g. semaphore) only in case of contention; in other case it simply uses interlocked functions, which are faster by the order of magnitude. It doesn't make much difference without threads present, but as soon as thread machinery initialised and (mostly) the interpreter global lock is on, difference becomes tremendous. I've included a small script, which initialises threads and launches pystone. With original thread_nt.h, Pystone results with initialised threads are twofold worse then w/o threads. With the new version, only 10% worse. I have used this patch for about 6 months (with threaded and non-threaded applications). It works remarkably well (though I'd desperately prefer Python was free-threaded; I hope, it will soon). Index: thread_nt.h =================================================================== RCS file: /projects/cvsroot/python/dist/src/Python/thread_nt.h,v retrieving revision 2.6 retrieving revision 2.7 diff -C2 -r2.6 -r2.7 *** thread_nt.h 2000/01/20 22:32:56 2.6 --- thread_nt.h 2000/05/04 18:47:15 2.7 *************** *** 31,34 **** --- 31,35 ---- /* This code implemented by Dag.Gruneau@elsa.preseco.comm.se */ + /* Fast NonRecursiveMutex support by Yakov Markovitch, markovitch@iso.ru */ #include *************** *** 36,39 **** --- 37,141 ---- #include + typedef struct NRMUTEX { + LONG owned ; + DWORD thread_id ; + HANDLE hevent ; + } NRMUTEX, *PNRMUTEX ; + + + typedef PVOID WINAPI interlocked_cmp_xchg_t(PVOID *dest, PVOID exc, PVOID comperand) ; + + /* Sorry mate, but we haven't got InterlockedCompareExchange in Win95! */ + static PVOID WINAPI interlocked_cmp_xchg(PVOID *dest, PVOID exc, PVOID comperand) + { + static LONG spinlock = 0 ; + PVOID result ; + + /* Acqire spinlock (yielding control to other threads if cant aquire for the moment) */ + while(InterlockedExchange(&spinlock, 1)) Sleep(0) ; + result = *dest ; + if (result == comperand) + *dest = exc ; + /* Release spinlock */ + spinlock = 0 ; + return result ; + } ; + + static interlocked_cmp_xchg_t *ixchg ; + BOOL InitializeNonRecursiveMutex(PNRMUTEX mutex) + { + if (!ixchg) + { + /* Sorely, Win95 has no InterlockedCompareExchange API (Win98 has), so we have to use emulation */ + HANDLE kernel = GetModuleHandle("kernel32.dll") ; + if (!kernel || (ixchg = (interlocked_cmp_xchg_t *)GetProcAddress(kernel, "InterlockedCompareExchange")) == NULL) + ixchg = interlocked_cmp_xchg ; + } + + mutex->owned = -1 ; /* No threads have entered NonRecursiveMutex */ + mutex->thread_id = 0 ; + mutex->hevent = CreateEvent(NULL, FALSE, FALSE, NULL) ; + return mutex->hevent != NULL ; /* TRUE if the mutex is created */ + } + + #define InterlockedCompareExchange(dest,exchange,comperand) (ixchg((dest), (exchange), (comperand))) + + VOID DeleteNonRecursiveMutex(PNRMUTEX mutex) + { + /* No in-use check */ + CloseHandle(mutex->hevent) ; + mutex->hevent = NULL ; /* Just in case */ + } + + DWORD EnterNonRecursiveMutex(PNRMUTEX mutex, BOOL wait) + { + /* Assume that the thread waits successfully */ + DWORD ret ; + + /* InterlockedIncrement(&mutex->owned) == 0 means that no thread currently owns the mutex */ + if (!wait) + { + if (InterlockedCompareExchange((PVOID *)&mutex->owned, (PVOID)0, (PVOID)-1) != (PVOID)-1) + return WAIT_TIMEOUT ; + ret = WAIT_OBJECT_0 ; + } + else + ret = InterlockedIncrement(&mutex->owned) ? + /* Some thread owns the mutex, let's wait... */ + WaitForSingleObject(mutex->hevent, INFINITE) : WAIT_OBJECT_0 ; + + mutex->thread_id = GetCurrentThreadId() ; /* We own it */ + return ret ; + } + + BOOL LeaveNonRecursiveMutex(PNRMUTEX mutex) + { + /* We don't own the mutex */ + mutex->thread_id = 0 ; + return + InterlockedDecrement(&mutex->owned) < 0 || + SetEvent(mutex->hevent) ; /* Other threads are waiting, wake one on them up */ + } + + PNRMUTEX AllocNonRecursiveMutex() + { + PNRMUTEX mutex = (PNRMUTEX)malloc(sizeof(NRMUTEX)) ; + if (mutex && !InitializeNonRecursiveMutex(mutex)) + { + free(mutex) ; + mutex = NULL ; + } + return mutex ; + } + + void FreeNonRecursiveMutex(PNRMUTEX mutex) + { + if (mutex) + { + DeleteNonRecursiveMutex(mutex) ; + free(mutex) ; + } + } + long PyThread_get_thread_ident(void); *************** *** 66,70 **** if (rv != -1) { success = 1; ! dprintf(("%ld: PyThread_start_new_thread succeeded: %ld\n", PyThread_get_thread_ident(), rv)); } --- 168,172 ---- if (rv != -1) { success = 1; ! dprintf(("%ld: PyThread_start_new_thread succeeded: %ld\n", PyThread_get_thread_ident(), aThreadId)); } *************** *** 80,84 **** if (!initialized) PyThread_init_thread(); ! return GetCurrentThreadId(); } --- 182,186 ---- if (!initialized) PyThread_init_thread(); ! return GetCurrentThreadId(); } *************** *** 134,138 **** PyThread_type_lock PyThread_allocate_lock(void) { ! HANDLE aLock; dprintf(("PyThread_allocate_lock called\n")); --- 236,240 ---- PyThread_type_lock PyThread_allocate_lock(void) { ! PNRMUTEX aLock; dprintf(("PyThread_allocate_lock called\n")); *************** *** 140,148 **** PyThread_init_thread(); ! aLock = CreateSemaphore(NULL, /* Security attributes */ ! 1, /* Initial value */ ! 1, /* Maximum value */ ! NULL); ! /* Name of semaphore */ dprintf(("%ld: PyThread_allocate_lock() -> %lx\n", PyThread_get_thread_ident(), (long)aLock)); --- 242,246 ---- PyThread_init_thread(); ! aLock = AllocNonRecursiveMutex() ; dprintf(("%ld: PyThread_allocate_lock() -> %lx\n", PyThread_get_thread_ident(), (long)aLock)); *************** *** 155,159 **** dprintf(("%ld: PyThread_free_lock(%lx) called\n", PyThread_get_thread_ident(),(long)aLock)); ! CloseHandle((HANDLE) aLock); } --- 253,257 ---- dprintf(("%ld: PyThread_free_lock(%lx) called\n", PyThread_get_thread_ident(),(long)aLock)); ! FreeNonRecursiveMutex(aLock) ; } *************** *** 166,179 **** int PyThread_acquire_lock(PyThread_type_lock aLock, int waitflag) { ! int success = 1; ! DWORD waitResult; dprintf(("%ld: PyThread_acquire_lock(%lx, %d) called\n", PyThread_get_thread_ident(),(long)aLock, waitflag)); - - waitResult = WaitForSingleObject((HANDLE) aLock, (waitflag == 1 ? INFINITE : 0)); ! if (waitResult != WAIT_OBJECT_0) { ! success = 0; /* We failed */ ! } dprintf(("%ld: PyThread_acquire_lock(%lx, %d) -> %d\n", PyThread_get_thread_ident(),(long)aLock, waitflag, success)); --- 264,272 ---- int PyThread_acquire_lock(PyThread_type_lock aLock, int waitflag) { ! int success ; dprintf(("%ld: PyThread_acquire_lock(%lx, %d) called\n", PyThread_get_thread_ident(),(long)aLock, waitflag)); ! success = aLock && EnterNonRecursiveMutex((PNRMUTEX) aLock, (waitflag == 1 ? INFINITE : 0)) == WAIT_OBJECT_0 ; dprintf(("%ld: PyThread_acquire_lock(%lx, %d) -> %d\n", PyThread_get_thread_ident(),(long)aLock, waitflag, success)); *************** *** 186,196 **** dprintf(("%ld: PyThread_release_lock(%lx) called\n", PyThread_get_thread_ident(),(long)aLock)); ! if (!ReleaseSemaphore( ! (HANDLE) aLock, /* Handle of semaphore */ ! 1, /* increment count by one */ ! NULL)) /* not interested in previous count */ ! { dprintf(("%ld: Could not PyThread_release_lock(%lx) error: %l\n", PyThread_get_thread_ident(), (long)aLock, GetLastError())); - } } --- 279,284 ---- dprintf(("%ld: PyThread_release_lock(%lx) called\n", PyThread_get_thread_ident(),(long)aLock)); ! if (!(aLock && LeaveNonRecursiveMutex((PNRMUTEX) aLock))) dprintf(("%ld: Could not PyThread_release_lock(%lx) error: %l\n", PyThread_get_thread_ident(), (long)aLock, GetLastError())); } *************** *** 207,213 **** aSemaphore = CreateSemaphore( NULL, /* Security attributes */ ! value, /* Initial value */ ! INT_MAX, /* Maximum value */ ! NULL); /* Name of semaphore */ dprintf(("%ld: PyThread_allocate_sema() -> %lx\n", PyThread_get_thread_ident(), (long)aSemaphore)); --- 295,301 ---- aSemaphore = CreateSemaphore( NULL, /* Security attributes */ ! value, /* Initial value */ ! INT_MAX, /* Maximum value */ ! NULL); /* Name of semaphore */ dprintf(("%ld: PyThread_allocate_sema() -> %lx\n", PyThread_get_thread_ident(), (long)aSemaphore)); From python-dev@python.org Fri May 5 15:27:42 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 5 May 2000 10:27:42 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Lib/test regrtest.py,1.15,1.16 Message-ID: <200005051427.KAA14079@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Lib/test In directory eric:/projects/python/develop/guido/src/Lib/test Modified Files: regrtest.py Log Message: Alas, Vladimir's patch was too aggressive, and started causing really weird errors. (E.g. see thread "weird bug in test_winreg" in python-dev.) Since it's actually useful to be able to re-run an individual test after running test.autotest, we keep the unloading code, but only for modules whose full name starts with "test.". Index: regrtest.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/test/regrtest.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** regrtest.py 2000/04/21 21:35:06 1.15 --- regrtest.py 2000/05/05 14:27:39 1.16 *************** *** 122,126 **** # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): ! if module not in save_modules: test_support.unload(module) if good and not quiet: --- 122,126 ---- # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): ! if module not in save_modules and module.startswith("test."): test_support.unload(module) if good and not quiet: From python-dev@python.org Fri May 5 15:30:02 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 5 May 2000 10:30:02 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Python thread_nt.h,2.7,2.8 Message-ID: <200005051430.KAA14105@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Python In directory eric:/projects/python/develop/guido/src/Python Modified Files: thread_nt.h Log Message: Quick fix by Mark Hammond -- Yakov changed a dprintf call but it was referencing an undefined variable, so we better change it back. Index: thread_nt.h =================================================================== RCS file: /projects/cvsroot/python/dist/src/Python/thread_nt.h,v retrieving revision 2.7 retrieving revision 2.8 diff -C2 -r2.7 -r2.8 *** thread_nt.h 2000/05/04 18:47:15 2.7 --- thread_nt.h 2000/05/05 14:29:59 2.8 *************** *** 168,172 **** if (rv != -1) { success = 1; ! dprintf(("%ld: PyThread_start_new_thread succeeded: %ld\n", PyThread_get_thread_ident(), aThreadId)); } --- 168,172 ---- if (rv != -1) { success = 1; ! dprintf(("%ld: PyThread_start_new_thread succeeded: %ld\n", PyThread_get_thread_ident(), rv)); } From python-dev@python.org Fri May 5 16:36:12 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 5 May 2000 11:36:12 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Include mymalloc.h,2.18,2.19 Message-ID: <200005051536.LAA14493@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Include In directory eric:/projects/python/develop/guido/src/Include Modified Files: mymalloc.h Log Message: Add two scenarios by Vladimir Marangozov that show how to use your own allocator. Index: mymalloc.h =================================================================== RCS file: /projects/cvsroot/python/dist/src/Include/mymalloc.h,v retrieving revision 2.18 retrieving revision 2.19 diff -C2 -r2.18 -r2.19 *** mymalloc.h 2000/05/03 23:44:23 2.18 --- mymalloc.h 2000/05/05 15:36:09 2.19 *************** *** 96,101 **** The PyCore_* macros can be defined to make the interpreter use a custom allocator. Note that they are for internal use only. Both ! the core and extension modules should use the PyMem_* API. */ #ifndef PyCore_MALLOC_FUNC #undef PyCore_REALLOC_FUNC --- 96,104 ---- The PyCore_* macros can be defined to make the interpreter use a custom allocator. Note that they are for internal use only. Both ! the core and extension modules should use the PyMem_* API. + See the comment block at the end of this file for two scenarios + showing how to use this to use a different allocator. */ + #ifndef PyCore_MALLOC_FUNC #undef PyCore_REALLOC_FUNC *************** *** 200,203 **** --- 203,245 ---- } #endif + + /* SCENARIOS + + Here are two scenarios by Vladimir Marangozov (the author of the + memory allocation redesign). + + 1) Scenario A + + Suppose you want to use a debugging malloc library that collects info on + where the malloc calls originate from. Assume the interface is: + + d_malloc(size_t n, char* src_file, unsigned long src_line) c.s. + + In this case, you would define (for example in config.h) : + + #define PyCore_MALLOC_FUNC d_malloc + ... + #define PyCore_MALLOC_PROTO Py_PROTO((size_t, char *, unsigned long)) + ... + #define NEED_TO_DECLARE_MALLOC_AND_FRIEND + + #define PyCore_MALLOC(n) PyCore_MALLOC_FUNC((n), __FILE__, __LINE__) + ... + + 2) Scenario B + + Suppose you want to use malloc hooks (defined & initialized in a 3rd party + malloc library) instead of malloc functions. In this case, you would + define: + + #define PyCore_MALLOC_FUNC (*malloc_hook) + ... + #define NEED_TO_DECLARE_MALLOC_AND_FRIEND + + and ignore the previous definitions about PyCore_MALLOC_FUNC, etc. + + + */ + #endif /* !Py_MYMALLOC_H */ From python-dev@python.org Fri May 5 21:44:27 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 5 May 2000 16:44:27 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Objects stringobject.c,2.63,2.64 Message-ID: <200005052044.QAA14950@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Objects In directory eric:/projects/python/develop/guido/src/Objects Modified Files: stringobject.c Log Message: The methods islower(), isupper(), isspace(), isdigit() and istitle() gave bogus results for chars in the range 128-255, because their implementation was using signed characters. Fixed this by using unsigned character pointers (as opposed to using Py_CHARMASK()). Index: stringobject.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Objects/stringobject.c,v retrieving revision 2.63 retrieving revision 2.64 diff -C2 -r2.63 -r2.64 *** stringobject.c 2000/05/03 23:44:35 2.63 --- stringobject.c 2000/05/05 20:44:24 2.64 *************** *** 1911,1916 **** string_isspace(PyStringObject *self, PyObject *args) { ! register const char *p = PyString_AS_STRING(self); ! register const char *e; if (!PyArg_NoArgs(args)) --- 1911,1916 ---- string_isspace(PyStringObject *self, PyObject *args) { ! register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self); ! register const unsigned char *e; if (!PyArg_NoArgs(args)) *************** *** 1940,1945 **** string_isdigit(PyStringObject *self, PyObject *args) { ! register const char *p = PyString_AS_STRING(self); ! register const char *e; if (!PyArg_NoArgs(args)) --- 1940,1945 ---- string_isdigit(PyStringObject *self, PyObject *args) { ! register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self); ! register const unsigned char *e; if (!PyArg_NoArgs(args)) *************** *** 1969,1974 **** string_islower(PyStringObject *self, PyObject *args) { ! register const char *p = PyString_AS_STRING(self); ! register const char *e; int cased; --- 1969,1974 ---- string_islower(PyStringObject *self, PyObject *args) { ! register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self); ! register const unsigned char *e; int cased; *************** *** 2001,2006 **** string_isupper(PyStringObject *self, PyObject *args) { ! register const char *p = PyString_AS_STRING(self); ! register const char *e; int cased; --- 2001,2006 ---- string_isupper(PyStringObject *self, PyObject *args) { ! register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self); ! register const unsigned char *e; int cased; *************** *** 2034,2039 **** string_istitle(PyStringObject *self, PyObject *args) { ! register const char *p = PyString_AS_STRING(self); ! register const char *e; int cased, previous_is_cased; --- 2034,2039 ---- string_istitle(PyStringObject *self, PyObject *args) { ! register const unsigned char *p = (unsigned char *) PyString_AS_STRING(self); ! register const unsigned char *e; int cased, previous_is_cased; *************** *** 2049,2053 **** previous_is_cased = 0; for (; p < e; p++) { ! register const char ch = *p; if (isupper(ch)) { --- 2049,2053 ---- previous_is_cased = 0; for (; p < e; p++) { ! register const unsigned char ch = *p; if (isupper(ch)) { From python-dev@python.org Sat May 6 04:18:10 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 5 May 2000 23:18:10 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Tools/freeze freeze.py,1.34,1.35 Message-ID: <200005060318.XAA15210@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Tools/freeze In directory eric:/projects/python/develop/guido/src/Tools/freeze Modified Files: freeze.py Log Message: Toby Dickenson: Fix for problem with freeze when both "-m" and "-s service" options are used. (Blessed by MarkH) Index: freeze.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Tools/freeze/freeze.py,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -r1.34 -r1.35 *** freeze.py 2000/03/23 18:13:10 1.34 --- freeze.py 2000/05/06 03:18:08 1.35 *************** *** 336,343 **** mf.run_script(scriptfile) else: ! if modargs: ! mf.import_hook(scriptfile) ! else: ! mf.load_file(scriptfile) if debug > 0: --- 336,340 ---- mf.run_script(scriptfile) else: ! mf.load_file(scriptfile) if debug > 0: From python-dev@python.org Sat May 6 14:13:05 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 6 May 2000 09:13:05 -0400 (EDT) Subject: [Python-checkins] CVS: distutils/distutils/command build_ext.py,1.32,1.33 Message-ID: <200005061313.JAA24502@newcnri.cnri.reston.va.us> Update of /projects/cvsroot/distutils/distutils/command In directory newcnri:/tmp/cvs-serv24485/command Modified Files: build_ext.py Log Message: Added the ability to sneak extra flags onto the C compiler command line via an 'extra_compile_args' option in the 'build_info' dictionary. Index: build_ext.py =================================================================== RCS file: /projects/cvsroot/distutils/distutils/command/build_ext.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -r1.32 -r1.33 *** build_ext.py 2000/04/15 22:15:07 1.32 --- build_ext.py 2000/05/06 13:12:59 1.33 *************** *** 7,11 **** # created 1999/08/09, Greg Ward ! __revision__ = "$Id: build_ext.py,v 1.32 2000/04/15 22:15:07 gward Exp $" import sys, os, string, re --- 7,11 ---- # created 1999/08/09, Greg Ward ! __revision__ = "$Id: build_ext.py,v 1.33 2000/05/06 13:12:59 gward Exp $" import sys, os, string, re *************** *** 290,298 **** macros = build_info.get ('macros') include_dirs = build_info.get ('include_dirs') objects = self.compiler.compile (sources, output_dir=self.build_temp, macros=macros, include_dirs=include_dirs, ! debug=self.debug) # Now link the object files together into a "shared object" -- --- 290,300 ---- macros = build_info.get ('macros') include_dirs = build_info.get ('include_dirs') + extra_args = build_info.get ('extra_compile_args') objects = self.compiler.compile (sources, output_dir=self.build_temp, macros=macros, include_dirs=include_dirs, ! debug=self.debug, ! extra_postargs=extra_args) # Now link the object files together into a "shared object" -- From python-dev@python.org Sun May 7 16:29:21 2000 From: python-dev@python.org (Greg Ward) Date: Sun, 7 May 2000 11:29:21 -0400 (EDT) Subject: [Python-checkins] CVS: distutils/distutils cmd.py,1.6,1.7 Message-ID: <200005071529.LAA27651@newcnri.cnri.reston.va.us> Update of /projects/cvsroot/distutils/distutils In directory newcnri:/tmp/cvs-serv27636 Modified Files: cmd.py Log Message: Got rid of some little-used and not-very-useful methods: 'get_option()' and 'get_options()'. Index: cmd.py =================================================================== RCS file: /projects/cvsroot/distutils/distutils/cmd.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** cmd.py 2000/04/15 22:15:07 1.6 --- cmd.py 2000/05/07 15:29:15 1.7 *************** *** 7,11 **** # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: cmd.py,v 1.6 2000/04/15 22:15:07 gward Exp $" import sys, string --- 7,11 ---- # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: cmd.py,v 1.7 2000/05/07 15:29:15 gward Exp $" import sys, string *************** *** 158,202 **** - # -- Option query/set methods -------------------------------------- - - def get_option (self, option): - """Return the value of a single option for this command. Raise - AttributeError if 'option' is not known.""" - return getattr (self, option) - - - def get_options (self, *options): - """Return (as a tuple) the values of several options for this - command. Raise AttributeError if any of the options in - 'options' are not known.""" - - values = [] - for opt in options: - values.append (getattr (self, opt)) - - return tuple (values) - - - def set_option (self, option, value): - """Set the value of a single option for this command. Raise - AttributeError if 'option' is not known.""" - - if not hasattr (self, option): - raise AttributeError, \ - "command '%s': no such option '%s'" % \ - (self.get_command_name(), option) - if value is not None: - setattr (self, option, value) - - def set_options (self, **optval): - """Set the values of several options for this command. Raise - AttributeError if any of the options specified as - keyword arguments are not known.""" - - for k in optval.keys(): - if optval[k] is not None: - self.set_option (k, optval[k]) - - # -- Convenience methods for commands ------------------------------ --- 158,161 ---- *************** *** 229,234 **** for (src_option, dst_option) in option_pairs: if getattr (self, dst_option) is None: ! self.set_option (dst_option, ! src_cmd_obj.get_option (src_option)) --- 188,193 ---- for (src_option, dst_option) in option_pairs: if getattr (self, dst_option) is None: ! setattr (self, dst_option, ! getattr (src_cmd_obj, src_option)) *************** *** 248,252 **** cmd_obj = self.find_peer (command) ! return cmd_obj.get_option (option) --- 207,211 ---- cmd_obj = self.find_peer (command) ! return getattr(cmd_obj, option) From python-dev@python.org Sun May 7 16:30:36 2000 From: python-dev@python.org (Greg Ward) Date: Sun, 7 May 2000 11:30:36 -0400 (EDT) Subject: [Python-checkins] CVS: distutils/distutils dist.py,1.8,1.9 Message-ID: <200005071530.LAA27692@newcnri.cnri.reston.va.us> Update of /projects/cvsroot/distutils/distutils In directory newcnri:/tmp/cvs-serv27663 Modified Files: dist.py Log Message: Got rid of several little-used and not-very-useful methods: 'get_option()', 'get_options()', 'get_command_option()', 'get_command_options()'. Index: dist.py =================================================================== RCS file: /projects/cvsroot/distutils/distutils/dist.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** dist.py 2000/04/26 02:26:55 1.8 --- dist.py 2000/05/07 15:30:31 1.9 *************** *** 7,11 **** # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: dist.py,v 1.8 2000/04/26 02:26:55 gward Exp $" import sys, string, re --- 7,11 ---- # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: dist.py,v 1.9 2000/05/07 15:30:31 gward Exp $" import sys, string, re *************** *** 262,267 **** # Require that the command class be derived from Command -- ! # that way, we can be sure that we at least have the 'run' ! # and 'get_option' methods. if not isinstance (cmd_obj, Command): raise DistutilsClassError, \ --- 262,267 ---- # Require that the command class be derived from Command -- ! # want to be sure that the basic "command" interface is ! # implemented. if not isinstance (cmd_obj, Command): raise DistutilsClassError, \ *************** *** 530,551 **** - def get_option (self, option): - """Return the value of a distribution option. Raise - AttributeError if 'option' is not known.""" - return getattr (self, opt) - - - def get_options (self, *options): - """Return (as a tuple) the values of several distribution - options. Raise AttributeError if any element of - 'options' is not known.""" - - values = [] - for opt in options: - values.append (getattr (self, opt)) - - return tuple (values) - - # -- Methods that operate on its Commands -------------------------- --- 530,533 ---- *************** *** 569,599 **** cmd_obj.run () self.have_run[command] = 1 - - - def get_command_option (self, command, option): - """Create a command object for 'command' if necessary, ensure that - its option values are all set to their final values, and return - the value of its 'option' option. Raise AttributeError if - 'option' is not known for that 'command'.""" - - cmd_obj = self.find_command_obj (command) - cmd_obj.ensure_ready () - return cmd_obj.get_option (option) - - - def get_command_options (self, command, *options): - """Create a command object for 'command' if necessary, ensure that - its option values are all set to their final values, and return - a tuple containing the values of all the options listed in - 'options' for that command. Raise DistutilsOptionError if any - invalid option is supplied in 'options'.""" - - cmd_obj = self.find_command_obj (command) - cmd_obj.ensure_ready () - values = [] - for opt in options: - values.append (getattr (cmd_obj, option)) - - return tuple (values) --- 551,554 ---- From python-dev@python.org Sun May 7 16:32:18 2000 From: python-dev@python.org (Greg Ward) Date: Sun, 7 May 2000 11:32:18 -0400 (EDT) Subject: [Python-checkins] CVS: distutils/distutils/command bdist.py,1.5,1.6 install_lib.py,1.19,1.20 Message-ID: <200005071532.LAA27761@newcnri.cnri.reston.va.us> Update of /projects/cvsroot/distutils/distutils/command In directory newcnri:/tmp/cvs-serv27742 Modified Files: bdist.py install_lib.py Log Message: Don't use 'set_option()' or 'get_option()' method -- direct attribute access, or getattr/setattr, is all that's needed. Index: bdist.py =================================================================== RCS file: /projects/cvsroot/distutils/distutils/command/bdist.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** bdist.py 2000/04/25 01:38:19 1.5 --- bdist.py 2000/05/07 15:32:12 1.6 *************** *** 6,10 **** # created 2000/03/29, Greg Ward ! __revision__ = "$Id: bdist.py,v 1.5 2000/04/25 01:38:19 gward Exp $" import os, string --- 6,10 ---- # created 2000/03/29, Greg Ward ! __revision__ = "$Id: bdist.py,v 1.6 2000/05/07 15:32:12 gward Exp $" import os, string *************** *** 65,69 **** sub_cmd = self.find_peer (cmd_name) ! sub_cmd.set_option ('format', self.format) self.run_peer (cmd_name) --- 65,69 ---- sub_cmd = self.find_peer (cmd_name) ! sub_cmd.format = self.format self.run_peer (cmd_name) Index: install_lib.py =================================================================== RCS file: /projects/cvsroot/distutils/distutils/command/install_lib.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** install_lib.py 2000/03/31 02:53:07 1.19 --- install_lib.py 2000/05/07 15:32:13 1.20 *************** *** 1,5 **** # created 1999/03/13, Greg Ward ! __revision__ = "$Id: install_lib.py,v 1.19 2000/03/31 02:53:07 gward Exp $" import sys, os, string --- 1,5 ---- # created 1999/03/13, Greg Ward ! __revision__ = "$Id: install_lib.py,v 1.20 2000/05/07 15:32:13 gward Exp $" import sys, os, string *************** *** 80,84 **** build_cmd = self.find_peer (build_cmd) build_files = build_cmd.get_outputs() ! build_dir = build_cmd.get_option (cmd_option) prefix_len = len (build_dir) + len (os.sep) --- 80,84 ---- build_cmd = self.find_peer (build_cmd) build_files = build_cmd.get_outputs() ! build_dir = getattr (build_cmd, cmd_option) prefix_len = len (build_dir) + len (os.sep) From python-dev@python.org Mon May 8 14:35:20 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 8 May 2000 09:35:20 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Include Python.h,2.15,2.16 Message-ID: <200005081335.JAA16397@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Include In directory eric:/projects/python/develop/guido/src/Include Modified Files: Python.h Log Message: Andy Dustman: add GNU pth user-space thread support. Index: Python.h =================================================================== RCS file: /projects/cvsroot/python/dist/src/Include/Python.h,v retrieving revision 2.15 retrieving revision 2.16 diff -C2 -r2.15 -r2.16 *** Python.h 2000/04/05 20:11:08 2.15 --- Python.h 2000/05/08 13:35:17 2.16 *************** *** 129,131 **** --- 129,135 ---- #define Py_eval_input 258 + #ifdef _GNU_PTH + /* GNU pth user-space thread support */ + #include + #endif #endif /* !Py_PYTHON_H */ From python-dev@python.org Mon May 8 14:36:52 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 8 May 2000 09:36:52 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Python thread_pth.h,NONE,2.1 thread.c,2.28,2.29 Message-ID: <200005081336.JAA16430@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Python In directory eric:/projects/python/develop/guido/src/Python Modified Files: thread.c Added Files: thread_pth.h Log Message: Andy Dustman: add GNU pth user-space thread support. Index: thread.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Python/thread.c,v retrieving revision 2.28 retrieving revision 2.29 diff -C2 -r2.28 -r2.29 *** thread.c 2000/04/24 15:06:51 2.28 --- thread.c 2000/05/08 13:36:49 2.29 *************** *** 151,156 **** --- 151,160 ---- #endif + #ifdef _GNU_PTH + #include "thread_pth.h" + #else #ifdef _POSIX_THREADS #include "thread_pthread.h" + #endif #endif From python-dev@python.org Mon May 8 14:41:41 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 8 May 2000 09:41:41 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src acconfig.h,1.28,1.29 config.h.in,2.53,2.54 configure,1.111,1.112 configure.in,1.119,1.120 Message-ID: <200005081341.JAA18182@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src In directory eric:/projects/python/develop/guido/src Modified Files: acconfig.h config.h.in configure configure.in Log Message: Andy Dustman: add GNU pth user-space thread support. Index: acconfig.h =================================================================== RCS file: /projects/cvsroot/python/dist/src/acconfig.h,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -r1.28 -r1.29 *** acconfig.h 2000/04/24 15:12:03 1.28 --- acconfig.h 2000/05/08 13:41:37 1.29 *************** *** 36,39 **** --- 36,42 ---- #undef GETTIMEOFDAY_NO_TZ + /* Define if you have GNU PTH threads */ + #undef _GNU_PTH + /* Define this if your time.h defines altzone */ #undef HAVE_ALTZONE Index: config.h.in =================================================================== RCS file: /projects/cvsroot/python/dist/src/config.h.in,v retrieving revision 2.53 retrieving revision 2.54 diff -C2 -r2.53 -r2.54 *** config.h.in 2000/04/24 15:12:03 2.53 --- config.h.in 2000/05/08 13:41:37 2.54 *************** *** 104,107 **** --- 104,110 ---- #undef GETTIMEOFDAY_NO_TZ + /* Define if you have GNU PTH threads */ + #undef _GNU_PTH + /* Define this if your time.h defines altzone */ #undef HAVE_ALTZONE Index: configure =================================================================== RCS file: /projects/cvsroot/python/dist/src/configure,v retrieving revision 1.111 retrieving revision 1.112 diff -C2 -r1.111 -r1.112 *** configure 2000/04/24 15:12:03 1.111 --- configure 2000/05/08 13:41:37 1.112 *************** *** 1,5 **** #! /bin/sh ! # From configure.in Revision: 1.119 # Guess values for system-dependent variables and create Makefiles. --- 1,5 ---- #! /bin/sh ! # From configure.in Revision: 1.120 [...1863 lines suppressed...] ac_cv_c_bigendian=no --- 5241,5245 ---- } EOF ! if { (eval echo configure:5244: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_c_bigendian=no *************** *** 5217,5221 **** # Check for --with-wctype-functions echo $ac_n "checking for --with-wctype-functions""... $ac_c" 1>&6 ! echo "configure:5220: checking for --with-wctype-functions" >&5 # Check whether --with-wctype-functions or --without-wctype-functions was given. if test "${with_wctype_functions+set}" = set; then --- 5267,5271 ---- # Check for --with-wctype-functions echo $ac_n "checking for --with-wctype-functions""... $ac_c" 1>&6 ! echo "configure:5270: checking for --with-wctype-functions" >&5 # Check whether --with-wctype-functions or --without-wctype-functions was given. if test "${with_wctype_functions+set}" = set; then Index: configure.in =================================================================== RCS file: /projects/cvsroot/python/dist/src/configure.in,v retrieving revision 1.119 retrieving revision 1.120 diff -C2 -r1.119 -r1.120 *** configure.in 2000/04/24 15:12:04 1.119 --- configure.in 2000/05/08 13:41:38 1.120 *************** *** 1,4 **** dnl Process this file with autoconf 2.0 or later to make a configure script. ! AC_REVISION($Revision: 1.119 $) AC_PREREQ(2.0) AC_INIT(Include/object.h) --- 1,4 ---- dnl Process this file with autoconf 2.0 or later to make a configure script. ! AC_REVISION($Revision: 1.120 $) AC_PREREQ(2.0) AC_INIT(Include/object.h) *************** *** 655,658 **** --- 655,662 ---- AC_DEFINE(C_THREADS) LIBOBJS="$LIBOBJS thread.o"],[ + AC_CHECK_LIB(pth, pth_init, [AC_DEFINE(WITH_THREAD) + AC_DEFINE(_GNU_PTH) + LIBS="-lpth $LIBS" + LIBOBJS="$LIBOBJS thread.o"],[ AC_CHECK_LIB(pthread, pthread_create, [AC_DEFINE(WITH_THREAD) AC_DEFINE(_POSIX_THREADS) *************** *** 681,685 **** LIBS="$LIBS -lcma" LIBOBJS="$LIBOBJS thread.o"]) ! ])])])])])])]) AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD) --- 685,689 ---- LIBS="$LIBS -lcma" LIBOBJS="$LIBOBJS thread.o"]) ! ])])])])])])])]) AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD) From python-dev@python.org Mon May 8 15:02:44 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 8 May 2000 10:02:44 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Python getargs.c,2.31,2.32 Message-ID: <200005081402.KAA19915@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Python In directory eric:/projects/python/develop/guido/src/Python Modified Files: getargs.c Log Message: Trent Mick: Changes the 'b', 'h', and 'i' formatters in PyArg_ParseTuple to raise an Overflow exception if they overflow (previously they just silently overflowed). Changes by Guido: always accept values [0..255] (in addition to [CHAR_MIN..CHAR_MAX]) for 'b' format; changed some spaces into tabs in other code. Index: getargs.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Python/getargs.c,v retrieving revision 2.31 retrieving revision 2.32 diff -C2 -r2.31 -r2.32 *** getargs.c 2000/05/03 15:15:57 2.31 --- getargs.c 2000/05/08 14:02:41 2.32 *************** *** 472,475 **** --- 472,485 ---- if (ival == -1 && PyErr_Occurred()) return "integer"; + else if (ival < CHAR_MIN) { + PyErr_SetString(PyExc_OverflowError, + "byte integer is less than minimum"); + return "integer"; + } + else if (ival > CHAR_MAX && ival >= 256) { + PyErr_SetString(PyExc_OverflowError, + "byte integer is greater than maximum"); + return "integer"; + } else *p = (char) ival; *************** *** 483,486 **** --- 493,506 ---- if (ival == -1 && PyErr_Occurred()) return "integer"; + else if (ival < SHRT_MIN) { + PyErr_SetString(PyExc_OverflowError, + "short integer is less than minimum"); + return "integer"; + } + else if (ival > SHRT_MAX) { + PyErr_SetString(PyExc_OverflowError, + "short integer is greater than maximum"); + return "integer"; + } else *p = (short) ival; *************** *** 494,497 **** --- 514,527 ---- if (ival == -1 && PyErr_Occurred()) return "integer"; + else if (ival < INT_MIN) { + PyErr_SetString(PyExc_OverflowError, + "integer is less than minimum"); + return "integer"; + } + else if (ival > INT_MAX) { + PyErr_SetString(PyExc_OverflowError, + "integer is greater than maximum"); + return "integer"; + } else *p = ival; *************** *** 573,578 **** { if (*format == '#') { /* any buffer-like object */ ! void **p = (void **)va_arg(*p_va, char **); ! PyBufferProcs *pb = arg->ob_type->tp_as_buffer; int *q = va_arg(*p_va, int *); int count; --- 603,608 ---- { if (*format == '#') { /* any buffer-like object */ ! void **p = (void **)va_arg(*p_va, char **); ! PyBufferProcs *pb = arg->ob_type->tp_as_buffer; int *q = va_arg(*p_va, int *); int count; *************** *** 590,596 **** format++; } else { ! char **p = va_arg(*p_va, char **); ! if (PyString_Check(arg)) *p = PyString_AS_STRING(arg); else if (PyUnicode_Check(arg)) { --- 620,626 ---- format++; } else { ! char **p = va_arg(*p_va, char **); ! if (PyString_Check(arg)) *p = PyString_AS_STRING(arg); else if (PyUnicode_Check(arg)) { *************** *** 611,616 **** { if (*format == '#') { /* any buffer-like object */ ! void **p = (void **)va_arg(*p_va, char **); ! PyBufferProcs *pb = arg->ob_type->tp_as_buffer; int *q = va_arg(*p_va, int *); int count; --- 641,646 ---- { if (*format == '#') { /* any buffer-like object */ ! void **p = (void **)va_arg(*p_va, char **); ! PyBufferProcs *pb = arg->ob_type->tp_as_buffer; int *q = va_arg(*p_va, int *); int count; *************** *** 633,639 **** format++; } else { ! char **p = va_arg(*p_va, char **); ! if (arg == Py_None) *p = 0; else if (PyString_Check(arg)) --- 663,669 ---- format++; } else { ! char **p = va_arg(*p_va, char **); ! if (arg == Py_None) *p = 0; else if (PyString_Check(arg)) *************** *** 781,786 **** { if (*format == '#') { /* any buffer-like object */ ! void **p = (void **)va_arg(*p_va, char **); ! PyBufferProcs *pb = arg->ob_type->tp_as_buffer; int *q = va_arg(*p_va, int *); int count; --- 811,816 ---- { if (*format == '#') { /* any buffer-like object */ ! void **p = (void **)va_arg(*p_va, char **); ! PyBufferProcs *pb = arg->ob_type->tp_as_buffer; int *q = va_arg(*p_va, int *); int count; *************** *** 800,806 **** format++; } else { ! Py_UNICODE **p = va_arg(*p_va, Py_UNICODE **); ! if (PyUnicode_Check(arg)) *p = PyUnicode_AS_UNICODE(arg); else --- 830,836 ---- format++; } else { ! Py_UNICODE **p = va_arg(*p_va, Py_UNICODE **); ! if (PyUnicode_Check(arg)) *p = PyUnicode_AS_UNICODE(arg); else *************** *** 851,855 **** *p = arg; else ! return "(unspecified)"; } --- 881,885 ---- *p = arg; else ! return "(unspecified)"; } *************** *** 1162,1166 **** if (!match) { sprintf(msgbuf, ! "%s is an invalid keyword argument for this function", ks); PyErr_SetString(PyExc_TypeError, msgbuf); --- 1192,1196 ---- if (!match) { sprintf(msgbuf, ! "%s is an invalid keyword argument for this function", ks); PyErr_SetString(PyExc_TypeError, msgbuf); From python-dev@python.org Mon May 8 15:04:56 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 8 May 2000 10:04:56 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Include ceval.h,2.30,2.31 Message-ID: <200005081404.KAA20008@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Include In directory eric:/projects/python/develop/guido/src/Include Modified Files: ceval.h Log Message: Trent Mick: Add declaration of PyEval_SliceIndex(). Index: ceval.h =================================================================== RCS file: /projects/cvsroot/python/dist/src/Include/ceval.h,v retrieving revision 2.30 retrieving revision 2.31 diff -C2 -r2.30 -r2.31 *** ceval.h 1999/03/17 18:44:39 2.30 --- ceval.h 2000/05/08 14:04:54 2.31 *************** *** 145,148 **** --- 145,151 ---- #endif /* !WITH_THREAD */ + extern DL_IMPORT(int) _PyEval_SliceIndex Py_PROTO((PyObject *, int *)); + + #ifdef __cplusplus } From python-dev@python.org Mon May 8 15:06:53 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 8 May 2000 10:06:53 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Python ceval.c,2.178,2.179 Message-ID: <200005081406.KAA20032@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Python In directory eric:/projects/python/develop/guido/src/Python Modified Files: ceval.c Log Message: Trent Mick: Change static slice_index() to extern _PyEval_SliceIndex() (with different return value interpretation: 0 for failure, 1 for success). Index: ceval.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Python/ceval.c,v retrieving revision 2.178 retrieving revision 2.179 diff -C2 -r2.178 -r2.179 *** ceval.c 2000/05/04 00:55:17 2.178 --- ceval.c 2000/05/08 14:06:50 2.179 *************** *** 81,85 **** static PyObject *call_function Py_PROTO((PyObject *, PyObject *, PyObject *)); static PyObject *loop_subscript Py_PROTO((PyObject *, PyObject *)); - static int slice_index Py_PROTO((PyObject *, int *)); static PyObject *apply_slice Py_PROTO((PyObject *, PyObject *, PyObject *)); static int assign_slice Py_PROTO((PyObject *, PyObject *, --- 81,84 ---- *************** *** 2588,2593 **** } ! static int ! slice_index(v, pi) PyObject *v; int *pi; --- 2587,2596 ---- } ! /* Extract a slice index from a PyInt or PyLong, the index is bound to ! the range [-INT_MAX+1, INTMAX]. Returns 0 and an exception if there is ! and error. Returns 1 on success.*/ ! ! int ! _PyEval_SliceIndex(v, pi) PyObject *v; int *pi; *************** *** 2605,2609 **** /* It's not an overflow error, so just signal an error */ ! return -1; } --- 2608,2612 ---- /* It's not an overflow error, so just signal an error */ ! return 0; } *************** *** 2615,2619 **** /* Create a long integer with a value of 0 */ long_zero = PyLong_FromLong( 0L ); ! if (long_zero == NULL) return -1; /* Check sign */ --- 2618,2622 ---- /* Create a long integer with a value of 0 */ long_zero = PyLong_FromLong( 0L ); ! if (long_zero == NULL) return 0; /* Check sign */ *************** *** 2631,2635 **** PyErr_SetString(PyExc_TypeError, "slice index must be int"); ! return -1; } /* Truncate -- very long indices are truncated anyway */ --- 2634,2638 ---- PyErr_SetString(PyExc_TypeError, "slice index must be int"); ! return 0; } /* Truncate -- very long indices are truncated anyway */ *************** *** 2640,2644 **** *pi = x; } ! return 0; } --- 2643,2647 ---- *pi = x; } ! return 1; } *************** *** 2648,2654 **** { int ilow = 0, ihigh = INT_MAX; ! if (slice_index(v, &ilow) != 0) return NULL; ! if (slice_index(w, &ihigh) != 0) return NULL; return PySequence_GetSlice(u, ilow, ihigh); --- 2651,2657 ---- { int ilow = 0, ihigh = INT_MAX; ! if (!_PyEval_SliceIndex(v, &ilow)) return NULL; ! if (!_PyEval_SliceIndex(w, &ihigh)) return NULL; return PySequence_GetSlice(u, ilow, ihigh); *************** *** 2660,2666 **** { int ilow = 0, ihigh = INT_MAX; ! if (slice_index(v, &ilow) != 0) return -1; ! if (slice_index(w, &ihigh) != 0) return -1; if (x == NULL) --- 2663,2669 ---- { int ilow = 0, ihigh = INT_MAX; ! if (!_PyEval_SliceIndex(v, &ilow)) return -1; ! if (!_PyEval_SliceIndex(w, &ihigh)) return -1; if (x == NULL) From python-dev@python.org Mon May 8 15:08:08 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 8 May 2000 10:08:08 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Objects stringobject.c,2.64,2.65 Message-ID: <200005081408.KAA20085@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Objects In directory eric:/projects/python/develop/guido/src/Objects Modified Files: stringobject.c Log Message: Trent Mick: Fix the string methods that implement slice-like semantics with optional args (count, find, endswith, etc.) to properly handle indeces outside [INT_MIN, INT_MAX]. Previously the "i" formatter for PyArg_ParseTuple was used to get the indices. These could overflow. This patch changes the string methods to use the "O&" formatter with the slice_index() function from ceval.c which is used to do the same job for Python code slices (e.g. 'abcabcabc'[0:1000000000L]). slice_index() is renamed _PyEval_SliceIndex() and is now exported. As well, the return values for success/fail were changed to make slice_index directly usable as required by the "O&" formatter. [GvR: shouldn't a similar patch be applied to unicodeobject.c?] Index: stringobject.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Objects/stringobject.c,v retrieving revision 2.64 retrieving revision 2.65 diff -C2 -r2.64 -r2.65 *** stringobject.c 2000/05/05 20:44:24 2.64 --- stringobject.c 2000/05/08 14:08:05 2.65 *************** *** 823,828 **** PyObject *subobj; ! if (!PyArg_ParseTuple(args, "O|ii:find/rfind/index/rindex", ! &subobj, &i, &last)) return -2; if (PyString_Check(subobj)) { --- 823,828 ---- PyObject *subobj; ! if (!PyArg_ParseTuple(args, "O|O&O&:find/rfind/index/rindex", ! &subobj, _PyEval_SliceIndex, &i, _PyEval_SliceIndex, &last)) return -2; if (PyString_Check(subobj)) { *************** *** 1195,1200 **** PyObject *subobj; ! if (!PyArg_ParseTuple(args, "O|ii:count", &subobj, &i, &last)) return NULL; if (PyString_Check(subobj)) { sub = PyString_AS_STRING(subobj); --- 1195,1202 ---- PyObject *subobj; ! if (!PyArg_ParseTuple(args, "O|O&O&:count", &subobj, ! _PyEval_SliceIndex, &i, _PyEval_SliceIndex, &last)) return NULL; + if (PyString_Check(subobj)) { sub = PyString_AS_STRING(subobj); *************** *** 1618,1622 **** PyObject *subobj; ! if (!PyArg_ParseTuple(args, "O|ii:startswith", &subobj, &start, &end)) return NULL; if (PyString_Check(subobj)) { --- 1620,1625 ---- PyObject *subobj; ! if (!PyArg_ParseTuple(args, "O|O&O&:startswith", &subobj, ! _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end)) return NULL; if (PyString_Check(subobj)) { *************** *** 1672,1676 **** PyObject *subobj; ! if (!PyArg_ParseTuple(args, "O|ii:endswith", &subobj, &start, &end)) return NULL; if (PyString_Check(subobj)) { --- 1675,1680 ---- PyObject *subobj; ! if (!PyArg_ParseTuple(args, "O|O&O&:endswith", &subobj, ! _PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end)) return NULL; if (PyString_Check(subobj)) { From python-dev@python.org Mon May 8 15:14:51 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 8 May 2000 10:14:51 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/PC config.h,1.33,1.34 Message-ID: <200005081414.KAA20127@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/PC In directory eric:/projects/python/develop/guido/src/PC Modified Files: config.h Log Message: Trent Mick: Changes to PC\config.[hc] for Win64. MSVC defines _WINxx to differentiate the various windows platforms. Python's MS_WINxx are keyed off of these. Note that _WIN32 (and hence MS_WIN32 in Python) are defined on Win32 *and* on Win64. This is for compatibility reasons. The idea is that the common case is that code specific to Win32 will also work on Win64 rather than being specific to Win32 (i.e. there is more the same than different in WIn32 and Win64). The following modules are specifically excluded in the Win64 build: audioop, binascii, imageop, rgbimg. They are advertised as heavily 32-bit dependent. [They should probably be fixed! --GvR] The patch to config.h looks big but it really is not. These are the effective changes: - MS_WINxx are keyed off _WINxx - SIZEOF_VOID_P is set to 8 for Win64 - COMPILER string is changed appropriately for Win64 Index: config.h =================================================================== RCS file: /projects/cvsroot/python/dist/src/PC/config.h,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -r1.33 -r1.34 *** config.h 2000/04/24 15:37:34 1.33 --- config.h 2000/05/08 14:14:48 1.34 *************** *** 12,16 **** the following #defines ! MS_WIN32 - Code specific to the MS Win32 API MS_WIN16 - Code specific to the old 16 bit Windows API. MS_WINDOWS - Code specific to Windows, but all versions. --- 12,17 ---- the following #defines ! MS_WIN64 - Code specific to the MS Win64 API ! MS_WIN32 - Code specific to the MS Win32 (and Win64) API MS_WIN16 - Code specific to the old 16 bit Windows API. MS_WINDOWS - Code specific to Windows, but all versions. *************** *** 43,53 **** /* Microsoft C defines _MSC_VER */ ! #if defined(_MSC_VER) && _MSC_VER > 850 ! /* Start of defines for MS_WIN32 using VC++ 2.0 and up */ #define NT /* NT is obsolete - please use MS_WIN32 instead */ #define MS_WIN32 #define MS_WINDOWS /* For NT the Python core is in a DLL by default. Test the standard macro MS_COREDLL to find out. If you have an exception --- 44,95 ---- /* Microsoft C defines _MSC_VER */ + #ifdef _MSC_VER ! /* MSVC defines _WINxx to differentiate the windows platform types ! ! Note that for compatibility reasons _WIN32 is defined on Win32 ! *and* on Win64. For the same reasons, in Python, MS_WIN32 is ! defined on Win32 *and* Win64. Win32 only code must therefore be ! guarded as follows: ! #if defined(MS_WIN32) && !defined(MS_WIN64) ! */ ! #ifdef _WIN64 ! #define MS_WIN64 ! #endif ! #ifdef _WIN32 #define NT /* NT is obsolete - please use MS_WIN32 instead */ #define MS_WIN32 + #endif + #ifdef _WIN16 + #define MS_WIN16 + #endif #define MS_WINDOWS + /* set the COMPILER */ + #ifdef MS_WIN64 + #ifdef _M_IX86 + #define COMPILER "[MSC 64 bit (Intel)]" + #elif defined(_M_ALPHA) + #define COMPILER "[MSC 64 bit (Alpha)]" + #else + #define COMPILER "[MSC 64 bit (Unknown)]" + #endif + #endif /* MS_WIN64 */ + + #if defined(MS_WIN32) && !defined(MS_WIN64) + #ifdef _M_IX86 + #define COMPILER "[MSC 32 bit (Intel)]" + #elif defined(_M_ALPHA) + #define COMPILER "[MSC 32 bit (Alpha)]" + #else + #define COMPILER "[MSC (Unknown)]" + #endif + #endif /* MS_WIN32 && !MS_WIN64 */ + + #endif /* _MSC_VER */ + + #if defined(_MSC_VER) && _MSC_VER > 850 + /* Start of defines for MS_WIN32 using VC++ 2.0 and up */ + /* For NT the Python core is in a DLL by default. Test the standard macro MS_COREDLL to find out. If you have an exception *************** *** 60,70 **** #endif /* !MS_NO_COREDLL */ - #ifdef _M_IX86 - #define COMPILER "[MSC 32 bit (Intel)]" - #elif defined(_M_ALPHA) - #define COMPILER "[MSC 32 bit (Alpha)]" - #else - #define COMPILER "[MSC (Unknown)]" - #endif #define PYTHONPATH ".\\DLLs;.\\lib;.\\lib\\plat-win;.\\lib\\lib-tk" typedef int pid_t; --- 102,105 ---- *************** *** 93,101 **** #endif /* _MSC_VER && > 850 */ ! #if defined(_MSC_VER) && _MSC_VER <= 850 /* Start of defines for 16-bit Windows using VC++ 1.5 */ #define COMPILER "[MSC 16-bit]" - #define MS_WIN16 - #define MS_WINDOWS #define PYTHONPATH ".;.\\lib;.\\lib\\plat-win;.\\lib\\dos-8x3" #define IMPORT_8x3_NAMES --- 128,134 ---- #endif /* _MSC_VER && > 850 */ ! #if defined(_MSC_VER) && _MSC_VER <= 850 /* presume this implies Win16 */ /* Start of defines for 16-bit Windows using VC++ 1.5 */ #define COMPILER "[MSC 16-bit]" #define PYTHONPATH ".;.\\lib;.\\lib\\plat-win;.\\lib\\dos-8x3" #define IMPORT_8x3_NAMES *************** *** 201,213 **** /* End of compilers - finish up */ ! #ifdef MS_WIN32 #define PLATFORM "win32" #else ! #ifdef MS_WIN16 #define PLATFORM "win16" #else #define PLATFORM "dos" ! #endif /* !MS_WIN16 */ ! #endif /* !MS_WIN32 */ #ifdef MS_WIN32 --- 234,253 ---- /* End of compilers - finish up */ ! #if defined(MS_WIN64) ! #define PLATFORM "win64" ! #define SIZEOF_VOID_P 8 ! #elif defined(MS_WIN32) #define PLATFORM "win32" + #ifdef _M_ALPHA + #define SIZEOF_VOID_P 8 #else ! #define SIZEOF_VOID_P 4 ! #endif ! #elif defined(MS_WIN16) #define PLATFORM "win16" #else #define PLATFORM "dos" ! #endif ! #ifdef MS_WIN32 *************** *** 229,238 **** #define SIZEOF_LONG 4 #define SIZEOF_LONG_LONG 8 - - #ifdef _M_ALPHA - #define SIZEOF_VOID_P 8 - #else - #define SIZEOF_VOID_P 4 - #endif /* Smaller stack size limit. (9500 would work too, but we're conservative.) */ --- 269,272 ---- From python-dev@python.org Mon May 8 15:15:22 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 8 May 2000 10:15:22 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/PC config.c,1.21,1.22 Message-ID: <200005081415.KAA20148@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/PC In directory eric:/projects/python/develop/guido/src/PC Modified Files: config.c Log Message: Trent Mick: The following modules are specifically excluded in the Win64 build: audioop, binascii, imageop, rgbimg. They are advertised as heavily 32-bit dependent. [They should probably be fixed! --GvR] Index: config.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/PC/config.c,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -r1.21 -r1.22 *** config.c 2000/04/21 21:26:43 1.21 --- config.c 2000/05/08 14:15:19 1.22 *************** *** 38,46 **** --- 38,50 ---- extern void initarray(); + #ifndef MS_WIN64 extern void initaudioop(); extern void initbinascii(); + #endif extern void initcmath(); extern void initerrno(); + #ifndef MS_WIN64 extern void initimageop(); + #endif extern void initmath(); extern void initmd5(); *************** *** 49,53 **** --- 53,59 ---- extern void initoperator(); extern void initregex(); + #ifndef MS_WIN64 extern void initrgbimg(); + #endif extern void initrotor(); extern void initsignal(); *************** *** 75,84 **** --- 81,96 ---- {"array", initarray}, #ifdef MS_WINDOWS + #ifndef MS_WIN64 {"audioop", initaudioop}, #endif + #endif + #ifndef MS_WIN64 {"binascii", initbinascii}, + #endif {"cmath", initcmath}, {"errno", initerrno}, + #ifndef MS_WIN64 {"imageop", initimageop}, + #endif {"math", initmath}, {"md5", initmd5}, *************** *** 87,91 **** --- 99,105 ---- {"operator", initoperator}, {"regex", initregex}, + #ifndef MS_WIN64 {"rgbimg", initrgbimg}, + #endif {"rotor", initrotor}, {"signal", initsignal}, *************** *** 101,109 **** {"pcre", initpcre}, #ifdef WIN32 ! {"msvcrt", initmsvcrt}, ! {"_locale", init_locale}, #endif ! {"_codecs", init_codecs}, /* -- ADDMODULE MARKER 2 -- */ --- 115,123 ---- {"pcre", initpcre}, #ifdef WIN32 ! {"msvcrt", initmsvcrt}, ! {"_locale", init_locale}, #endif ! {"_codecs", init_codecs}, /* -- ADDMODULE MARKER 2 -- */ From python-dev@python.org Mon May 8 15:29:41 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 8 May 2000 10:29:41 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Modules mathmodule.c,2.42,2.43 Message-ID: <200005081429.KAA20491@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Modules In directory eric:/projects/python/develop/guido/src/Modules Modified Files: mathmodule.c Log Message: Trent Mick: Fix overflow bug in ldexp(x, exp). The 'exp' argument maps to a C int for the math library call [double ldexp(double, int)], however the 'd' PyArg_ParseTuple formatter was used to yield a double, which was subsequently cast to an int. This could overflow. [GvR: mysteriously, on Solaris 2.7, ldexp(1, 2147483647) returns Inf while ldexp(1, 2147483646) raises OverflowError; this seems a bug in the math library (it also takes a real long time to compute the Inf outcome). Does this point to a bug in the CHECK() macro? It should have discovered that the result was outside the HUGE_VAL range.] Index: mathmodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/mathmodule.c,v retrieving revision 2.42 retrieving revision 2.43 diff -C2 -r2.42 -r2.43 *** mathmodule.c 1998/12/08 16:27:10 2.42 --- mathmodule.c 2000/05/08 14:29:38 2.43 *************** *** 197,207 **** PyObject *args; { ! double x, y; ! /* Cheat -- allow float as second argument */ ! if (! PyArg_Parse(args, "(dd)", &x, &y)) return NULL; errno = 0; PyFPE_START_PROTECT("ldexp", return 0) ! x = ldexp(x, (int)y); PyFPE_END_PROTECT(x) CHECK(x); --- 197,207 ---- PyObject *args; { ! double x; ! int exp; ! if (! PyArg_Parse(args, "(di)", &x, &exp)) return NULL; errno = 0; PyFPE_START_PROTECT("ldexp", return 0) ! x = ldexp(x, exp); PyFPE_END_PROTECT(x) CHECK(x); From python-dev@python.org Mon May 8 18:00:03 2000 From: python-dev@python.org (Jeremy Hylton) Date: Mon, 8 May 2000 13:00:03 -0400 Subject: [Python-checkins] CVS: python/dist/src/Lib gzip.py,1.17,1.18 Message-ID: <200005081700.NAA14941@goon.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Lib In directory goon.cnri.reston.va.us:/home/jhylton/python/src/Lib Modified Files: gzip.py Log Message: if the GzipFile constructor fails, the __del__ method is still called. catch the resulting AttributeError and exit cleanly. Index: gzip.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/gzip.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** gzip.py 2000/02/04 15:39:29 1.17 --- gzip.py 2000/05/08 16:59:59 1.18 *************** *** 254,260 **** def __del__(self): ! if (self.myfileobj is not None or ! self.fileobj is not None): ! self.close() def flush(self): --- 254,264 ---- def __del__(self): ! try: ! if (self.myfileobj is None and ! self.fileobj is None): ! return ! except AttributeError: ! return ! self.close() def flush(self): From python-dev@python.org Mon May 8 18:25:22 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 8 May 2000 13:25:22 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Lib/lib-stdwin Abstract.py,1.6,NONE BoxParent.py,1.4,NONE Buttons.py,1.10,NONE CSplit.py,1.5,NONE DirList.py,1.7,NONE FormSplit.py,1.4,NONE HVSplit.py,1.6,NONE Histogram.py,1.5,NONE Sliders.py,1.8,NONE Soundogram.py,1.4,NONE Split.py,1.9,NONE StripChart.py,1.7,NONE TextEdit.py,1.7,NONE TransParent.py,1.5,NONE VUMeter.py,1.4,NONE WindowParent.py,1.11,NONE WindowSched.py,1.7,NONE anywin.py,1.2,NONE basewin.py,1.2,NONE dirwin.py,1.5,NONE filewin.py,1.4,NONE formatter.py,1.6,NONE gwin.py,1.6,NONE listwin.py,1.1,NONE mainloop.py,1.7,NONE rect.py,1.4,NONE srcwin.py,1.3,NONE stdwinevents.py,1.4,NONE stdwinq.py,1.1,NONE tablewin.py,1.4,NONE textwin.py,1.3,NONE wdb.py,1.7,NONE wdbframewin.py,1.7,NONE wdbsrcwin.py,1.3,NONE Message-ID: <200005081725.NAA21227@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Lib/lib-stdwin In directory eric:/projects/python/develop/guido/src/Lib/lib-stdwin Removed Files: Abstract.py BoxParent.py Buttons.py CSplit.py DirList.py FormSplit.py HVSplit.py Histogram.py Sliders.py Soundogram.py Split.py StripChart.py TextEdit.py TransParent.py VUMeter.py WindowParent.py WindowSched.py anywin.py basewin.py dirwin.py filewin.py formatter.py gwin.py listwin.py mainloop.py rect.py srcwin.py stdwinevents.py stdwinq.py tablewin.py textwin.py wdb.py wdbframewin.py wdbsrcwin.py Log Message: Deleting all stdwin library modules. From python-dev@python.org Mon May 8 18:29:53 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 8 May 2000 13:29:53 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Lib/lib-old Para.py,1.4,1.5 Message-ID: <200005081729.NAA21271@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Lib/lib-old In directory eric:/projects/python/develop/guido/src/Lib/lib-old Modified Files: Para.py Log Message: Deleted the stdwin-based test() function. Index: Para.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/lib-old/Para.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** Para.py 2000/02/15 21:57:14 1.4 --- Para.py 2000/05/08 17:29:50 1.5 *************** *** 342,409 **** top1, bottom1 = top2, bottom2 d.invert((h1, top1), (h2, bottom2)) - - - # Test class Para - # XXX This was last used on the Mac, hence the weird fonts... - def test(): - import stdwin - from stdwinevents import * - words = 'The', 'quick', 'brown', 'fox', 'jumps', 'over', \ - 'the', 'lazy', 'dog.' - paralist = [] - for just in 'l', 'r', 'lr', 'c': - p = Para() - p.just = just - p.addword(stdwin, ('New York', 'p', 12), words[0], 1, 1) - for word in words[1:-1]: - p.addword(stdwin, None, word, 1, 1) - p.addword(stdwin, None, words[-1], 2, 4) - p.addword(stdwin, ('New York', 'b', 18), 'Bye!', 0, 0) - p.addword(stdwin, ('New York', 'p', 10), 'Bye!', 0, 0) - paralist.append(p) - window = stdwin.open('Para.test()') - start = stop = selpara = None - while 1: - etype, win, detail = stdwin.getevent() - if etype == WE_CLOSE: - break - if etype == WE_SIZE: - window.change((0, 0), (1000, 1000)) - if etype == WE_DRAW: - width, height = window.getwinsize() - d = None - try: - d = window.begindrawing() - d.cliprect(detail) - d.erase(detail) - v = 0 - for p in paralist: - v = p.render(d, 0, v, width) - if p == selpara and \ - start <> None and stop <> None: - p.invert(d, start, stop) - finally: - if d: d.close() - if etype == WE_MOUSE_DOWN: - if selpara and start <> None and stop <> None: - d = window.begindrawing() - selpara.invert(d, start, stop) - d.close() - start = stop = selpara = None - mouseh, mousev = detail[0] - for p in paralist: - start = p.whereis(stdwin, mouseh, mousev) - if start <> None: - selpara = p - break - if etype == WE_MOUSE_UP and start <> None and selpara: - mouseh, mousev = detail[0] - stop = selpara.whereis(stdwin, mouseh, mousev) - if stop == None: start = selpara = None - else: - if start > stop: - start, stop = stop, start - d = window.begindrawing() - selpara.invert(d, start, stop) - d.close() - window.close() --- 342,343 ---- From python-dev@python.org Mon May 8 18:31:13 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 8 May 2000 13:31:13 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Lib/dos-8x3 mimepars.py,NONE,1.1 rfc822-n.py,NONE,1.1 robotpar.py,NONE,1.1 sre_comp.py,NONE,1.1 sre_cons.py,NONE,1.1 sre_pars.py,NONE,1.1 stringol.py,NONE,1.1 test_con.py,NONE,1.1 test_ext.py,NONE,1.1 test_for.py,NONE,1.1 test_mma.py,NONE,1.1 test_pye.py,NONE,1.1 test_uni.py,NONE,1.1 test_win.py,NONE,1.1 test_zip.py,NONE,1.1 threadst.py,NONE,1.1 userstri.py,NONE,1.1 basehttp.py,1.4,1.5 cgihttps.py,1.6,1.7 configpa.py,1.5,1.6 exceptio.py,1.7,1.8 fileinpu.py,1.3,1.4 formatte.py,1.8,1.9 gopherli.py,1.2,1.3 htmlenti.py,1.1,1.2 linecach.py,1.1,1.2 macurl2p.py,1.5,1.6 mimetool.py,1.6,1.7 mimetype.py,1.5,1.6 multifil.py,1.3,1.4 nturl2pa.py,1.3,1.4 posixfil.py,1.7,1.8 posixpat.py,1.9,1.10 py_compi.py,1.8,1.9 queue.py,1.6,1.7 regex_sy.py,1.2,1.3 rlcomple.py,1.4,1.5 simpleht.py,1.4,1.5 socketse.py,1.8,1.9 statcach.py,1.1,1.2 stringio.py,1.3,1.4 telnetli.py,1.3,1.4 test_bin.py,1.2,1.3 test_cpi.py,1.1,1.2 test_fcn.py,1.5,1.6 test_gdb.py,1.1,1.2 test_gra.py,! 1.2,1.3 test_lon.py,1.1,1.2 test_rfc.py,1.1,1.2 test_soc.py,1.5,1.6 test_typ.py,1.6,1.7 test_zli.py,1.4,1.5 threadin.py,1.1,1.2 tracebac.py,1.6,1.7 userdict.py,1.5,1.6 userlist.py,1.5,1.6 Message-ID: <200005081731.NAA21463@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Lib/dos-8x3 In directory eric:/projects/python/develop/guido/src/Lib/dos-8x3 Modified Files: basehttp.py cgihttps.py configpa.py exceptio.py fileinpu.py formatte.py gopherli.py htmlenti.py linecach.py macurl2p.py mimetool.py mimetype.py multifil.py nturl2pa.py posixfil.py posixpat.py py_compi.py queue.py regex_sy.py rlcomple.py simpleht.py socketse.py statcach.py stringio.py telnetli.py test_bin.py test_cpi.py test_fcn.py test_gdb.py test_gra.py test_lon.py test_rfc.py test_soc.py test_typ.py test_zli.py threadin.py tracebac.py userdict.py userlist.py Added Files: mimepars.py rfc822-n.py robotpar.py sre_comp.py sre_cons.py sre_pars.py stringol.py test_con.py test_ext.py test_for.py test_mma.py test_pye.py test_uni.py test_win.py test_zip.py threadst.py userstri.py Log Message: The usual... Index: basehttp.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/dos-8x3/basehttp.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** basehttp.py 1999/04/08 20:27:39 1.4 --- basehttp.py 2000/05/08 17:30:59 1.5 *************** *** 69,73 **** import socket # For gethostbyaddr() import string - import rfc822 import mimetools import SocketServer --- 69,72 ---- *************** *** 95,104 **** if not host or host == '0.0.0.0': host = socket.gethostname() ! hostname, hostnames, hostaddrs = socket.gethostbyaddr(host) ! if '.' not in hostname: ! for host in hostnames: ! if '.' in host: ! hostname = host ! break self.server_name = hostname self.server_port = port --- 94,107 ---- if not host or host == '0.0.0.0': host = socket.gethostname() ! try: ! hostname, hostnames, hostaddrs = socket.gethostbyaddr(host) ! except socket.error: ! hostname = host ! else: ! if '.' not in hostname: ! for host in hostnames: ! if '.' in host: ! hostname = host ! break self.server_name = hostname self.server_port = port *************** *** 170,174 **** This server parses the request and the headers, and then calls a function specific to the request type (). Specifically, ! a request SPAM will be handled by a method handle_SPAM(). If no such method exists the server sends an error response to the client. If it exists, it is called with no arguments: --- 173,177 ---- This server parses the request and the headers, and then calls a function specific to the request type (). Specifically, ! a request SPAM will be handled by a method do_SPAM(). If no such method exists the server sends an error response to the client. If it exists, it is called with no arguments: *************** *** 217,230 **** server_version = "BaseHTTP/" + __version__ ! def handle(self): ! """Handle a single HTTP request. ! You normally don't need to override this method; see the class ! __doc__ string for information on how to handle specific HTTP ! commands such as GET and POST. ! """ ! self.raw_requestline = self.rfile.readline() self.request_version = version = "HTTP/0.9" # Default requestline = self.raw_requestline --- 220,234 ---- server_version = "BaseHTTP/" + __version__ ! def parse_request(self): ! """Parse a request (internal). ! The request should be stored in self.raw_request; the results ! are in self.command, self.path, self.request_version and ! self.headers. ! Return value is 1 for success, 0 for failure; on failure, an ! error is sent back. ! """ self.request_version = version = "HTTP/0.9" # Default requestline = self.raw_requestline *************** *** 239,243 **** if version[:5] != 'HTTP/': self.send_error(400, "Bad request version (%s)" % `version`) ! return elif len(words) == 2: [command, path] = words --- 243,247 ---- if version[:5] != 'HTTP/': self.send_error(400, "Bad request version (%s)" % `version`) ! return 0 elif len(words) == 2: [command, path] = words *************** *** 245,257 **** self.send_error(400, "Bad HTTP/0.9 request type (%s)" % `command`) ! return else: self.send_error(400, "Bad request syntax (%s)" % `requestline`) ! return self.command, self.path, self.request_version = command, path, version self.headers = self.MessageClass(self.rfile, 0) ! mname = 'do_' + command if not hasattr(self, mname): ! self.send_error(501, "Unsupported method (%s)" % `command`) return method = getattr(self, mname) --- 249,275 ---- self.send_error(400, "Bad HTTP/0.9 request type (%s)" % `command`) ! return 0 else: self.send_error(400, "Bad request syntax (%s)" % `requestline`) ! return 0 self.command, self.path, self.request_version = command, path, version self.headers = self.MessageClass(self.rfile, 0) ! return 1 ! ! def handle(self): ! """Handle a single HTTP request. ! ! You normally don't need to override this method; see the class ! __doc__ string for information on how to handle specific HTTP ! commands such as GET and POST. ! ! """ ! ! self.raw_requestline = self.rfile.readline() ! if not self.parse_request(): # An error code has been sent, just exit ! return ! mname = 'do_' + self.command if not hasattr(self, mname): ! self.send_error(501, "Unsupported method (%s)" % `self.command`) return method = getattr(self, mname) Index: cgihttps.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/dos-8x3/cgihttps.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** cgihttps.py 1998/12/22 13:50:29 1.6 --- cgihttps.py 2000/05/08 17:30:59 1.7 *************** *** 4,7 **** --- 4,10 ---- requests to cgi-bin scripts. + If the os.fork() function is not present, this module will not work; + SystemError will be raised instead. + """ *************** *** 11,17 **** import os - import sys - import time - import socket import string import urllib --- 14,17 ---- *************** *** 20,23 **** --- 20,29 ---- + try: + os.fork + except AttributeError: + raise SystemError, __name__ + " requires os.fork()" + + class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): *************** *** 151,154 **** --- 157,163 ---- if ua: env['HTTP_USER_AGENT'] = ua + co = filter(None, self.headers.getheaders('cookie')) + if co: + env['HTTP_COOKIE'] = string.join(co, ', ') # XXX Other HTTP_* headers decoded_query = string.replace(query, '+', ' ') *************** *** 178,182 **** try: nobody = pwd.getpwnam('nobody')[2] ! except pwd.error: nobody = 1 + max(map(lambda x: x[2], pwd.getpwall())) return nobody --- 187,191 ---- try: nobody = pwd.getpwnam('nobody')[2] ! except KeyError: nobody = 1 + max(map(lambda x: x[2], pwd.getpwall())) return nobody Index: configpa.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/dos-8x3/configpa.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** configpa.py 1999/02/16 20:05:33 1.5 --- configpa.py 2000/05/08 17:30:59 1.6 *************** *** 34,42 **** return all the configuration section names, sans DEFAULT options(section) return list of configuration options for the named section read(filenames) ! read and parse the list of named configuration files get(section, option, raw=0, vars=None) --- 34,55 ---- return all the configuration section names, sans DEFAULT + has_section(section) + return whether the given section exists + options(section) return list of configuration options for the named section + has_option(section, option) + return whether the given section has the given option + read(filenames) ! read and parse the list of named configuration files, given by ! name. A single filename is also allowed. Non-existing files ! are ignored. ! ! readfp(fp, filename=None) ! read and parse one configuration file, given as a file object. ! The filename defaults to fp.name; it is only used in error ! messages (if fp has no `name' attribute, the string `' is used). get(section, option, raw=0, vars=None) *************** *** 159,162 **** --- 172,176 ---- def options(self, section): + """Return a list of option names for the given section name.""" try: opts = self.__sections[section].copy() *************** *** 166,180 **** return opts.keys() def read(self, filenames): ! """Read and parse a list of filenames.""" if type(filenames) is type(''): filenames = [filenames] ! for file in filenames: try: ! fp = open(file, 'r') ! self.__read(fp) except IOError: ! pass def get(self, section, option, raw=0, vars=None): """Get an option value for a given section. --- 180,227 ---- return opts.keys() + def has_option(self, section, option): + """Return whether the given section has the given option.""" + try: + opts = self.__sections[section] + except KeyError: + raise NoSectionError(section) + return opts.has_key(option) + def read(self, filenames): ! """Read and parse a filename or a list of filenames. ! ! Files that cannot be opened are silently ignored; this is ! designed so that you can specify a list of potential ! configuration file locations (e.g. current directory, user's ! home directory, systemwide directory), and all existing ! configuration files in the list will be read. A single ! filename may also be given. ! """ if type(filenames) is type(''): filenames = [filenames] ! for filename in filenames: try: ! fp = open(filename) except IOError: ! continue ! self.__read(fp, filename) ! fp.close() ! ! def readfp(self, fp, filename=None): ! """Like read() but the argument must be a file-like object. + The `fp' argument must have a `readline' method. Optional + second argument is the `filename', which if not given, is + taken from fp.name. If fp has no `name' attribute, `' is + used. + + """ + if filename is None: + try: + filename = fp.name + except AttributeError: + filename = '' + self.__read(fp, filename) + def get(self, section, option, raw=0, vars=None): """Get an option value for a given section. *************** *** 200,204 **** if vars: d.update(vars) ! option = string.lower(option) try: rawval = d[option] --- 247,251 ---- if vars: d.update(vars) ! option = self.optionxform(option) try: rawval = d[option] *************** *** 213,217 **** while depth < 10: # Loop through this until it's done depth = depth + 1 ! if not string.find(value, "%("): try: value = value % d --- 260,264 ---- while depth < 10: # Loop through this until it's done depth = depth + 1 ! if string.find(value, "%(") >= 0: try: value = value % d *************** *** 237,252 **** return val # # Regular expressions for parsing section headers and options. Note a # slight semantic change from the previous version, because of the use # of \w, _ is allowed in section header names. ! __SECTCRE = re.compile( r'\[' # [ ! r'(?P
[-\w]+)' # `-', `_' or any alphanum r'\]' # ] ) ! __OPTCRE = re.compile( ! r'(?P