[Django] #20185: TypeError: unicode argument expected, got 'str' on core management validation (used gunicorn)

180 views
Skip to first unread message

Django

unread,
Apr 3, 2013, 2:52:12 AM4/3/13
to django-...@googlegroups.com
#20185: TypeError: unicode argument expected, got 'str' on core management
validation (used gunicorn)
----------------------------+----------------------
Reporter: avelino | Owner: nobody
Type: Bug | Status: new
Component: Python 2 | Version: 1.5
Severity: Normal | Keywords: gunicorn
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+----------------------
Used gunicorn 0.17.2

Error:

{{{
2013-04-03 02:37:08 [71497] [INFO] Starting gunicorn 0.17.2
2013-04-03 02:37:08 [71497] [INFO] Listening at: http://127.0.0.1:8000
(71497)
2013-04-03 02:37:08 [71497] [INFO] Using worker: sync
2013-04-03 02:37:08 [71500] [INFO] Booting worker with pid: 71500
2013-04-03 02:37:10 [71500] [ERROR] Exception in worker process:
Traceback (most recent call last):
File "/Users/avelino/.virtualenvs/yacows.virgula/lib/python2.7/site-
packages/gunicorn/arbiter.py", line 485, in spawn_worker
worker.init_process()
File "/Users/avelino/.virtualenvs/yacows.virgula/lib/python2.7/site-
packages/gunicorn/workers/base.py", line 100, in init_process
self.wsgi = self.app.wsgi()
File "/Users/avelino/.virtualenvs/yacows.virgula/lib/python2.7/site-
packages/gunicorn/app/base.py", line 103, in wsgi
self.callable = self.load()
File "/Users/avelino/.virtualenvs/yacows.virgula/lib/python2.7/site-
packages/gunicorn/app/djangoapp.py", line 101, in load
return mod.make_wsgi_application()
File "/Users/avelino/.virtualenvs/yacows.virgula/lib/python2.7/site-
packages/gunicorn/app/django_wsgi.py", line 36, in make_wsgi_application
if get_validation_errors(s):
File "/Users/avelino/.virtualenvs/yacows.virgula/lib/python2.7/site-
packages/django/core/management/validation.py", line 150, in
get_validation_errors
e.add(opts, "'%s' has a relation with model %s, which has either not
been installed or is abstract." % (f.name, f.rel.to))
File "/Users/avelino/.virtualenvs/yacows.virgula/lib/python2.7/site-
packages/django/core/management/validation.py", line 19, in add
self.outfile.write(self.style.ERROR(force_str(u"%s: %s\n" % (context,
error))))
TypeError: unicode argument expected, got 'str'
Traceback (most recent call last):
File "/Users/avelino/.virtualenvs/yacows.virgula/lib/python2.7/site-
packages/gunicorn/arbiter.py", line 485, in spawn_worker
worker.init_process()
File "/Users/avelino/.virtualenvs/yacows.virgula/lib/python2.7/site-
packages/gunicorn/workers/base.py", line 100, in init_process
self.wsgi = self.app.wsgi()
File "/Users/avelino/.virtualenvs/yacows.virgula/lib/python2.7/site-
packages/gunicorn/app/base.py", line 103, in wsgi
self.callable = self.load()
File "/Users/avelino/.virtualenvs/yacows.virgula/lib/python2.7/site-
packages/gunicorn/app/djangoapp.py", line 101, in load
return mod.make_wsgi_application()
File "/Users/avelino/.virtualenvs/yacows.virgula/lib/python2.7/site-
packages/gunicorn/app/django_wsgi.py", line 36, in make_wsgi_application
if get_validation_errors(s):
File "/Users/avelino/.virtualenvs/yacows.virgula/lib/python2.7/site-
packages/django/core/management/validation.py", line 150, in
get_validation_errors
e.add(opts, "'%s' has a relation with model %s, which has either not
been installed or is abstract." % (f.name, f.rel.to))
File "/Users/avelino/.virtualenvs/yacows.virgula/lib/python2.7/site-
packages/django/core/management/validation.py", line 19, in add
self.outfile.write(self.style.ERROR(force_str(u"%s: %s\n" % (context,
error))))
TypeError: unicode argument expected, got 'str'
2013-04-03 02:37:10 [71500] [INFO] Worker exiting (pid: 71500)
2013-04-03 02:37:10 [71497] [INFO] Shutting down: Master
2013-04-03 02:37:10 [71497] [INFO] Reason: Worker failed to boot.
}}}

if it bug, the following correction:
https://github.com/django/django/pull/983

--
Ticket URL: <https://code.djangoproject.com/ticket/20185>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 3, 2013, 2:56:11 AM4/3/13
to django-...@googlegroups.com
#20185: TypeError: unicode argument expected, got 'str' on core management
validation (used gunicorn)
--------------------------+--------------------------------------

Reporter: avelino | Owner: nobody
Type: Bug | Status: new
Component: Python 2 | Version: 1.5
Severity: Normal | Resolution:

Keywords: gunicorn | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------+--------------------------------------
Changes (by avelino):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Reproduce the problem

Install:
gunicorn==0.17.2
django==1.5.1

Run:
$ gunicorn_django

--
Ticket URL: <https://code.djangoproject.com/ticket/20185#comment:1>

Django

unread,
Apr 3, 2013, 4:37:23 AM4/3/13
to django-...@googlegroups.com
#20185: TypeError: unicode argument expected, got 'str' on core management
validation (used gunicorn)
--------------------------+--------------------------------------
Reporter: avelino | Owner: nobody
Type: Bug | Status: closed

Component: Python 2 | Version: 1.5
Severity: Normal | Resolution: invalid

Keywords: gunicorn | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------+--------------------------------------
Changes (by bmispelon):

* status: new => closed
* resolution: => invalid


Comment:

This is a bug inside gunicorn, most likely caused by the use of
`io.StringIO` instead of `StringIO.StringIO` which breaks under python 2.

This line in particular:
https://github.com/benoitc/gunicorn/blob/0.17.2/gunicorn/app/django_wsgi.py#L13

--
Ticket URL: <https://code.djangoproject.com/ticket/20185#comment:2>

Django

unread,
Jul 3, 2013, 3:33:43 PM7/3/13
to django-...@googlegroups.com
#20185: TypeError: unicode argument expected, got 'str' on core management
validation (used gunicorn)
--------------------------+--------------------------------------
Reporter: avelino | Owner: nobody
Type: Bug | Status: closed

Component: Python 2 | Version: 1.5
Severity: Normal | Resolution: invalid

Keywords: gunicorn | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------+--------------------------------------

Comment (by aj@…):

Does anyone know the cause of this bug? Whether or not it is Gunicorn's
fault or a configuration error?

--
Ticket URL: <https://code.djangoproject.com/ticket/20185#comment:3>

Django

unread,
Sep 16, 2013, 6:39:31 PM9/16/13
to django-...@googlegroups.com
#20185: TypeError: unicode argument expected, got 'str' on core management
validation (used gunicorn)
--------------------------+--------------------------------------
Reporter: avelino | Owner: nobody
Type: Bug | Status: closed

Component: Python 2 | Version: 1.5
Severity: Normal | Resolution: invalid

Keywords: gunicorn | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------+--------------------------------------

Comment (by abraham.estrada@…):

I'm getting this error when adding "AUTH_USER_MODEL" to the settings.

--
Ticket URL: <https://code.djangoproject.com/ticket/20185#comment:4>

Django

unread,
Apr 22, 2014, 7:01:17 PM4/22/14
to django-...@googlegroups.com
#20185: TypeError: unicode argument expected, got 'str' on core management
validation (used gunicorn)
--------------------------+--------------------------------------
Reporter: avelino | Owner: nobody
Type: Bug | Status: closed

Component: Python 2 | Version: 1.5
Severity: Normal | Resolution: invalid

Keywords: gunicorn | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------+--------------------------------------

Comment (by hobs at totalgood.com):

Thank you very much for pointing me to the django_wsgi line that was the
problem.

For me run_gunicorn (gunicorn/app/django_wsgi.py) was trying to output
error messages for one of my installed apps using the wrong StringIO. I
reversed the try/except order for import of StringIO (to favor python2)
and then also fixed the model inheritance in the broken app. You can do
either to avoid this error (don't have validation errors or use the right
StringIO to log/output the validation errors).

This is the sort of error message that gunicorn is using StringIO to try
to log. I was trying to ForeignKey to the abstract model
contrib.auth.User:

One or more models did not validate:
agile.organization: 'user' has an m2m relation with model User, which


has either not been installed or is abstract.

--
Ticket URL: <https://code.djangoproject.com/ticket/20185#comment:5>

Reply all
Reply to author
Forward
0 new messages