Issue 667730: More DictMixin - Python tracker (original) (raw)

Created on 2003-01-14 13:27 by s_keim, last changed 2022-04-10 16:06 by admin. This issue is now closed.

Messages (7)

msg42412 - (view)

Author: Sebastien Keim (s_keim)

Date: 2003-01-14 13:27

This patch is intended to provide a more consistent implementation for the various dictionary like objects of the standard library.

test_userdict has been rewritten, it now use unittest and define a test-case wich allow to check for conformity with the dictionary protocol.

test_shelve and test_weakref have been rewritten to use the test_userdict test-case.

test_os has been extended: a new test case check for environ object conformity to the dictionary protocol.

The patch modify the UserDict module:

In the weakref module, the patch make WeakValueDictionnary and WeakKeyDictionnary subclasses of UserDict.DictMixin. It also use nested scopes, the new generators syntax for iterator methods and rewrite WeakKeyDictionnary.delitem . All of this allow to decrease the module size by 50%.

In the shelve module, the patch add a copy() method which return a dictionary with the keys and values of the database.

msg42413 - (view)

Author: Martin v. Löwis (loewis) * (Python committer)

Date: 2003-01-14 21:43

Logged In: YES user_id=21627

This patch breaks backwards compatibility. UserDict is an oldstyle class on purpose, since changing it to a newstyle class will certainly break the compatibility in subtle ways (e.g. by changing what type(userdictinstance) is).

Unless you can bring forward a better rationale than consistency, this patch will be rejected.

msg42414 - (view)

Author: Raymond Hettinger (rhettinger) * (Python committer)

Date: 2003-01-16 02:35

Logged In: YES user_id=80475

msg42415 - (view)

Author: Raymond Hettinger (rhettinger) * (Python committer)

Date: 2003-01-16 02:50

Logged In: YES user_id=80475

Also, +1 on consolidating the test cases though it should be done after any other changes to the files so we can make sure that nothing got broken.

msg42416 - (view)

Author: Sebastien Keim (s_keim)

Date: 2003-03-03 15:27

Logged In: YES user_id=498191

I have downloaded a new version of the patch updated to Python2.3a2

I hope to have removed all the stuff which could break backward compatibility since the new proposed patch contain now only the testing stuff (well, almost since I have also added a pop method to the weak dictionary classes to make them compatible with the test case).

msg42417 - (view)

Author: Raymond Hettinger (rhettinger) * (Python committer)

Date: 2003-03-07 05:52

Logged In: YES user_id=80475

The patch looks good. Please make two adjustments and re-submit.

  1. Change the test_func docstrings to comment blocks. If a docstring is present, test support will print them in the summary instead of the test name.

  2. Change the logic for mapping.pop() to accommodate the new default argument option which was added yesterday. The format is m.pop(key[, default]).

msg42418 - (view)

Author: Raymond Hettinger (rhettinger) * (Python committer)

Date: 2003-03-09 07:23

Logged In: YES user_id=80475

Accepted patch. Made the suggested fix-ups. Fixed spelling. Replace _tested_class method with an equivalent class variable.

Applied as: Lib/weakref.py 1.19 Lib/test/test_userdict.py 1.14 Lib/test/test_os.py 1.14 Lib/test/test_shelve.py 1.3 Lib/test/test_weakref.py 1.22