Opened 12 months ago

Last modified 12 months ago

#9545 defect new

t.w.util.ParentRedirect is broken on py3

Reported by: Wim Lewis Owned by:
Priority: normal Milestone: Python-3.x
Component: web Keywords: py3k
Cc: Branch:
Author:

Description

I'm seeing this traceback (python 3.6, twisted 18.7.0). This is in the rendering of a ParentRedirect.

render is passing a URLPath instance as the first arg to redirectTo, presumably on the assumption that it'll be stringified (or bytes-ified), but it just gets handed to nativeString, which doesn't know what to do with it.

redirectTo is documented to want a bytes anyway (and explicitly rejects unicode strings), so probably render should do the bytes-ifying before passing it down to redirectTo.

  File ".../site-packages/twisted/web/server.py", line 258, in render
    body = resrc.render(self)
  File ".../site-packages/twisted/web/_auth/wrapper.py", line 200, in render
    return super(ResourceWrapper, self).render(request)
  File ".../site-packages/twisted/web/util.py", line 117, in render
    return redirectTo(urlpath.URLPath.fromRequest(request).here(), request)
  File ".../site-packages/twisted/web/util.py", line 73, in redirectTo
    """ % {'url': nativeString(URL)}
  File ".../site-packages/twisted/python/compat.py", line 412, in nativeString
    raise TypeError("%r is neither bytes nor unicode" % s)
builtins.TypeError: URLPath(scheme=b'http', netloc=b'localhost:8001', path=b'/admin/', query=b'', fragment=b'') is neither bytes nor unicode

Change History (1)

comment:1 Changed 12 months ago by Wim Lewis

Milestone: Python-3.x
Note: See TracTickets for help on using tickets.