Changes between Initial Version and Version 3 of Ticket #19616

01/16/13 05:49:35 (4 years ago)
Luke Plant

Looking at the code and the comments in the else branch, it actually seems very obvious that the function has covered it's bases about whether self._result_cache is None or not. We need either some further analysis as to why it is wrong, or a simple test case that ought to work.


  • Ticket #19616 – Description

    initial v3  
    11This is the code from QuerySet (version 1.42).
    22As you can see by the lines I've bolded, although _result_cache might be None, it is still being checked for len()
    44def __contains__(self, val):
    55        # The 'in' operator works without this method, due to __iter__. This
    77        # instances, by bailing out early if we find a matching element.
    88        pos = 0
    9         '''if self._result_cache is not None:'''
     9        if self._result_cache is not None:
    1010            if val in self._result_cache:
    1111                return True
    1515            # remember not to check these again:
    1616            pos = len(self._result_cache)
    17         '''else:'''
     17        else:
    1818            # We need to start filling the result cache out. The following
    1919            # ensures that self._iter is not None and self._result_cache is not
    2323        # Carry on, one result at a time.
    2424        while True:
    25            ''' if len(self._result_cache) <= pos:'''
     25           if len(self._result_cache) <= pos:
    2626                self._fill_cache(num=1)
Back to Top