Tim Peters [Tue, 26 Jun 2001 22:40:47 +0000 (22:40 +0000)]
Windows build broke from recent Unicode changes -- need to #define
SIZEOF_SHORT by hand here.
Also added dynamic check that SIZEOF_SHORT is correct for the platform (in
_testcapimodule).
Martin v. Löwis [Tue, 26 Jun 2001 22:22:37 +0000 (22:22 +0000)]
Support using UCS-4 as the Py_UNICODE type:
Add configure option --enable-unicode.
Add config.h macros Py_USING_UNICODE, PY_UNICODE_TYPE, Py_UNICODE_SIZE,
SIZEOF_WCHAR_T.
Define Py_UCS2.
Encode and decode large UTF-8 characters into single Py_UNICODE values
for wide Unicode types; likewise for UTF-16.
Remove test whether sizeof Py_UNICODE is two.
Jack Jansen [Tue, 26 Jun 2001 21:51:18 +0000 (21:51 +0000)]
First small step towards bgen-generated CoreFoundation. there is hardly any real functionality yet, but method chains seem to work, and so do Retain/Release semantics.
Tim Peters [Tue, 26 Jun 2001 20:58:58 +0000 (20:58 +0000)]
Add "gi_" (generator-iterator) prefix to names of genobject members.
Makes it much easier to find references via dumb editor search (former
"frame" in particular was near-hopeless).
Barry Warsaw [Tue, 26 Jun 2001 20:09:28 +0000 (20:09 +0000)]
Add a bunch of tests for extended dict.update() where the argument is
a non-dictionary mapping object. Include tests for several expected
failure modes.
Barry Warsaw [Tue, 26 Jun 2001 20:08:32 +0000 (20:08 +0000)]
dict_update(): Generalize this method so {}.update() accepts any
"mapping" object, specifically one that supports PyMapping_Keys() and
PyObject_GetItem(). This allows you to say e.g. {}.update(UserDict())
We keep the special case for concrete dict objects, although that
seems moderately questionable. OTOH, the code exists and works, so
why change that?
.update()'s docstring already claims that D.update(E) implies calling
E.keys() so it's appropriate not to transform AttributeErrors in
PyMapping_Keys() to TypeErrors.
Fredrik Lundh [Tue, 26 Jun 2001 17:17:07 +0000 (17:17 +0000)]
experimental UCS-4 support: added USE_UCS4_STORAGE define to
unicodeobject.h, which forces sizeof(Py_UNICODE) == sizeof(Py_UCS4).
(this may be good enough for platforms that doesn't have a 16-bit
type. the UTF-16 codecs don't work, though)
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.