Thoughts on this patch? -------- Original Message -------- Subject: Re: venus runtests.py FAIL after git update Date: Sun, 23 May 2010 09:53:35 +0200 From: Mark Wielaard <m...@klomp.org> To: Sam Ruby <ru...@intertwingly.net> CC: de...@lists.planetplanet.org
On Sat, 2010-05-22 at 17:01 -0400, Sam Ruby wrote:
Tracked down the root cause, it is the following change: http://tinyurl.com/2wcfgde [1]. With that change, html5lib depends on a feature introduced in Python 2.5, namely the ability to pass a tuple to the startswith method:
Aha. OK, that seems easy to workaround.
Python 2.5 was released on September 19th 2006 Any possibility you can install and use python 2.5 (at least for your usages of Venus)?
Yeah, yeah, I know, I should leave this web 2.0 stuff to the young and hip and stick to old fashioned web 1.0 with my "stable" (read "ancient") enterprisy distro :) But since html5lib seems to have 2.4 (and earlier) support already for most other newish 2.5 functionality it seems simple to just add another one. With the attached patch everything works fine, zero FAIL on runtests.py, even on a bare centos 5.5 install (which was released just a couple of weeks ago and will most likely be support for some years to come). Cheers, Mark -- You received this message because you are subscribed to the Google Groups "html5lib-discuss" group. To post to this group, send an email to html5lib-disc...@googlegroups.com. To unsubscribe from this group, send email to html5lib-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/html5lib-discuss?hl=en-GB.
>From 49ca2b65ff5f45d4de23240ff42d1925cd9c1daa Mon Sep 17 00:00:00 2001 From: Mark Wielaard <m...@klomp.org> Date: Sun, 23 May 2010 10:45:54 +0200 Subject: [PATCH] Define startswith function that takes a tuple for 2.4 in html5parser. --- planet/vendor/html5lib/html5parser.py | 20 ++++++++++++++++---- 1 files changed, 16 insertions(+), 4 deletions(-) diff --git a/planet/vendor/html5lib/html5parser.py b/planet/vendor/html5lib/html5parser.py index 75dad65..da3b4e9 100644 --- a/planet/vendor/html5lib/html5parser.py +++ b/planet/vendor/html5lib/html5parser.py @@ -15,6 +15,18 @@ except: return True return False +try: + "abc".startswith(("a", "b")) + def startswith(str, prefixes): + return str.startswith(prefixes) +except: + # Python 2.4 doesn't accept a tuple as argument to string startswith + def startswith(str, prefixes): + for prefix in prefixes: + if str.startswith(prefix): + return True + return False + import sys import inputstream @@ -485,7 +497,7 @@ class InitialPhase(Phase): publicId = publicId.translate(asciiUpper2Lower) if (not correct or token["name"] != "html" - or publicId.startswith( + or startswith(publicId, ("+//silmaril//dtd html pro v0r11 19970101//", "-//advasoft ltd//dtd html 3.0 aswedit + extensions//", "-//as//dtd html 3.0 aswedit + extensions//", @@ -545,16 +557,16 @@ class InitialPhase(Phase): ("-//w3o//dtd w3 html strict 3.0//en//", "-/w3c/dtd html 4.0 transitional/en", "html") - or publicId.startswith( + or startswith(publicId, ("-//w3c//dtd html 4.01 frameset//", "-//w3c//dtd html 4.01 transitional//")) and systemId == None or systemId and systemId.lower() == "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd"): self.parser.compatMode = "quirks" - elif (publicId.startswith( + elif (startswith(publicId, ("-//w3c//dtd xhtml 1.0 frameset//", "-//w3c//dtd xhtml 1.0 transitional//")) - or publicId.startswith( + or startswith(publicId, ("-//w3c//dtd html 4.01 frameset//", "-//w3c//dtd html 4.01 transitional//")) and systemId != None): -- 1.5.5.6