update to 0.7.6
This commit is contained in:
parent
4550f77475
commit
2c0aae3b7c
@ -1,363 +0,0 @@
|
||||
From 2d1a1a58df56874a806dfbfb34e39878f805b7c5 Mon Sep 17 00:00:00 2001
|
||||
From: Captain <captain.a.wei@gmail.com>
|
||||
Date: Sun, 28 Jun 2020 17:22:35 +0800
|
||||
Subject: [PATCH] python-genshi: fix some syntax error
|
||||
|
||||
Follow these steps:
|
||||
osc build <options> python-genshi.spec
|
||||
or
|
||||
rpmbuild -ba python-genshi.spec
|
||||
|
||||
This is because of some incompatible syntax in python2 and python3.
|
||||
|
||||
Use new syntax to write code.
|
||||
|
||||
Signed-off-by: Captain <captain.a.wei@gmail.com>
|
||||
---
|
||||
genshi/filters/tests/test_html.py | 24 +++++++++++-------------
|
||||
genshi/input.py | 4 ++--
|
||||
genshi/template/base.py | 2 +-
|
||||
genshi/template/directives.py | 4 ++--
|
||||
genshi/template/eval.py | 18 +++++++++---------
|
||||
genshi/template/interpolation.py | 2 +-
|
||||
genshi/template/markup.py | 2 +-
|
||||
genshi/template/tests/directives.py | 8 ++++----
|
||||
genshi/template/tests/eval.py | 10 +++-------
|
||||
genshi/template/tests/interpolation.py | 2 +-
|
||||
genshi/template/tests/markup.py | 10 +++++-----
|
||||
genshi/template/text.py | 2 +-
|
||||
12 files changed, 41 insertions(+), 47 deletions(-)
|
||||
|
||||
diff --git a/genshi/filters/tests/test_html.py b/genshi/filters/tests/test_html.py
|
||||
index 45ec0da..4853f88 100644
|
||||
--- a/genshi/filters/tests/test_html.py
|
||||
+++ b/genshi/filters/tests/test_html.py
|
||||
@@ -521,11 +521,11 @@ class HTMLSanitizerTestCase(unittest.TestCase):
|
||||
self.assertEquals('<img/>', (html | HTMLSanitizer()).render())
|
||||
|
||||
def test_sanitize_expression(self):
|
||||
- html = HTML(ur'<div style="top:expression(alert())">XSS</div>')
|
||||
+ html = HTML(u'<div style="top:expression(alert())">XSS</div>')
|
||||
self.assertEqual('<div>XSS</div>', unicode(html | StyleSanitizer()))
|
||||
|
||||
def test_capital_expression(self):
|
||||
- html = HTML(ur'<div style="top:EXPRESSION(alert())">XSS</div>')
|
||||
+ html = HTML(u'<div style="top:EXPRESSION(alert())">XSS</div>')
|
||||
self.assertEqual('<div>XSS</div>', unicode(html | StyleSanitizer()))
|
||||
|
||||
def test_sanitize_url_with_javascript(self):
|
||||
@@ -538,18 +538,16 @@ class HTMLSanitizerTestCase(unittest.TestCase):
|
||||
u'XSS</div>')
|
||||
self.assertEqual('<div>XSS</div>', unicode(html | StyleSanitizer()))
|
||||
|
||||
- def test_sanitize_unicode_escapes(self):
|
||||
- html = HTML(ur'<div style="top:exp\72 ess\000069 on(alert())">'
|
||||
- ur'XSS</div>')
|
||||
- self.assertEqual('<div>XSS</div>', unicode(html | StyleSanitizer()))
|
||||
+ #def test_sanitize_unicode_escapes(self):
|
||||
+ # html = HTML(u'<div style="top:exp\72 ess\000069 on(alert())">'
|
||||
+ # u'XSS</div>')
|
||||
+ # self.assertEqual('<div>XSS</div>', unicode(html | StyleSanitizer()))
|
||||
|
||||
- def test_sanitize_backslash_without_hex(self):
|
||||
- html = HTML(ur'<div style="top:e\xp\ression(alert())">XSS</div>')
|
||||
- self.assertEqual('<div>XSS</div>', unicode(html | StyleSanitizer()))
|
||||
- html = HTML(ur'<div style="top:e\\xp\\ression(alert())">XSS</div>')
|
||||
- self.assertEqual(r'<div style="top:e\\xp\\ression(alert())">'
|
||||
- 'XSS</div>',
|
||||
- unicode(html | StyleSanitizer()))
|
||||
+ #def test_sanitize_backslash_without_hex(self):
|
||||
+ # html = HTML(r'<div style="top:e\\xp\\ression(alert())">XSS</div>')
|
||||
+ # self.assertEqual(r'<div style="top:e\\xp\\ression(alert())">'
|
||||
+ # 'XSS</div>',
|
||||
+ # unicode(html | StyleSanitizer()))
|
||||
|
||||
def test_sanitize_unsafe_props(self):
|
||||
html = HTML(u'<div style="POSITION:RELATIVE">XSS</div>')
|
||||
diff --git a/genshi/input.py b/genshi/input.py
|
||||
index f2bfd7a..58f209e 100644
|
||||
--- a/genshi/input.py
|
||||
+++ b/genshi/input.py
|
||||
@@ -164,7 +164,7 @@ class XMLParser(object):
|
||||
self._queue = []
|
||||
if done:
|
||||
break
|
||||
- except expat.ExpatError, e:
|
||||
+ except expat.ExpatError as e:
|
||||
msg = str(e)
|
||||
raise ParseError(msg, self.filename, e.lineno, e.offset)
|
||||
return Stream(_generate()).filter(_coalesce)
|
||||
@@ -345,7 +345,7 @@ class HTMLParser(html.HTMLParser, object):
|
||||
for tag in open_tags:
|
||||
yield END, QName(tag), pos
|
||||
break
|
||||
- except html.HTMLParseError, e:
|
||||
+ except html.HTMLParseError as e:
|
||||
msg = '%s: line %d, column %d' % (e.msg, e.lineno, e.offset)
|
||||
raise ParseError(msg, self.filename, e.lineno, e.offset)
|
||||
return Stream(_generate()).filter(_coalesce)
|
||||
diff --git a/genshi/template/base.py b/genshi/template/base.py
|
||||
index 0ee3ed3..dd8d030 100644
|
||||
--- a/genshi/template/base.py
|
||||
+++ b/genshi/template/base.py
|
||||
@@ -417,7 +417,7 @@ class Template(DirectiveFactory):
|
||||
source = BytesIO(source)
|
||||
try:
|
||||
self._stream = self._parse(source, encoding)
|
||||
- except ParseError, e:
|
||||
+ except ParseError as e:
|
||||
raise TemplateSyntaxError(e.msg, self.filepath, e.lineno, e.offset)
|
||||
|
||||
def __getstate__(self):
|
||||
diff --git a/genshi/template/directives.py b/genshi/template/directives.py
|
||||
index 1f70ef6..d5b257c 100644
|
||||
--- a/genshi/template/directives.py
|
||||
+++ b/genshi/template/directives.py
|
||||
@@ -108,7 +108,7 @@ class Directive(object):
|
||||
try:
|
||||
return expr and Expression(expr, template.filepath, lineno,
|
||||
lookup=template.lookup) or None
|
||||
- except SyntaxError, err:
|
||||
+ except SyntaxError as err:
|
||||
err.msg += ' in expression "%s" of "%s" directive' % (expr,
|
||||
cls.tagname)
|
||||
raise TemplateSyntaxError(err, template.filepath, lineno,
|
||||
@@ -706,7 +706,7 @@ class WithDirective(Directive):
|
||||
self.vars.append(([_assignment(n) for n in node.targets],
|
||||
Expression(node.value, template.filepath,
|
||||
lineno, lookup=template.lookup)))
|
||||
- except SyntaxError, err:
|
||||
+ except SyntaxError as err:
|
||||
err.msg += ' in expression "%s" of "%s" directive' % (value,
|
||||
self.tagname)
|
||||
raise TemplateSyntaxError(err, template.filepath, lineno,
|
||||
diff --git a/genshi/template/eval.py b/genshi/template/eval.py
|
||||
index fbd20d0..a5269f9 100644
|
||||
--- a/genshi/template/eval.py
|
||||
+++ b/genshi/template/eval.py
|
||||
@@ -34,13 +34,13 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
# Check for a Python 2.4 bug in the eval loop
|
||||
has_star_import_bug = False
|
||||
-try:
|
||||
- class _FakeMapping(object):
|
||||
- __getitem__ = __setitem__ = lambda *a: None
|
||||
- exec 'from sys import *' in {}, _FakeMapping()
|
||||
-except SystemError:
|
||||
- has_star_import_bug = True
|
||||
-del _FakeMapping
|
||||
+#try:
|
||||
+# class _FakeMapping(object):
|
||||
+# __getitem__ = __setitem__ = lambda *a: None
|
||||
+# exec 'from sys import *' in {}, _FakeMapping()
|
||||
+#except SystemError:
|
||||
+# has_star_import_bug = True
|
||||
+#del _FakeMapping
|
||||
|
||||
|
||||
def _star_import_patch(mapping, modname):
|
||||
@@ -196,7 +196,7 @@ class Suite(Code):
|
||||
"""
|
||||
__traceback_hide__ = 'before_and_this'
|
||||
_globals = self._globals(data)
|
||||
- exec self.code in _globals, data
|
||||
+ exec(self.code, _globals, data)
|
||||
|
||||
|
||||
UNDEFINED = object()
|
||||
@@ -333,7 +333,7 @@ class LookupBase(object):
|
||||
key = key[0]
|
||||
try:
|
||||
return obj[key]
|
||||
- except (AttributeError, KeyError, IndexError, TypeError), e:
|
||||
+ except (AttributeError, KeyError, IndexError, TypeError) as e:
|
||||
if isinstance(key, basestring):
|
||||
val = getattr(obj, key, UNDEFINED)
|
||||
if val is UNDEFINED:
|
||||
diff --git a/genshi/template/interpolation.py b/genshi/template/interpolation.py
|
||||
index 57ebac5..401d79e 100644
|
||||
--- a/genshi/template/interpolation.py
|
||||
+++ b/genshi/template/interpolation.py
|
||||
@@ -77,7 +77,7 @@ def interpolate(text, filepath=None, lineno=-1, offset=0, lookup='strict'):
|
||||
expr = Expression(chunk.strip(), pos[0], pos[1],
|
||||
lookup=lookup)
|
||||
yield EXPR, expr, tuple(pos)
|
||||
- except SyntaxError, err:
|
||||
+ except SyntaxError as err:
|
||||
raise TemplateSyntaxError(err, filepath, pos[1],
|
||||
pos[2] + (err.offset or 0))
|
||||
else:
|
||||
diff --git a/genshi/template/markup.py b/genshi/template/markup.py
|
||||
index e672924..3c34320 100644
|
||||
--- a/genshi/template/markup.py
|
||||
+++ b/genshi/template/markup.py
|
||||
@@ -93,7 +93,7 @@ class MarkupTemplate(Template):
|
||||
try:
|
||||
suite = Suite(data[1], self.filepath, pos[1],
|
||||
lookup=self.lookup)
|
||||
- except SyntaxError, err:
|
||||
+ except SyntaxError as err:
|
||||
raise TemplateSyntaxError(err, self.filepath,
|
||||
pos[1] + (err.lineno or 1) - 1,
|
||||
pos[2] + (err.offset or 0))
|
||||
diff --git a/genshi/template/tests/directives.py b/genshi/template/tests/directives.py
|
||||
index 2704ddc..84679f6 100644
|
||||
--- a/genshi/template/tests/directives.py
|
||||
+++ b/genshi/template/tests/directives.py
|
||||
@@ -487,7 +487,7 @@ class ForDirectiveTestCase(unittest.TestCase):
|
||||
try:
|
||||
list(tmpl.generate(foo=12))
|
||||
self.fail('Expected TemplateRuntimeError')
|
||||
- except TypeError, e:
|
||||
+ except TypeError as e:
|
||||
assert (str(e) == "iteration over non-sequence" or
|
||||
str(e) == "'int' object is not iterable")
|
||||
exc_type, exc_value, exc_traceback = sys.exc_info()
|
||||
@@ -513,7 +513,7 @@ class ForDirectiveTestCase(unittest.TestCase):
|
||||
</py:for>
|
||||
</doc>""", filename='test.html').generate()
|
||||
self.fail('ExpectedTemplateSyntaxError')
|
||||
- except TemplateSyntaxError, e:
|
||||
+ except TemplateSyntaxError as e:
|
||||
self.assertEqual('test.html', e.filename)
|
||||
if sys.version_info[:2] > (2,4):
|
||||
self.assertEqual(2, e.lineno)
|
||||
@@ -1050,7 +1050,7 @@ class ContentDirectiveTestCase(unittest.TestCase):
|
||||
<py:content foo="">Foo</py:content>
|
||||
</doc>""", filename='test.html').generate()
|
||||
self.fail('Expected TemplateSyntaxError')
|
||||
- except TemplateSyntaxError, e:
|
||||
+ except TemplateSyntaxError as e:
|
||||
self.assertEqual('test.html', e.filename)
|
||||
self.assertEqual(2, e.lineno)
|
||||
|
||||
@@ -1068,7 +1068,7 @@ class ReplaceDirectiveTestCase(unittest.TestCase):
|
||||
<elem py:replace="">Foo</elem>
|
||||
</doc>""", filename='test.html').generate()
|
||||
self.fail('Expected TemplateSyntaxError')
|
||||
- except TemplateSyntaxError, e:
|
||||
+ except TemplateSyntaxError as e:
|
||||
self.assertEqual('test.html', e.filename)
|
||||
self.assertEqual(2, e.lineno)
|
||||
|
||||
diff --git a/genshi/template/tests/eval.py b/genshi/template/tests/eval.py
|
||||
index c44a0e3..9b79628 100644
|
||||
--- a/genshi/template/tests/eval.py
|
||||
+++ b/genshi/template/tests/eval.py
|
||||
@@ -81,11 +81,7 @@ class ExpressionTestCase(unittest.TestCase):
|
||||
|
||||
def test_num_literal(self):
|
||||
self.assertEqual(42, Expression("42").evaluate({}))
|
||||
- if IS_PYTHON2:
|
||||
- self.assertEqual(42L, Expression("42L").evaluate({}))
|
||||
self.assertEqual(.42, Expression(".42").evaluate({}))
|
||||
- if IS_PYTHON2:
|
||||
- self.assertEqual(07, Expression("07").evaluate({}))
|
||||
self.assertEqual(0xF2, Expression("0xF2").evaluate({}))
|
||||
self.assertEqual(0XF2, Expression("0XF2").evaluate({}))
|
||||
|
||||
@@ -416,7 +412,7 @@ class ExpressionTestCase(unittest.TestCase):
|
||||
try:
|
||||
expr.evaluate({})
|
||||
self.fail('Expected UndefinedError')
|
||||
- except UndefinedError, e:
|
||||
+ except UndefinedError as e:
|
||||
exc_type, exc_value, exc_traceback = sys.exc_info()
|
||||
frame = exc_traceback.tb_next
|
||||
frames = []
|
||||
@@ -439,7 +435,7 @@ class ExpressionTestCase(unittest.TestCase):
|
||||
try:
|
||||
expr.evaluate({'something': Something()})
|
||||
self.fail('Expected UndefinedError')
|
||||
- except UndefinedError, e:
|
||||
+ except UndefinedError as e:
|
||||
self.assertEqual('<Something> has no member named "nil"', str(e))
|
||||
exc_type, exc_value, exc_traceback = sys.exc_info()
|
||||
search_string = "<Expression 'something.nil'>"
|
||||
@@ -463,7 +459,7 @@ class ExpressionTestCase(unittest.TestCase):
|
||||
try:
|
||||
expr.evaluate({'something': Something()})
|
||||
self.fail('Expected UndefinedError')
|
||||
- except UndefinedError, e:
|
||||
+ except UndefinedError as e:
|
||||
self.assertEqual('<Something> has no member named "nil"', str(e))
|
||||
exc_type, exc_value, exc_traceback = sys.exc_info()
|
||||
search_string = '''<Expression 'something["nil"]'>'''
|
||||
diff --git a/genshi/template/tests/interpolation.py b/genshi/template/tests/interpolation.py
|
||||
index 52b369b..65be21d 100644
|
||||
--- a/genshi/template/tests/interpolation.py
|
||||
+++ b/genshi/template/tests/interpolation.py
|
||||
@@ -131,7 +131,7 @@ class InterpolateTestCase(unittest.TestCase):
|
||||
def test_interpolate_full_mismatched_brackets(self):
|
||||
try:
|
||||
list(interpolate('${{1:2}'))
|
||||
- except TemplateSyntaxError, e:
|
||||
+ except TemplateSyntaxError as e:
|
||||
pass
|
||||
else:
|
||||
self.fail('Expected TemplateSyntaxError')
|
||||
diff --git a/genshi/template/tests/markup.py b/genshi/template/tests/markup.py
|
||||
index b6084f4..e8ab921 100644
|
||||
--- a/genshi/template/tests/markup.py
|
||||
+++ b/genshi/template/tests/markup.py
|
||||
@@ -83,7 +83,7 @@ class MarkupTemplateTestCase(unittest.TestCase):
|
||||
xml = '<p xmlns:py="http://genshi.edgewall.org/" py:do="nothing" />'
|
||||
try:
|
||||
tmpl = MarkupTemplate(xml, filename='test.html')
|
||||
- except BadDirectiveError, e:
|
||||
+ except BadDirectiveError as e:
|
||||
self.assertEqual('test.html', e.filename)
|
||||
self.assertEqual(1, e.lineno)
|
||||
|
||||
@@ -92,7 +92,7 @@ class MarkupTemplateTestCase(unittest.TestCase):
|
||||
try:
|
||||
tmpl = MarkupTemplate(xml, filename='test.html').generate()
|
||||
self.fail('Expected TemplateSyntaxError')
|
||||
- except TemplateSyntaxError, e:
|
||||
+ except TemplateSyntaxError as e:
|
||||
self.assertEqual('test.html', e.filename)
|
||||
self.assertEqual(1, e.lineno)
|
||||
|
||||
@@ -103,7 +103,7 @@ class MarkupTemplateTestCase(unittest.TestCase):
|
||||
try:
|
||||
tmpl = MarkupTemplate(xml, filename='test.html')
|
||||
self.fail('Expected TemplateSyntaxError')
|
||||
- except TemplateSyntaxError, e:
|
||||
+ except TemplateSyntaxError as e:
|
||||
self.assertEqual('test.html', e.filename)
|
||||
self.assertEqual(2, e.lineno)
|
||||
|
||||
@@ -116,7 +116,7 @@ class MarkupTemplateTestCase(unittest.TestCase):
|
||||
try:
|
||||
tmpl = MarkupTemplate(xml, filename='test.html')
|
||||
self.fail('Expected TemplateSyntaxError')
|
||||
- except TemplateSyntaxError, e:
|
||||
+ except TemplateSyntaxError as e:
|
||||
self.assertEqual('test.html', e.filename)
|
||||
self.assertEqual(3, e.lineno)
|
||||
|
||||
@@ -619,7 +619,7 @@ class MarkupTemplateTestCase(unittest.TestCase):
|
||||
tmpl = MarkupTemplate(xml, filename='test.html',
|
||||
allow_exec=False)
|
||||
self.fail('Expected SyntaxError')
|
||||
- except TemplateSyntaxError, e:
|
||||
+ except TemplateSyntaxError as e:
|
||||
pass
|
||||
|
||||
def test_allow_exec_true(self):
|
||||
diff --git a/genshi/template/text.py b/genshi/template/text.py
|
||||
index 1eddb74..243c1cd 100644
|
||||
--- a/genshi/template/text.py
|
||||
+++ b/genshi/template/text.py
|
||||
@@ -201,7 +201,7 @@ class NewTextTemplate(Template):
|
||||
try:
|
||||
suite = Suite(value, self.filepath, lineno,
|
||||
lookup=self.lookup)
|
||||
- except SyntaxError, err:
|
||||
+ except SyntaxError as err:
|
||||
raise TemplateSyntaxError(err, self.filepath,
|
||||
lineno + (err.lineno or 1) - 1)
|
||||
pos = (self.filename, lineno, 0)
|
||||
--
|
||||
2.23.0
|
||||
|
||||
Binary file not shown.
BIN
Genshi-0.7.6.tar.gz
Normal file
BIN
Genshi-0.7.6.tar.gz
Normal file
Binary file not shown.
@ -1,17 +1,18 @@
|
||||
%global _python_bytecompile_extra 1
|
||||
|
||||
Name: python-genshi
|
||||
Version: 0.7.3
|
||||
Release: 7
|
||||
Version: 0.7.6
|
||||
Release: 1
|
||||
Summary: Toolkit for stream-based generation of output for the web
|
||||
License: BSD
|
||||
URL: http://genshi.edgewall.org/
|
||||
Source0: https://files.pythonhosted.org/packages/source/G/Genshi/Genshi-%{version}.tar.gz
|
||||
Patch0: 0001-python-genshi-fix-some-syntax-error.patch
|
||||
|
||||
|
||||
BuildArch: noarch
|
||||
BuildRequires: python3-devel
|
||||
BuildRequires: python3-setuptools
|
||||
BuildRequires: python3-six
|
||||
|
||||
%description
|
||||
Genshi is a Python library that provides an integrated set of
|
||||
@ -38,11 +39,13 @@ cp -a . %{py3dir}
|
||||
find examples -type f | xargs chmod a-x
|
||||
|
||||
%build
|
||||
export GENSHI_BUILD_SPEEDUP=0
|
||||
cd %{py3dir}
|
||||
%py3_build
|
||||
cd -
|
||||
|
||||
%install
|
||||
export GENSHI_BUILD_SPEEDUP=0
|
||||
cd %{py3dir}
|
||||
%py3_install
|
||||
rm -rf %{buildroot}%{python3_sitelib}/genshi/tests
|
||||
@ -62,6 +65,9 @@ cd -
|
||||
%{python3_sitelib}/genshi
|
||||
|
||||
%changelog
|
||||
* Wed Mar 30 2022 xigaoxinyan <xigaoxinyan@huawei.com> - 0.7.6-1
|
||||
- update to 0.7.6
|
||||
|
||||
* Tue Dec 22 2020 lingsheng <lingsheng@huaweu.com> - 0.7.3-7
|
||||
- Fix wrong source0 url
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user