<feed xmlns='http://www.w3.org/2005/Atom'>
<title>python.git/Objects, branch v2.1c2</title>
<subtitle>Python interpreter</subtitle>
<id>http://dangofactory.net/cgit/cgit.cgi/Server/python.git/atom/Objects?h=v2.1c2</id>
<link rel='self' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/atom/Objects?h=v2.1c2'/>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/'/>
<updated>2001-04-16T00:02:32Z</updated>
<entry>
<title>Tim pointed out a remaining vulnerability in popitem(): the</title>
<updated>2001-04-16T00:02:32Z</updated>
<author>
<name>Guido van Rossum</name>
<email>guido@python.org</email>
</author>
<published>2001-04-16T00:02:32Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=e04eaec5b60a41b114dd3b7d78c3a389f8534af8'/>
<id>urn:sha1:e04eaec5b60a41b114dd3b7d78c3a389f8534af8</id>
<content type='text'>
PyTuple_New() could *conceivably* clear the dict, so move the test for
an empty dict after the tuple allocation.  It means that we waste time
allocating and deallocating a 2-tuple when the dict is empty, but who
cares.  It also means that when the dict is empty *and* there's no
memory to allocate a 2-tuple, we raise MemoryError, not KeyError --
but that may actually a good idea: if there's no room for a lousy
2-tuple, what are the chances that there's room for a KeyError
instance?
</content>
</entry>
<entry>
<title>Tentative fix for a problem that Tim discovered at the last moment,</title>
<updated>2001-04-15T22:16:26Z</updated>
<author>
<name>Guido van Rossum</name>
<email>guido@python.org</email>
</author>
<published>2001-04-15T22:16:26Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=a4dd011259fa6f3079bd0efd95b3a136c0e3c190'/>
<id>urn:sha1:a4dd011259fa6f3079bd0efd95b3a136c0e3c190</id>
<content type='text'>
and reported to python-dev: because we were calling dict_resize() in
PyDict_Next(), and because GC's dict_traverse() uses PyDict_Next(),
and because PyTuple_New() can cause GC, and because dict_items() calls
PyTuple_New(), it was possible for dict_items() to have the dict
resized right under its nose.

The solution is convoluted, and touches several places: keys(),
values(), items(), popitem(), PyDict_Next(), and PyDict_SetItem().

There are two parts to it. First, we no longer call dict_resize() in
PyDict_Next(), which seems to solve the immediate problem.  But then
PyDict_SetItem() must have a different policy about when *it* calls
dict_resize(), because we want to guarantee (e.g. for an algorithm
that Jeremy uses in the compiler) that you can loop over a dict using
PyDict_Next() and make changes to the dict as long as those changes
are only value replacements for existing keys using PyDict_SetItem().
This is done by resizing *after* the insertion instead of before, and
by remembering the size before we insert the item, and if the size is
still the same, we don't bother to even check if we might need to
resize.  An additional detail is that if the dict starts out empty, we
must still resize it before the insertion.

That was the first part. :-)

The second part is to make keys(), values(), items(), and popitem()
safe against side effects on the dict caused by allocations, under the
assumption that if the GC can cause arbitrary Python code to run, it
can cause other threads to run, and it's not inconceivable that our
dict could be resized -- it would be insane to write code that relies
on this, but not all code is sane.

Now, I have this nagging feeling that the loops in lookdict probably
are blissfully assuming that doing a simple key comparison does not
change the dict's size.  This is not necessarily true (the keys could
be class instances after all).  But that's a battle for another day.
</content>
</entry>
<entry>
<title>Make one more private symbol static.</title>
<updated>2001-04-14T17:55:41Z</updated>
<author>
<name>Guido van Rossum</name>
<email>guido@python.org</email>
</author>
<published>2001-04-14T17:55:41Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=6b356e70b5f3d0ce99d84576401c2acca6a0b90e'/>
<id>urn:sha1:6b356e70b5f3d0ce99d84576401c2acca6a0b90e</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Make some private symbols static.</title>
<updated>2001-04-14T17:55:09Z</updated>
<author>
<name>Guido van Rossum</name>
<email>guido@python.org</email>
</author>
<published>2001-04-14T17:55:09Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=f68d8e52e7ce833d123de034a4f123ec710a639f'/>
<id>urn:sha1:f68d8e52e7ce833d123de034a4f123ec710a639f</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Bug 415514 reported that e.g.</title>
<updated>2001-04-12T18:38:48Z</updated>
<author>
<name>Tim Peters</name>
<email>tim.peters@gmail.com</email>
</author>
<published>2001-04-12T18:38:48Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=fff53250789c3879e5f63d4dde80d17e0b9c4dbb'/>
<id>urn:sha1:fff53250789c3879e5f63d4dde80d17e0b9c4dbb</id>
<content type='text'>
    "%#x" % 0
blew up, at heart because C sprintf supplies a base marker if and only if
the value is not 0.  I then fixed that, by tolerating C's inconsistency
when it does %#x, and taking away that *Python* produced 0x0 when
formatting 0L (the "long" flavor of 0) under %#x itself.  But after talking
with Guido, we agreed it would be better to supply 0x for the short int
case too, despite that it's inconsistent with C, because C is inconsistent
with itself and with Python's hex(0) (plus, while "%#x" % 0 didn't work
before, "%#x" % 0L *did*, and returned "0x0").  Similarly for %#X conversion.
</content>
</entry>
<entry>
<title>Fix for SF bug #415514: "%#x" % 0 caused assertion failure/abort.</title>
<updated>2001-04-12T00:35:51Z</updated>
<author>
<name>Tim Peters</name>
<email>tim.peters@gmail.com</email>
</author>
<published>2001-04-12T00:35:51Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=711088d9b8c6898aad571fb251cb40a8b7d42f64'/>
<id>urn:sha1:711088d9b8c6898aad571fb251cb40a8b7d42f64</id>
<content type='text'>
http://sourceforge.net/tracker/index.php?func=detail&amp;aid=415514&amp;group_id=5470&amp;atid=105470
For short ints, Python defers to the platform C library to figure out what
%#x should do.  The code asserted that the platform C returned a string
beginning with "0x".  However, that's not true when-- and only when --the
*value* being formatted is 0.  Changed the code to live with C's inconsistency
here.  In the meantime, the problem does not arise if you format a long 0 (0L)
instead.  However, that's because the code *we* wrote to do %#x conversions on
longs produces a leading "0x" regardless of value.  That's probably wrong too:
we should drop leading "0x", for consistency with C, when (&amp; only when) formatting
0L.  So I changed the long formatting code to do that too.
</content>
</entry>
<entry>
<title>Fixed ref count bug. Patch #411191. Found by Walter Dörwald.</title>
<updated>2001-03-25T19:16:13Z</updated>
<author>
<name>Marc-André Lemburg</name>
<email>mal@egenix.com</email>
</author>
<published>2001-03-25T19:16:13Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=ae605341e3eb9e6426db07660ac57675ae86e2b6'/>
<id>urn:sha1:ae605341e3eb9e6426db07660ac57675ae86e2b6</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Add support for weak references to the function and method types.</title>
<updated>2001-03-23T04:19:27Z</updated>
<author>
<name>Fred Drake</name>
<email>fdrake@acm.org</email>
</author>
<published>2001-03-23T04:19:27Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=db81e8ddf8953359e8c2ed9569dd2e774d78ae95'/>
<id>urn:sha1:db81e8ddf8953359e8c2ed9569dd2e774d78ae95</id>
<content type='text'>
</content>
</entry>
<entry>
<title>A small change to the C API for weakly-referencable types:  Such types</title>
<updated>2001-03-22T18:26:47Z</updated>
<author>
<name>Fred Drake</name>
<email>fdrake@acm.org</email>
</author>
<published>2001-03-22T18:26:47Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=4e262a963190b201578b0b5d972035b1637f6bd5'/>
<id>urn:sha1:4e262a963190b201578b0b5d972035b1637f6bd5</id>
<content type='text'>
must now initialize the extra field used by the weak-ref machinery to
NULL themselves, to avoid having to require PyObject_INIT() to check
if the type supports weak references and do it there.  This causes less
work to be done for all objects (the type object does not need to be
consulted to check for the Py_TPFLAGS_HAVE_WEAKREFS bit).
</content>
</entry>
<entry>
<title>Make PyDict_Next safe to use for loops that merely modify the values</title>
<updated>2001-03-21T19:23:56Z</updated>
<author>
<name>Tim Peters</name>
<email>tim.peters@gmail.com</email>
</author>
<published>2001-03-21T19:23:56Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=6783070ebfa77aeaf7b5db758095e93cf8e2635c'/>
<id>urn:sha1:6783070ebfa77aeaf7b5db758095e93cf8e2635c</id>
<content type='text'>
associated with existing dict keys.
This is a variant of part of Michael Hudson's patch #409864 "lazy fix for
Pings bizarre scoping crash".
</content>
</entry>
</feed>
