Opened 2 years ago

Last modified 18 months ago

#6177 enhancement new

Port twisted.web.static to Python 3

Reported by: itamar Owned by:
Priority: lowest Milestone: Python-3.x
Component: core Keywords:
Cc: Branch:
Author: Launchpad Bug:

Description

twisted.web.static should be ported to Python 3.

Attachments (1)

web.static-py3k-wip.patch (22.1 KB) - added by ihrachyshka 18 months ago.
First draft, not completed

Download all attachments as: .zip

Change History (4)

comment:1 Changed 18 months ago by ihrachyshka

  • Owner set to ihrachyshka
  • Status changed from new to assigned

Changed 18 months ago by ihrachyshka

First draft, not completed

comment:2 Changed 18 months ago by ihrachyshka

  • Owner ihrachyshka deleted
  • Status changed from assigned to new

I've mostly ported web.static and corresponding unit test to python3.x though it turned out the code depends on python.filepath (thru web.util), while filepath module does not seem to work ok in python3.x (even though corresponding porting ticket was closed as fixed).

For reference:
web.util py3k ticket: #6178
unicode in filepath: #5203

comment:3 Changed 18 months ago by ihrachyshka

So after applying the patch, run-python3-tests fails while initially importing modules, as follows:

Traceback (most recent call last):

File "./admin/run-python3-tests", line 30, in <module>

unittest.main(module=None, argv=["run-python3-tests", "-v"] + testModules)

File "/usr/local/Cellar/python3/3.3.2/Frameworks/Python.framework/Versions/3.3/lib/python3.3/unittest/main.py", line 124, in init

self.parseArgs(argv)

File "/usr/local/Cellar/python3/3.3.2/Frameworks/Python.framework/Versions/3.3/lib/python3.3/unittest/main.py", line 168, in parseArgs

self.createTests()

File "/usr/local/Cellar/python3/3.3.2/Frameworks/Python.framework/Versions/3.3/lib/python3.3/unittest/main.py", line 175, in createTests

self.module)

File "/usr/local/Cellar/python3/3.3.2/Frameworks/Python.framework/Versions/3.3/lib/python3.3/unittest/loader.py", line 137, in loadTestsFromNames

suites = [self.loadTestsFromName(name, module) for name in names]

File "/usr/local/Cellar/python3/3.3.2/Frameworks/Python.framework/Versions/3.3/lib/python3.3/unittest/loader.py", line 137, in <listcomp>

suites = [self.loadTestsFromName(name, module) for name in names]

File "/usr/local/Cellar/python3/3.3.2/Frameworks/Python.framework/Versions/3.3/lib/python3.3/unittest/loader.py", line 96, in loadTestsFromName

module = import('.'.join(parts_copy))

File "/Users/ihrachyshka/proj/tw/twisted/twisted/web/test/test_static.py", line 19, in <module>

from twisted.web import static, http, script, resource

File "/Users/ihrachyshka/proj/tw/twisted/twisted/web/static.py", line 22, in <module>

from twisted.web.util import redirectTo

File "/Users/ihrachyshka/proj/tw/twisted/twisted/web/util.py", line 362, in <module>

class FailureElement(Element):

File "/Users/ihrachyshka/proj/tw/twisted/twisted/web/util.py", line 372, in FailureElement

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

File "/Users/ihrachyshka/proj/tw/twisted/twisted/python/filepath.py", line 408, in sibling

return self.parent().child(path)

File "/Users/ihrachyshka/proj/tw/twisted/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.

Note: See TracTickets for help on using tickets.