[issue16991] Add OrderedDict written in C

Eric Snow report at bugs.python.org
Sat May 23 01:38:31 CEST 2015


Eric Snow added the comment:

If I still the following at Lib/test/test_configparser.py:328:

  print(len(cf._proxies), len(list(cf._proxies)), list(cf._proxies))
  print(len(cf._sections), len(list(cf._sections)), list(cf._sections))

I get unexpected results that are a clear indication of a problem:

  9 8 ['DEFAULT', 'Foo Bar', 'Spacey Bar', 'Spacey Bar From The Beginning', 'Commented Bar', 'Long Line', 'Section\\with$weird%characters[\t', 'Internationalized Stuff']
  8 7 ['Foo Bar', 'Spacey Bar', 'Spacey Bar From The Beginning', 'Commented Bar', 'Long Line', 'Section\\with$weird%characters[\t', 'Internationalized Stuff']

Note that OrderedDict.__len__ is just dict.__len__, so the first number (the actual length) should be the same as the second number (the number of keys).  Also note that OrderedDict.keys() is working (even if not exactly correct).  Between the two observations, this implies that for this one test the keys are not only off, but at least one of the keys in the linked list is not in the underlying dict.

I'm sure this is consequence of resizing.  At the last point that we resize this is the state of the cf._proxies and cf._sections (ignore the trailing <NULL> (?)):

  OrderedDict([('DEFAULT', <Section: DEFAULT>), ('Foo Bar', <Section: Foo Bar>), ('Spacey Bar', <Section: Spacey Bar>), ('Spacey Bar From The Beginning', <Section: Spacey Bar From The Beginning>), ('Commented Bar', <Section: Commented Bar>), <NULL>])

  OrderedDict([('Foo Bar', OrderedDict([('foo', ['bar1'])])), ('Spacey Bar', OrderedDict([('foo', ['bar2'])])), ('Spacey Bar From The Beginning', OrderedDict([('foo', ['bar3']), ('baz', ['qwe'])])), ('Commented Bar', OrderedDict([('foo', ['bar4']), ('baz', ['qwe'])])), ('Long Line', OrderedDict([('foo', ['this line is much, much longer than my editor', 'likes it.'])])), <NULL>])

I haven't had time to analyze this but I'll be taking a closer look in later tonight.  I'm not giving up on 3.5. :)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16991>
_______________________________________


More information about the Python-bugs-list mailing list