Fredrik Lundh [Tue, 26 Jun 2001 16:39:36 +0000 (16:39 +0000)]
experimental UCS-4 support: made compare a bit more robust, in case
sizeof(Py_UNICODE) >= sizeof(long). also changed surrogate expansion
to work if sizeof(Py_UNICODE) > 2.
Just van Rossum [Mon, 25 Jun 2001 18:01:24 +0000 (18:01 +0000)]
Return self.trace_dispatch from dispatch_return() to enable stepping through generators. (An alternative would be to create a new "yield" debugger event, but that involves many more changes, and might break Bdb subclasses.)
Tim Peters [Sun, 24 Jun 2001 20:02:47 +0000 (20:02 +0000)]
Clear the copy of the globs dict after running examples. This helps to
break cycles, which are a special problem when running generator tests
that provoke exceptions by invoking the .next() method of a named
generator-iterator: then the iterator is named in globs, and the
iterator's frame gets a tracekback object pointing back to globs, and
gc doesn't chase these types so the cycle leaks.
Also changed _run_examples() to make a copy of globs itself, so its
callers (direct and indirect) don't have to (and changed the callers
to stop making their own copies); *that* much is a change I've been
meaning to make for a long time (it's more robust the new way).
Here's a way to provoke the symptom without doctest; it leaks at a
prodigious rate; if the last two "source" lines are replaced with
g().next()
the iterator isn't named and then there's no leak:
source = """\
def g():
yield 1/0
k = g()
k.next()
"""
code = compile(source, "<source>", "exec")
def f(globs):
try:
exec code in globs
except ZeroDivisionError:
pass
while 1:
f(globals().copy())
After this change, running test_generators in an infinite loop still leaks,
but reduced from a flood to a trickle.
Tim Peters [Sun, 24 Jun 2001 06:46:58 +0000 (06:46 +0000)]
doctest doesn't handle intentional SyntaxError exceptions gracefully,
because it picks up the first line of traceback.format_exception_only()
instead of the last line. Pick up the last line instead!
Tim Peters [Sun, 24 Jun 2001 05:47:06 +0000 (05:47 +0000)]
Another variant of the 2-3-5 test, mixing generators with a LazyList class.
Good news: Some of this stuff is pretty sophisticated (read nuts), and
I haven't bumped into a bug yet.
Bad news: If I run the doctest in an infinite loop, memory is clearly
leaking.
Tim Peters [Sun, 24 Jun 2001 05:08:52 +0000 (05:08 +0000)]
Pure brute-force hackery to allow Python to build on Windows again,
because I need to make progress and don't have time now to think about
whatever it is the new code is trying to accomplish.
def g3():
for i in range(3):
yield None
yield None
assert list(g3()) == [None] * 4
compile.c: compile_funcdef and com_return_stmt: Just van Rossum's patch
to compile the same code for "return" regardless of function type (this
goes back to the previous scheme of returning Py_None).
ceval.c: gen_iternext: take a return (but not a yield) of Py_None as
meaning the generator is exhausted.
Tim Peters [Sat, 23 Jun 2001 05:47:56 +0000 (05:47 +0000)]
gen_iternext(): Don't assume that the current thread state's frame is
not NULL. I don't think it can be NULL from Python code, but if using
generators via the C API I expect a NULL frame is possible.
Tim Peters [Sat, 23 Jun 2001 05:26:56 +0000 (05:26 +0000)]
PyFrameObject: rename f_stackbottom to f_stacktop, since it points to
the next free valuestack slot, not to the base (in America, stacks push
and pop at the top -- they mutate at the bottom in Australia <winK>).
eval_frame(): assert that f_stacktop isn't NULL upon entry.
frame_delloc(): avoid ordered pointer comparisons involving f_stacktop
when f_stacktop is NULL.
Fred Drake [Sat, 23 Jun 2001 03:16:29 +0000 (03:16 +0000)]
Contributed updates from Harald Hanche-Olsen, giving details of the branch
cuts for the complex math functions. Includes a brief description of
what branch cuts are.
Tim Peters [Sat, 23 Jun 2001 02:07:08 +0000 (02:07 +0000)]
Disallow 'yield' in a 'try' block when there's a 'finally' clause.
Derived from Thomas Wouters's patch on the Iterators list, but doesn't
try to read c->c_block[c->c_nblocks].
Fred Drake [Fri, 22 Jun 2001 17:11:30 +0000 (17:11 +0000)]
Adjust to understand use of either single- or double-quotes to quote
attribute values, and make the logic surrounding the platform
annotations just a little easier to read. Also make the platform
notes appear in the generated page; they were supposed to, but did not.
Guido van Rossum [Fri, 22 Jun 2001 16:05:48 +0000 (16:05 +0000)]
This is a trivial command line utility to print MD5 checksums.
I published it on the web as http://www.python.org/2.1/md5sum.py
so I thought I might as well check it in.
Works with Python 1.5.2 and later.
Works like the Linux tool ``mdfsum file ...'' except it doesn't take
any options or read stdin.
Neil Schemenauer [Thu, 21 Jun 2001 02:41:10 +0000 (02:41 +0000)]
Try to avoid creating reference cycles involving generators. Only keep a
reference to f_back when its really needed. Do a little whitespace
normalization as well. This whole file is a big war between tabs and spaces
but now is probably not the time to reindent everything.
Jack Jansen [Wed, 20 Jun 2001 21:31:28 +0000 (21:31 +0000)]
Don't use extern when we mean staticforward (OSX gcc is picky about it).
Blacklist SendControlMessage: it's signature has changed between Universal Headers 3.3 and 3.4.
Fred Drake [Wed, 20 Jun 2001 21:29:30 +0000 (21:29 +0000)]
Added support for new \setreleaseinfo macro.
Normalize all generated HTML so that attribute names come out as
name="value" instead of name='value'.
Changed the target of RFC links to point to the hypertext RFCs at
www.faqs.org instead of the plain text RFCs at www.ietf.org.
Just van Rossum [Wed, 20 Jun 2001 19:57:55 +0000 (19:57 +0000)]
Override bdb's canonic() method with a no-op: with bdb's version we couldn't edit breakpoints in file-less ("Untitled" script windows). Besides, we did't need it as we always use full path names anyway.
Tim Peters [Wed, 20 Jun 2001 06:57:32 +0000 (06:57 +0000)]
gen_iternext(): repair subtle refcount problem.
NeilS, please check! This came from staring at your genbug.py, but I'm
not sure it plugs all possible holes. Without this, I caught a
frameobject refcount going negative, and it was also the cause (in debug
build) of _Py_ForgetReference's attempt to forget an object with already-
NULL _ob_prev and _ob_next pointers -- although I'm still not entirely
sure how! Part of the difficulty is that frameobjects are stored on a
free list that gets recycled very quickly, so if there's a stray pointer
to one of them it never looks like an insane frameobject (never goes
trough the free() mangling MS debug forces, etc).
Barry Warsaw [Tue, 19 Jun 2001 22:48:10 +0000 (22:48 +0000)]
encode(): Fixed the handling of soft line breaks for lines over 76
characters in length. Remember that when calculating the soft breaks,
the trailing `=' sign counts against the max length!
Jack Jansen [Tue, 19 Jun 2001 21:23:11 +0000 (21:23 +0000)]
- _filename_to_abs() didn't cater for .. components in the pathname. Fixed.
- compile() didn't return a (empty) list of objects. Fixed.
- the various _fix_xxx_args() methods weren't called (are they new or did I overlook them?). Fixed.
Jack Jansen [Tue, 19 Jun 2001 20:20:05 +0000 (20:20 +0000)]
The test used int(time.time()) to get a random number, but this doesn't work on the mac (where times are bigger than ints). Changed to int(time.time()%1000000).
This patch by Martin v. Loewis changes the UTF-16 codec to only
write a BOM at the start of the stream and also to only read it as
BOM at the start of a stream.
Subsequent reading/writing of BOMs will read/write the BOM as ZWNBSP
character. This is in sync with the Unicode specifications.
Note that UTF-16 files will now *have* to start with a BOM mark
in order to be readable by the codec.
Barry Warsaw [Tue, 19 Jun 2001 19:44:42 +0000 (19:44 +0000)]
Document the new encodestring() and decodestring() functions. Also,
add some description of what the quotetabs argument does for the
encode*() functions. Finally, add a "see also" pointing to the base64
module.