--- genshi/builder.py | 12 ++++------ genshi/compat.py | 5 +--- genshi/core.py | 33 ++++++++++++++--------------- genshi/filters/html.py | 15 ++++++------- genshi/filters/i18n.py | 23 +++++++++----------- genshi/filters/tests/i18n.py | 5 +--- genshi/filters/tests/test_html.py | 43 ++++++++++++++++++-------------------- genshi/filters/tests/transform.py | 17 +++++++-------- genshi/filters/transform.py | 10 +++----- genshi/input.py | 26 +++++++++++----------- genshi/output.py | 7 ++---- genshi/path.py | 3 -- genshi/template/base.py | 16 ++++++-------- genshi/template/directives.py | 6 +---- genshi/template/eval.py | 20 +++++++---------- genshi/template/loader.py | 5 +--- genshi/template/plugin.py | 5 +--- genshi/template/tests/markup.py | 5 +--- genshi/template/text.py | 5 +--- genshi/util.py | 7 ++---- setup.cfg | 2 - 21 files changed, 122 insertions(+), 148 deletions(-) Index: Genshi-0.7.9/genshi/builder.py =================================================================== --- Genshi-0.7.9.orig/genshi/builder.py 2024-06-16 01:52:43.000000000 +0200 +++ Genshi-0.7.9/genshi/builder.py 2025-05-09 08:47:55.639423560 +0200 @@ -68,8 +68,6 @@ Hello, world! """ -import six - from genshi.compat import numeric_types from genshi.core import Attrs, Markup, Namespace, QName, Stream, \ START, END, TEXT @@ -110,7 +108,7 @@ return str(self.generate()) def __unicode__(self): - return six.text_type(self.generate()) + return str(self.generate()) def __html__(self): return Markup(self.generate()) @@ -121,7 +119,7 @@ :param node: the node to append; can be an `Element`, `Fragment`, or a `Stream`, or a Python string or number """ - simple_types = (Stream, Element) + six.string_types + numeric_types + simple_types = (Stream, Element, str) + numeric_types if isinstance(node, simple_types): # For objects of a known/primitive type, we avoid the check for # whether it is iterable for better performance @@ -144,8 +142,8 @@ for event in child: yield event else: - if not isinstance(child, six.string_types): - child = six.text_type(child) + if not isinstance(child, str): + child = str(child) yield TEXT, child, (None, -1, -1) def generate(self): @@ -162,7 +160,7 @@ for name, value in kwargs.items(): name = name.rstrip('_').replace('_', '-') if value is not None and name not in names: - attrs.append((QName(name), six.text_type(value))) + attrs.append((QName(name), str(value))) names.add(name) return Attrs(attrs) Index: Genshi-0.7.9/genshi/compat.py =================================================================== --- Genshi-0.7.9.orig/genshi/compat.py 2024-06-16 01:52:43.000000000 +0200 +++ Genshi-0.7.9/genshi/compat.py 2025-05-09 08:33:55.950025453 +0200 @@ -23,11 +23,10 @@ import warnings from types import CodeType -import six IS_PYTHON2 = (sys.version_info[0] == 2) -numeric_types = (float, ) + six.integer_types +numeric_types = (float, int) # This function should only be called in Python 2, and will fail in Python 3 @@ -47,7 +46,7 @@ # We need to test if an object is an instance of a string type in places def isstring(obj): - return isinstance(obj, six.string_types) + return isinstance(obj, str) # We need to differentiate between StringIO and BytesIO in places Index: Genshi-0.7.9/genshi/core.py =================================================================== --- Genshi-0.7.9.orig/genshi/core.py 2024-06-16 01:52:43.000000000 +0200 +++ Genshi-0.7.9/genshi/core.py 2025-05-09 08:30:16.089149971 +0200 @@ -18,7 +18,6 @@ from itertools import chain import operator -import six from genshi.compat import stringrepr from genshi.util import stripentities, striptags @@ -282,7 +281,7 @@ if hasattr(event, 'totuple'): event = event.totuple() else: - event = TEXT, six.text_type(event), (None, -1, -1) + event = TEXT, str(event), (None, -1, -1) yield event return @@ -411,7 +410,7 @@ :return: a new instance with the attribute removed :rtype: `Attrs` """ - if isinstance(names, six.string_types): + if isinstance(names, str): names = (names,) return Attrs([(name, val) for name, val in self if name not in names]) @@ -445,17 +444,17 @@ return TEXT, ''.join([x[1] for x in self]), (None, -1, -1) -class Markup(six.text_type): +class Markup(str): """Marks a string as being safe for inclusion in HTML/XML output without needing to be escaped. """ __slots__ = [] def __add__(self, other): - return Markup(six.text_type.__add__(self, escape(other))) + return Markup(str.__add__(self, escape(other))) def __radd__(self, other): - return Markup(six.text_type.__add__(escape(other), self)) + return Markup(str.__add__(escape(other), self)) def __mod__(self, args): if isinstance(args, dict): @@ -464,14 +463,14 @@ args = tuple(map(escape, args)) else: args = escape(args) - return Markup(six.text_type.__mod__(self, args)) + return Markup(str.__mod__(self, args)) def __mul__(self, num): - return Markup(six.text_type.__mul__(self, num)) + return Markup(str.__mul__(self, num)) __rmul__ = __mul__ def __repr__(self): - return "<%s %s>" % (type(self).__name__, six.text_type.__repr__(self)) + return "<%s %s>" % (type(self).__name__, str.__repr__(self)) def join(self, seq, escape_quotes=True): """Return a `Markup` object which is the concatenation of the strings @@ -489,7 +488,7 @@ :see: `escape` """ escaped_items = [escape(item, quotes=escape_quotes) for item in seq] - return Markup(six.text_type.join(self, escaped_items)) + return Markup(str.join(self, escaped_items)) @classmethod def escape(cls, text, quotes=True): @@ -538,7 +537,7 @@ """ if not self: return '' - return six.text_type(self).replace('"', '"') \ + return str(self).replace('"', '"') \ .replace('>', '>') \ .replace('<', '<') \ .replace('&', '&') @@ -652,7 +651,7 @@ self.uri = uri def __init__(self, uri): - self.uri = six.text_type(uri) + self.uri = str(uri) def __contains__(self, qname): return qname.namespace == self.uri @@ -691,7 +690,7 @@ XML_NAMESPACE = Namespace('http://www.w3.org/XML/1998/namespace') -class QName(six.text_type): +class QName(str): """A qualified element or attribute name. The unicode value of instances of this class contains the qualified name of @@ -729,11 +728,11 @@ qname = qname.lstrip('{') parts = qname.split('}', 1) if len(parts) > 1: - self = six.text_type.__new__(cls, '{%s' % qname) - self.namespace, self.localname = map(six.text_type, parts) + self = str.__new__(cls, '{%s' % qname) + self.namespace, self.localname = map(str, parts) else: - self = six.text_type.__new__(cls, qname) - self.namespace, self.localname = None, six.text_type(qname) + self = str.__new__(cls, qname) + self.namespace, self.localname = None, str(qname) return self def __getnewargs__(self): Index: Genshi-0.7.9/genshi/filters/html.py =================================================================== --- Genshi-0.7.9.orig/genshi/filters/html.py 2024-06-16 01:52:43.000000000 +0200 +++ Genshi-0.7.9/genshi/filters/html.py 2025-05-09 08:30:16.089433034 +0200 @@ -15,7 +15,6 @@ import re -import six from genshi.core import Attrs, QName, stripentities from genshi.core import END, START, TEXT, COMMENT @@ -99,13 +98,13 @@ checked = False if isinstance(value, (list, tuple)): if declval is not None: - u_vals = [six.text_type(v) for v in value] + u_vals = [str(v) for v in value] checked = declval in u_vals else: checked = any(value) else: if declval is not None: - checked = declval == six.text_type(value) + checked = declval == str(value) elif type == 'checkbox': checked = bool(value) if checked: @@ -121,7 +120,7 @@ value = value[0] if value is not None: attrs |= [ - (QName('value'), six.text_type(value)) + (QName('value'), str(value)) ] elif tagname == 'select': name = attrs.get('name') @@ -164,10 +163,10 @@ select_value = None elif in_select and tagname == 'option': if isinstance(select_value, (tuple, list)): - selected = option_value in [six.text_type(v) for v + selected = option_value in [str(v) for v in select_value] else: - selected = option_value == six.text_type(select_value) + selected = option_value == str(select_value) okind, (tag, attrs), opos = option_start if selected: attrs |= [(QName('selected'), 'selected')] @@ -183,7 +182,7 @@ option_text = [] elif in_textarea and tagname == 'textarea': if textarea_value: - yield TEXT, six.text_type(textarea_value), pos + yield TEXT, str(textarea_value), pos textarea_value = None in_textarea = False yield kind, data, pos @@ -526,7 +525,7 @@ def _repl(match): t = match.group(1) if t: - return six.unichr(int(t, 16)) + return chr(int(t, 16)) t = match.group(2) if t == '\\': return r'\\' Index: Genshi-0.7.9/genshi/filters/i18n.py =================================================================== --- Genshi-0.7.9.orig/genshi/filters/i18n.py 2024-06-16 01:52:43.000000000 +0200 +++ Genshi-0.7.9/genshi/filters/i18n.py 2025-05-09 08:30:16.089768807 +0200 @@ -24,7 +24,6 @@ from functools import partial from types import FunctionType -import six from genshi.core import Attrs, Namespace, QName, START, END, TEXT, \ XML_NAMESPACE, _ensure, StreamEventKind @@ -801,7 +800,7 @@ if kind is START: tag, attrs = data if tag in self.ignore_tags or \ - isinstance(attrs.get(xml_lang), six.string_types): + isinstance(attrs.get(xml_lang), str): skip += 1 yield kind, data, pos continue @@ -811,7 +810,7 @@ for name, value in attrs: newval = value - if isinstance(value, six.string_types): + if isinstance(value, str): text = value.strip() if translate_attrs and name in include_attrs and text: newval = gettext(text) @@ -831,7 +830,7 @@ elif translate_text and kind is TEXT: text = data.strip() if text: - data = data.replace(text, six.text_type(gettext(text))) + data = data.replace(text, str(gettext(text))) yield kind, data, pos elif kind is SUB: @@ -944,7 +943,7 @@ if kind is START and not skip: tag, attrs = data if tag in self.ignore_tags or \ - isinstance(attrs.get(xml_lang), six.string_types): + isinstance(attrs.get(xml_lang), str): skip += 1 continue @@ -1050,7 +1049,7 @@ def _extract_attrs(self, event, gettext_functions, search_text): for name, value in event[1][1]: - if search_text and isinstance(value, six.string_types): + if search_text and isinstance(value, str): if name in self.include_attrs: text = value.strip() if text: @@ -1321,10 +1320,10 @@ strings = [] def _add(arg): if isinstance(arg, _ast_Str) \ - and isinstance(_ast_Str_value(arg), six.text_type): + and isinstance(_ast_Str_value(arg), str): strings.append(_ast_Str_value(arg)) elif isinstance(arg, _ast_Str): - strings.append(six.text_type(_ast_Str_value(arg), 'utf-8')) + strings.append(str(_ast_Str_value(arg), 'utf-8')) elif arg: strings.append(None) [_add(arg) for arg in node.args] @@ -1365,22 +1364,22 @@ :rtype: ``iterator`` """ template_class = options.get('template_class', MarkupTemplate) - if isinstance(template_class, six.string_types): + if isinstance(template_class, str): module, clsname = template_class.split(':', 1) template_class = getattr(__import__(module, {}, {}, [clsname]), clsname) encoding = options.get('encoding', None) extract_text = options.get('extract_text', True) - if isinstance(extract_text, six.string_types): + if isinstance(extract_text, str): extract_text = extract_text.lower() in ('1', 'on', 'yes', 'true') ignore_tags = options.get('ignore_tags', Translator.IGNORE_TAGS) - if isinstance(ignore_tags, six.string_types): + if isinstance(ignore_tags, str): ignore_tags = ignore_tags.split() ignore_tags = [QName(tag) for tag in ignore_tags] include_attrs = options.get('include_attrs', Translator.INCLUDE_ATTRS) - if isinstance(include_attrs, six.string_types): + if isinstance(include_attrs, str): include_attrs = include_attrs.split() include_attrs = [QName(attr) for attr in include_attrs] Index: Genshi-0.7.9/genshi/filters/tests/i18n.py =================================================================== --- Genshi-0.7.9.orig/genshi/filters/tests/i18n.py 2024-06-16 01:52:43.000000000 +0200 +++ Genshi-0.7.9/genshi/filters/tests/i18n.py 2025-05-09 08:30:16.090147309 +0200 @@ -15,7 +15,6 @@ from gettext import NullTranslations import unittest -import six from genshi.core import Attrs from genshi.template import MarkupTemplate, Context @@ -48,7 +47,7 @@ if tmsg is missing: if self._fallback: return self._fallback.ugettext(message) - return six.text_type(message) + return str(message) return tmsg else: def gettext(self, message): @@ -57,7 +56,7 @@ if tmsg is missing: if self._fallback: return self._fallback.gettext(message) - return six.text_type(message) + return str(message) return tmsg if IS_PYTHON2: Index: Genshi-0.7.9/genshi/filters/tests/test_html.py =================================================================== --- Genshi-0.7.9.orig/genshi/filters/tests/test_html.py 2024-06-16 01:52:43.000000000 +0200 +++ Genshi-0.7.9/genshi/filters/tests/test_html.py 2025-05-09 08:30:16.090568412 +0200 @@ -13,7 +13,6 @@ import unittest -import six from genshi.input import HTML, ParseError from genshi.filters.html import HTMLFormFiller, HTMLSanitizer @@ -524,91 +523,91 @@ def test_sanitize_expression(self): html = HTML(u'