Fixed warnings in python3

This commit is contained in:
Daniel Neuhäuser 2010-06-20 22:39:38 +02:00
parent 20a21ed35a
commit 98b6073a7e
4 changed files with 15 additions and 2 deletions

View File

@ -80,7 +80,7 @@ class WarningStream(object):
self.warnfunc = warnfunc
def write(self, text):
if text.strip():
self.warnfunc(text, None, '')
self.warnfunc(text.strip(), None, '')
class NoUri(Exception):

View File

@ -12,6 +12,7 @@
import os
import re
import htmlentitydefs
import sys
from StringIO import StringIO
try:
@ -60,6 +61,10 @@ def tail_check(check):
return checker
if sys.version_info >= (3, 0):
ENV_WARNINGS = remove_unicode_literals(ENV_WARNINGS)
HTML_WARNINGS = remove_unicode_literals(HTML_WARNINGS)
HTML_XPATH = {
'images.html': [
(".//img[@src='_images/img.png']", ''),

View File

@ -32,6 +32,9 @@ None:None: WARNING: no matching candidate for image URI u'foo.\\*'
WARNING: invalid pair index entry u''
"""
if sys.version_info >= (3, 0):
LATEX_WARNINGS = remove_unicode_literals(LATEX_WARNINGS)
@with_app(buildername='latex', warning=latex_warnfile, cleanenv=True)
def test_latex(app):

View File

@ -11,6 +11,7 @@ import sys
import StringIO
import tempfile
import shutil
import re
from codecs import open
try:
@ -32,7 +33,7 @@ __all__ = [
'raises', 'raises_msg', 'Struct',
'ListOutput', 'TestApp', 'with_app', 'gen_with_app',
'path', 'with_tempdir', 'write_file',
'sprint',
'sprint', 'remove_unicode_literals',
]
@ -206,3 +207,7 @@ def write_file(name, contents, encoding=None):
def sprint(*args):
sys.stderr.write(' '.join(map(str, args)) + '\n')
_unicode_literals_re = re.compile(r'u(".*")|u(\'.*\')')
def remove_unicode_literals(s):
return _unicode_literals_re.sub(lambda x: x.group(1) or x.group(2), s)