1

I'm trying to use the --paste option of uwsgi, to serve a pyramid application, but PasteDeploy is throwing a TypeError (coming from Python3 I guess)

File "/home/admin/.mozaiqu.es.env/lib/python3.2/site-packages/paste/deploy/loadwsgi.py", line 277, in loadcontext
    if '#' in uri:
TypeError: Type str doesn't support the buffer API

The command i'm using:

uwsgi --paste development.ini --socket :3031 -H /home/admin/.mozaiqu.es.env

I thought that PasteDeploy and uwsgi were Python3 friendly, they aren't ?

Am I doing something wrong ?

b4stien
  • 1,810
  • 13
  • 14

2 Answers2

2

I just encountered the same problem in python 3.2. I have temporarily resolved the issue by adding the following to the loadcontext of loadwsgi.py:

if isinstance(uri, bytes):
    uri = uri.decode('utf-8')

Here is the addition with a little context:

def loadcontext(object_type, uri, name=None, relative_to=None,
                global_conf=None):
    if isinstance(uri, bytes):
        uri = uri.decode('utf-8')
    if '#' in uri:
        if name is None:
            uri, name = uri.split('#', 1)
        else:
            # @@: Ignore fragment or error?                                             
            uri = uri.split('#', 1)[0]
bboe
  • 4,092
  • 3
  • 29
  • 39
  • This one do the trick, PasteDeploy is not Python3 friendly, at all ... and seems to be no longer maintained. – b4stien Aug 20 '12 at 16:56
  • @b4stien I use it with Python 3 without issues. What problems do you see? – tshepang Mar 05 '13 at 09:04
  • This issue is more than 6/7 months old, maybe new version of python3 solved the problem. I ended using python2.7 for this very specific project. – b4stien Mar 05 '13 at 09:58
1

See Python 3.0 urllib.parse error "Type str doesn't support the buffer API"

It explains the error you are having, just in a different context. The error is basically a bug in python 3.x. There is a problem in the mesh between byte strings and unicode strings, so several errors arise for this. The first answer in the post above explains it with more clarity.

Community
  • 1
  • 1
Wiz
  • 4,595
  • 9
  • 34
  • 51