#15062: r14389 breaks getattr on Manager subclasses
---------------------------------------------------+------------------------
Reporter: clelland | Owner: nobody
Status: reopened | Milestone: 1.3
Component: Database layer (models, ORM) | Version: SVN
Resolution: | Keywords:
Stage: Unreviewed | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
---------------------------------------------------+------------------------
Changes (by clelland):
* status: closed => reopened
* resolution: worksforme =>
Comment:
Regarding (1), that was a mistake; egather was the name of the project I
was working on at the time, and I edited the stacktrace to remove the name
(not as carefully as I could have, apparently, though.)
I've been able to reproduce it again, with a fresh virtualenv, and a
checkout of Django 1.2.X at revision r14390, using Python 2.6.6 from
!MacPorts and MySQL 5.1.33.
I will attach my settings.py and models.py to this ticket.
I have dropped databases, deleted virtualenvs, and started from scratch to
reproduce this. This is my project setup:
{{{
ian@Ian-Clellands-MacBook-Pro:~/Code/Tests$ mkvirtualenv testcode
New python executable in testcode/bin/python
Installing setuptools............done.
virtualenvwrapper.user_scripts Creating
/Users/ian/.virtualenvs/testcode/bin/predeactivate
virtualenvwrapper.user_scripts Creating
/Users/ian/.virtualenvs/testcode/bin/postdeactivate
virtualenvwrapper.user_scripts Creating
/Users/ian/.virtualenvs/testcode/bin/preactivate
virtualenvwrapper.user_scripts Creating
/Users/ian/.virtualenvs/testcode/bin/postactivate
virtualenvwrapper.user_scripts Creating
/Users/ian/.virtualenvs/testcode/bin/get_env_details
(testcode)ian@Ian-Clellands-MacBook-Pro:~/Code/Tests$ ln -s
~/Code/Frameworks/django-1.2.X/django
~/.virtualenvs/testcode/lib/python2.6/site-packages/
(testcode)ian@Ian-Clellands-MacBook-Pro:~/Code/Tests$
~/Code/Frameworks/django-1.2.X/django/bin/django-admin.py startproject
related_test
(testcode)ian@Ian-Clellands-MacBook-Pro:~/Code/Tests$ cd related_test
(testcode)ian@Ian-Clellands-MacBook-Pro:~/Code/Tests/related_test$ mysql
-u django -p mysql
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1711
Server version: 5.1.53 Source distribution
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights
reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input
statement.
mysql> create database related_test;
Query OK, 1 row affected (0.00 sec)
mysql> \q
Bye
(testcode)ian@Ian-Clellands-MacBook-Pro:~/Code/Tests/related_test$
./manage.py startapp test_app
(testcode)ian@Ian-Clellands-MacBook-Pro:~/Code/Tests/related_test$
}}}
I then edited settings.py and test_app.models.py -- see attached files
Creating a user object, and then trying to create a related !TestModel
instance is sufficient to see this behaviour:
{{{
(testcode)ian@Ian-Clellands-MacBook-Pro:~/Code/Tests/related_test$
./manage.py syncdb
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table test_app_testmodel
You just installed Django's auth system, which means you don't have any
superusers defined.
Would you like to create one now? (yes/no): no
Installing index for auth.Permission model
Installing index for auth.Group_permissions model
Installing index for auth.User_user_permissions model
Installing index for auth.User_groups model
Installing index for auth.Message model
Installing index for test_app.TestModel model
No fixtures found.
(testcode)ian@Ian-Clellands-MacBook-Pro:~/Code/Tests/related_test$
./manage.py shell
Python 2.6.6 (r266:84292, Dec 29 2010, 09:13:15)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.contrib.auth.models import User
>>> user = User.objects.create_user('testuser', '[email protected]')
>>> user.id
1L
>>> user.testmodel_set.create(string='test')
Exception RuntimeError: 'maximum recursion depth exceeded in
__subclasscheck__' in <type 'exceptions.AttributeError'> ignored
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Users/ian/.virtualenvs/testcode/lib/python2.6/site-
packages/django/db/models/fields/related.py", line 423, in create
return super(RelatedManager, self.db_manager(db)).create(**kwargs)
File "/Users/ian/.virtualenvs/testcode/lib/python2.6/site-
packages/django/db/models/manager.py", line 138, in create
return self.get_query_set().create(**kwargs)
File "/Users/ian/.virtualenvs/testcode/lib/python2.6/site-
packages/django/db/models/fields/related.py", line 410, in get_query_set
return
superclass.get_query_set(self).using(db).filter(**(self.core_filters))
File "/Users/ian/Code/Tests/related_test/test_app/models.py", line 17,
in __getattr__
return getattr(self.get_query_set(), attr, *args)
File "/Users/ian/.virtualenvs/testcode/lib/python2.6/site-
packages/django/db/models/fields/related.py", line 410, in get_query_set
return
superclass.get_query_set(self).using(db).filter(**(self.core_filters))
File "/Users/ian/Code/Tests/related_test/test_app/models.py", line 17,
in __getattr__
return getattr(self.get_query_set(), attr, *args)
File "/Users/ian/.virtualenvs/testcode/lib/python2.6/site-
packages/django/db/models/fields/related.py", line 410, in get_query_set
return
superclass.get_query_set(self).using(db).filter(**(self.core_filters))
File "/Users/ian/Code/Tests/related_test/test_app/models.py", line 17,
in __getattr__
return getattr(self.get_query_set(), attr, *args)
File "/Users/ian/.virtualenvs/testcode/lib/python2.6/site-
packages/django/db/models/fields/related.py", line 410, in get_query_set
return
superclass.get_query_set(self).using(db).filter(**(self.core_filters))
File "/Users/ian/Code/Tests/related_test/test_app/models.py", line 17,
in __getattr__
return getattr(self.get_query_set(), attr, *args)
File "/Users/ian/.virtualenvs/testcode/lib/python2.6/site-
packages/django/db/models/fields/related.py", line 410, in get_query_set
return
superclass.get_query_set(self).using(db).filter(**(self.core_filters))
File "/Users/ian/Code/Tests/related_test/test_app/models.py", line 17,
in __getattr__
return getattr(self.get_query_set(), attr, *args)
...
File "/Users/ian/.virtualenvs/testcode/lib/python2.6/site-
packages/django/db/models/fields/related.py", line 410, in get_query_set
return
superclass.get_query_set(self).using(db).filter(**(self.core_filters))
File "/Users/ian/Code/Tests/related_test/test_app/models.py", line 17,
in __getattr__
return getattr(self.get_query_set(), attr, *args)
File "/Users/ian/.virtualenvs/testcode/lib/python2.6/site-
packages/django/db/models/fields/related.py", line 410, in get_query_set
return
superclass.get_query_set(self).using(db).filter(**(self.core_filters))
File "/Users/ian/Code/Tests/related_test/test_app/models.py", line 17,
in __getattr__
return getattr(self.get_query_set(), attr, *args)
File "/Users/ian/.virtualenvs/testcode/lib/python2.6/site-
packages/django/db/models/fields/related.py", line 410, in get_query_set
return
superclass.get_query_set(self).using(db).filter(**(self.core_filters))
File "/Users/ian/Code/Tests/related_test/test_app/models.py", line 14,
in get_query_set
return self.model.QuerySet(self.model)
File "/Users/ian/.virtualenvs/testcode/lib/python2.6/site-
packages/django/db/models/query.py", line 33, in __init__
self.query = query or sql.Query(self.model)
File "/Users/ian/.virtualenvs/testcode/lib/python2.6/site-
packages/django/db/models/sql/query.py", line 127, in __init__
self.where = where()
RuntimeError: maximum recursion depth exceeded while calling a Python
object
>>>
}}}
My django checkout is clean:
{{{
(testcode)ian@Ian-Clellands-MacBook-Pro:~/Code/Tests/related_test$ cd
~/Code/Frameworks/django-1.2.X
(testcode)ian@Ian-Clellands-MacBook-Pro:~/Code/Frameworks/django-1.2.X$
svn info
Path: .
URL: http://code.djangoproject.com/svn/django/branches/releases/1.2.X
Repository Root: http://code.djangoproject.com/svn
Repository UUID: bcc190cf-cafb-0310-a4f2-bffc1f526a37
Revision: 14390
Node Kind: directory
Schedule: normal
Last Changed Author: russellm
Last Changed Rev: 14390
Last Changed Date: 2010-10-28 06:00:08 -0700 (Thu, 28 Oct 2010)
(testcode)ian@Ian-Clellands-MacBook-Pro:~/Code/Frameworks/django-1.2.X$
svn diff
(testcode)ian@Ian-Clellands-MacBook-Pro:~/Code/Frameworks/django-1.2.X$
}}}
If I revert to revision r14388, this behaviour doesn't occur. (r14389 is
the same changeset as r14390, applied to trunk rather than 1.2.X)
I have also tested this on django-trunk:
{{{
(testcode)ian@Ian-Clellands-MacBook-Pro:~/Code/Frameworks/django-trunk$
svn info
Path: .
URL: http://code.djangoproject.com/svn/django/trunk
Repository Root: http://code.djangoproject.com/svn
Repository UUID: bcc190cf-cafb-0310-a4f2-bffc1f526a37
Revision: 15195
Node Kind: directory
Schedule: normal
Last Changed Author: russellm
Last Changed Rev: 15194
Last Changed Date: 2011-01-13 08:41:46 -0800 (Thu, 13 Jan 2011)
}}}
With the same results; except that the relevant line in `related.py` is
412, rather than 410.
Please let me know if there is anything else I can provide to help
reproduce this.
--
Ticket URL: <http://code.djangoproject.com/ticket/15062#comment:2>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" 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-updates?hl=en.