On 2 December 2010 15:43, Dan Fairs <[email protected]> wrote:
> Hi,
>
> Apologies for the slightly lengthy email.
>
> I'm working on getting ticket #2705 (Add optional FOR UPDATE clause to 
> QuerySets) into shape, primarily by adding tests to the patch. I'm writing a 
> test for a backend's FOR UPDATE NOWAIT, and have come across some interesting 
> behaviour where DatabaseError appears to be swallowed when converting a 
> queryset to a list. This doesn't happen when simply iterating over a queryset.
>
> My gut feeling is that this boils down to this vastly simplified 
> demonstration of how list() works:
>
>>>> class Foo(object):
> ...   def __len__(self):
> ...     print 'len called'
> ...     raise ValueError
> ...   def __iter__(self):
> ...     return iter([1,2,3])
> ...
>>>> a = Foo()
>>>> list(a)
> len called
> [1, 2, 3]
>

<snip>

I tested it on my machine and it raises ValueError on:

  * Python 2.4.6
  * Python 2.5.5
  * Python 2.6.6
  * Python 2.7.0+
  * Python 3.1.2

If you have  version 2.6.1, you should upgrade. I don't think Django
should support a Python bug that was fixed almost 2 years ago.

-- 
Łukasz Rekucki

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to