Your message dated Wed, 21 Jan 2015 10:02:58 +0100 with message-id <[email protected]> and subject line Re: Bug#653177: Model __eq__ does not compare correctly between normal objects and deferred objects has caused the Debian Bug report #653177, regarding Model __eq__ does not compare correctly between normal objects and deferred objects to be marked as done.
This means that you claim that the problem has been dealt with. If this is not the case it is now your responsibility to reopen the Bug report if necessary, and/or fix the problem forthwith. (NB: If you are a system administrator and have no idea what this message is talking about, this may indicate a serious mail system misconfiguration somewhere. Please contact [email protected] immediately.) -- 653177: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=653177 Debian Bug Tracking System Contact [email protected] with problems
--- Begin Message ---Package: python-django Version: 1.3.1-3 Severity: normal Hello, thank you for packaging django. I noticed that there is a problem with the default model object __eq__ implementation when working with deferred objects. The default implementation should be something like: def __eq__(self, other): return isinstance(other, self.__class__) and self._get_pk_val() == other._get_pk_val() Now, given a simple model... class Package(models.Model): name = models.TextField(null=False, unique=True) # Lots of other fields ...this code will show the problem: # Get a normal object p = Package.objects.get(name="debtags") # Get a deferred object dp = Package.objects.filter(name="debtags").only("name")[0] print object.__repr__(p), hash(p) print object.__repr__(dp), hash(dp) # This assert succeeds assert hash(p) == hash(dp) # This assert fails assert p == dp Its output is: <Package: debtags> 11 <Package_Deferred_ldesc_popcon_sdesc_source_version: debtags> 11 It looks like the isinstance bit of the default __eq__ model is failing here. This causes suprising behaviour: allpkgs = set(Package.objects.all().only("name")) # This assert fails assert Package.objects.get(name="debtags") in allpkgs I'll now work around this by implementing my own version of __eq__ methods in my model objects. Something like this works: def __eq__(self, other): return self.name == other.name although I'll have to pay attention not to end up with code that compares Packages with something else. Ciao, Enrico -- System Information: Debian Release: wheezy/sid APT prefers testing APT policy: (500, 'testing') Architecture: amd64 (x86_64) Kernel: Linux 3.1.0-1-amd64 (SMP w/4 CPU cores) Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages python-django depends on: ii python 2.7.2-9 ii python2.6 2.6.7-4 ii python2.7 2.7.2-8 Versions of packages python-django recommends: ii libjs-jquery 1.7-1 Versions of packages python-django suggests: ii geoip-database-contrib <none> ii python-flup <none> ii python-mysqldb <none> ii python-psycopg <none> ii python-psycopg2 2.4.2-1 ii python-sqlite 1.0.1-8 ii python-yaml 3.10-2 -- no debconf information
--- End Message ---
--- Begin Message ---Version: 1.7-1 On Sat, 24 Dec 2011, Enrico Zini wrote: > I noticed that there is a problem with the default model object __eq__ > implementation when working with deferred objects. This has been fixed upstream thanks to your report. Cheers, -- Raphaël Hertzog ◈ Debian Developer Support Debian LTS: http://www.freexian.com/services/debian-lts.html Learn to master Debian: http://debian-handbook.info/get/
--- End Message ---
_______________________________________________ Python-modules-team mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/python-modules-team

