Author xdegaye
Recipients rhettinger, stutzbach, xdegaye
Date 2013-09-28.20:53:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1380401602.68.0.29924709136.issue19119@psf.upfronthosting.co.za>
In-reply-to
Content
There are two test_get_only methods. The patch provides a partial
fix, but removes the following two lines from the first method as the
execution of these lines fails:

  for f in (self.module.nlargest, self.module.nsmallest):
      self.assertRaises(TypeError, f, 2, GetOnly())

because heapq.nlargest is stuck in an infinite loop when the sequence
does not have a length. This seems to be a bug in nlargest. See the
following test that runs with 100 % cpu usage.

$ ./python
Python 3.4.0a2+ (default:f6792f734fcc, Sep 28 2013, 17:09:46) 
[GCC 4.3.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> class GetOnly:
...     "Dummy sequence class defining __getitem__ but not __len__."
...     def __getitem__(self, ndx):
...         return 10
... 
>>> import heapq
>>> heapq.nlargest(2, GetOnly())
^CTraceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "Lib/heapq.py", line 455, in nlargest
    result = _nlargest(n, it)
  File "<stdin>", line 3, in __getitem__
KeyboardInterrupt
>>>
History
Date User Action Args
2013-09-28 20:53:22xdegayesetrecipients: + xdegaye, rhettinger, stutzbach
2013-09-28 20:53:22xdegayesetmessageid: <1380401602.68.0.29924709136.issue19119@psf.upfronthosting.co.za>
2013-09-28 20:53:22xdegayelinkissue19119 messages
2013-09-28 20:53:22xdegayecreate