Opened 5 years ago

Closed 23 months ago

#6178 enhancement closed fixed (fixed)

Port twisted.web.util to Python 3

Reported by: Itamar Turner-Trauring Owned by:
Priority: lowest Milestone: Python-3.x
Component: web Keywords:
Cc: Branch: branches/twutil-py3-6178
branch-diff, diff-cov, branch-cov, buildbot
Author: hawkowl

Description

twisted.web.util should run on Python 3.

Change History (6)

comment:1 Changed 4 years ago by nott_

Owner: set to nott_

comment:2 Changed 4 years ago by nott_

Owner: nott_ deleted

comment:3 Changed 4 years ago by Ihar Hrachyshka

This will probably require changing filepath.py to expose unicode strings instead of bytes. F.e. if I try to import the module in Python3.3, I get the following:

import twisted.web.util

Traceback (most recent call last):

File "<stdin>", line 1, in <module> File "./twisted/web/util.py", line 362, in <module>

class FailureElement(Element):

File "./twisted/web/util.py", line 372, in FailureElement

loader = XMLFile(getModule(name).filePath.sibling("failure.xhtml"))

File "./twisted/python/filepath.py", line 408, in sibling

return self.parent().child(path)

File "./twisted/python/filepath.py", line 679, in child

if self.sep in norm:

TypeError: 'in <string>' requires string as left operand, not bytes

If I try to pass bytes string to sibling(), I get another error:

import twisted.web.util

Traceback (most recent call last):

File "<stdin>", line 1, in <module> File "./twisted/web/util.py", line 362, in <module>

class FailureElement(Element):

File "./twisted/web/util.py", line 372, in FailureElement

loader = XMLFile(getModule(name).filePath.sibling(b"failure.xhtml"))

File "./twisted/python/filepath.py", line 408, in sibling

return self.parent().child(path)

File "./twisted/python/filepath.py", line 681, in child

newpath = abspath(joinpath(self.path, norm))

File "/usr/local/Cellar/python3/3.3.2/Frameworks/Python.framework/Versions/3.3/lib/python3.3/posixpath.py", line 92, in join

"components.") from None

TypeError: Can't mix strings and bytes in path components.

It looks like filepath object is instantiated via unicode module path, while we try to use paths as if they are bytes. Looks like the ticket to handle first is: #5203

comment:4 Changed 3 years ago by hawkowl

Author: hawkowl
Branch: branches/twutil-py3-6178

(In [44196]) Branching to twutil-py3-6178.

comment:5 Changed 2 years ago by hawkowl

Component: coreweb

comment:6 Changed 23 months ago by hawkowl

Resolution: fixed
Status: newclosed

This has all been ported now.

Note: See TracTickets for help on using tickets.