Re: anybody else embed their Pythons?

Guido.van.Rossum@cwi.nl
Sat, 28 May 1994 01:09:17 +0200

> Yesterday I put Alice (our system)
> together with Python-1.0.2 and it all compiled okay, but when I typed
> a simple assignment, say "a = 42" I heard my disk start going nuts.
> When I ran a top it turned out that my process had ballooned up in
> memory from 1.78 meg to 199.8 meg!!!

We discussed this a little over private email. The fix is important
enough to post to the whole group -- a new bug in 1.0.2 causes a loop
in the tokenizer when the last line doesn't end in '\n'. Here's a
patch.

*** 2.14.2.3 1994/04/28 12:31:46
--- tokenizer.c 1994/05/23 12:40:51
***************
*** 267,274 ****
tok->buf + curstart;
if (fgets(tok->inp,
(int)(tok->end - tok->inp),
! tok->fp) == NULL)
! break;
tok->inp = strchr(tok->inp, '\0');
done = tok->inp[-1] == '\n';
}
--- 267,277 ----
tok->buf + curstart;
if (fgets(tok->inp,
(int)(tok->end - tok->inp),
! tok->fp) == NULL) {
! /* Last line does not end in \n,
! fake one */
! strcpy(tok->inp, "\n");
! }
tok->inp = strchr(tok->inp, '\0');
done = tok->inp[-1] == '\n';
}

--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>
URL: <http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>