Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 239433 Details for
Bug 328117
www-client/pybugz-0.8.0 does not run with python-2.7
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
0001-Fix-XML-parsing-for-Python-2.7.patch
0001-Fix-XML-parsing-for-Python-2.7.patch (text/plain), 2.21 KB, created by
Christopher Brannon (RETIRED)
on 2010-07-19 19:48:42 UTC
(
hide
)
Description:
0001-Fix-XML-parsing-for-Python-2.7.patch
Filename:
MIME Type:
Creator:
Christopher Brannon (RETIRED)
Created:
2010-07-19 19:48:42 UTC
Size:
2.21 KB
patch
obsolete
>From 52b48f73eee2f4b173b5a0f52959d539c5c4440c Mon Sep 17 00:00:00 2001 >From: Christopher Brannon <cmbrannon79@gmail.com> >Date: Mon, 19 Jul 2010 13:43:54 -0500 >Subject: [PATCH] Fix XML parsing for Python 2.7. > >The xml.etree.ElementTree module changed between Python 2.6 and >Python 2.7. The ForcedEncodingXMLTreeBuilder >class that we use in bugzilla.py no longer works with Python 2.7. >New members were added to its superclass, and these new members >weren't being initialized by the custom __init__ method. >After some research, I learned that we no longer need the >ForcedEncodingXMLTreeBuilder class in Python 2.7, because >ElementTree.XMLTreeBuilder does exactly what we want. > >See <http://bugs.gentoo.org/show_bug.cgi?id=328117>. >--- > bugz/bugzilla.py | 18 +++++++++++++++++- > 1 files changed, 17 insertions(+), 1 deletions(-) > >diff --git a/bugz/bugzilla.py b/bugz/bugzilla.py >index 0694983..ecbd271 100644 >--- a/bugz/bugzilla.py >+++ b/bugz/bugzilla.py >@@ -7,6 +7,7 @@ import locale > import mimetypes > import os > import re >+import sys > > from cookielib import LWPCookieJar, CookieJar > from cStringIO import StringIO >@@ -84,6 +85,8 @@ def get_content_type(filename): > # > # Override the behaviour of elementtree and allow us to > # force the encoding to utf-8 >+# Not needed in Python 2.7, since ElementTree.XMLTreeBuilder uses the forced >+# encoding. > # > > class ForcedEncodingXMLTreeBuilder(ElementTree.XMLTreeBuilder): >@@ -442,8 +445,21 @@ class Bugz: > resp = self.opener.open(req) > > fd = StringIO(resp.read()) >+ > # workaround for ill-defined XML templates in bugzilla 2.20.2 >- parser = ForcedEncodingXMLTreeBuilder(encoding = 'utf-8') >+ (major_version, minor_version) = \ >+ (sys.version_info[0], sys.version_info[1]) >+ if major_version > 2 or \ >+ (major_version == 2 and minor_version >= 7): >+ # If this is 2.7 or greater, then XMLTreeBuilder >+ # does what we want. >+ parser_class = ElementTree.XMLParser >+ else: >+ # Running under Python 2.6, so we need to use our >+ # subclass of XMLTreeBuilder instead. >+ parser_class = ForcedEncodingXMLTreeBuilder >+ parser = parser_class(encoding = 'utf-8') >+ > etree = ElementTree.parse(fd, parser) > bug = etree.find('.//bug') > if bug and bug.attrib.has_key('error'): >-- >1.7.1.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 328117
: 239433