From 2d3b966419e5c1534e54ebb931457192dcf3dfd204fe837161e41fe7f6fbee09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=C3=A9ta=20Machov=C3=A1?= Date: Mon, 7 Nov 2022 13:27:17 +0000 Subject: [PATCH] Accepting request 1034153 from home:pgajdos:python - do not require six for build - added patches fix https://github.com/mjs/imapclient/commit/6e6ec34b0e71975134d9492add22361ce4beb2a0 + python-IMAPClient-no-python2.patch OBS-URL: https://build.opensuse.org/request/show/1034153 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-IMAPClient?expand=0&rev=11 --- python-IMAPClient-no-python2.patch | 1336 ++++++++++++++++++++++++++++ python-IMAPClient.changes | 8 + python-IMAPClient.spec | 10 +- 3 files changed, 1350 insertions(+), 4 deletions(-) create mode 100644 python-IMAPClient-no-python2.patch diff --git a/python-IMAPClient-no-python2.patch b/python-IMAPClient-no-python2.patch new file mode 100644 index 0000000..942fea4 --- /dev/null +++ b/python-IMAPClient-no-python2.patch @@ -0,0 +1,1336 @@ +Index: imapclient-2.3.1/.github/workflows/main.yml +=================================================================== +--- imapclient-2.3.1.orig/.github/workflows/main.yml ++++ imapclient-2.3.1/.github/workflows/main.yml +@@ -15,14 +15,12 @@ jobs: + fail-fast: false + matrix: + python-version: +- - "2.7" + - "3.4" + - "3.5" + - "3.6" + - "3.7" + - "3.8" + - "3.9" +- - "pypy2" + - "pypy3" + steps: + - uses: actions/checkout@v2 +Index: imapclient-2.3.1/doc/src/concepts.rst +=================================================================== +--- imapclient-2.3.1.orig/doc/src/concepts.rst ++++ imapclient-2.3.1/doc/src/concepts.rst +@@ -102,13 +102,6 @@ When constructing a custom context it is + the default context, created by the ``ssl`` module, and modify it to + suit your needs. + +-.. warning:: +- +- Users of Python 2.7.0 - 2.7.8 can use TLS but cannot configure +- the settings via an ``ssl.SSLContext``. These Python versions are +- also not capable of proper certification verification. It is highly +- encouraged to upgrade to a more recent version of Python. +- + The following example shows how to to disable certification + verification and certificate host name checks if required. + +Index: imapclient-2.3.1/doc/src/index.rst +=================================================================== +--- imapclient-2.3.1.orig/doc/src/index.rst ++++ imapclient-2.3.1/doc/src/index.rst +@@ -30,7 +30,7 @@ explains IMAP in detail. Other RFCs also + to the base protocol. These are referred to in the documentation below + where relevant. + +-Python versions 2.7 and 3.4 through 3.9 are officially supported. ++Python versions 3.4 through 3.9 are officially supported. + + Getting Started + --------------- +Index: imapclient-2.3.1/imapclient/__init__.py +=================================================================== +--- imapclient-2.3.1.orig/imapclient/__init__.py ++++ imapclient-2.3.1/imapclient/__init__.py +@@ -5,8 +5,6 @@ + # version_info provides the version number in programmer friendly way. + # The 4th part will be either alpha, beta or final. + +-from __future__ import unicode_literals +- + from .imapclient import * + from .response_parser import * + from .tls import * +Index: imapclient-2.3.1/imapclient/config.py +=================================================================== +--- imapclient-2.3.1.orig/imapclient/config.py ++++ imapclient-2.3.1/imapclient/config.py +@@ -2,16 +2,13 @@ + # Released subject to the New BSD License + # Please see http://en.wikipedia.org/wiki/BSD_licenses + +-from __future__ import unicode_literals +- + import json + from os import environ, path + import ssl + +-from six import iteritems +-from six.moves.configparser import SafeConfigParser, NoOptionError +-from six.moves.urllib.request import urlopen +-from six.moves.urllib.parse import urlencode ++import configparser ++import urllib.parse ++import urllib.request + + import imapclient + +@@ -45,7 +42,7 @@ def parse_config_file(filename): + Used by livetest.py and interact.py + """ + +- parser = SafeConfigParser(get_string_config_defaults()) ++ parser = configparser.SafeConfigParser(get_string_config_defaults()) + with open(filename, "r") as fh: + parser.readfp(fh) + +@@ -62,7 +59,7 @@ def parse_config_file(filename): + + def get_string_config_defaults(): + out = {} +- for k, v in iteritems(get_config_defaults()): ++ for k, v in get_config_defaults().items(): + if v is True: + v = "true" + elif v is False: +@@ -80,7 +77,7 @@ def _read_config_section(parser, section + def get_allowing_none(name, typefunc): + try: + v = parser.get(section, name) +- except NoOptionError: ++ except configparser.NoOptionError: + return None + if not v: + return None +@@ -133,7 +130,8 @@ def refresh_oauth2_token(hostname, clien + refresh_token=refresh_token.encode("ascii"), + grant_type=b"refresh_token", + ) +- response = urlopen(url, urlencode(post).encode("ascii")).read() ++ response = urllib.request.urlopen( ++ url, urllib.parse.urlencode(post).encode("ascii")).read() + return json.loads(response.decode("ascii"))["access_token"] + + +Index: imapclient-2.3.1/imapclient/datetime_util.py +=================================================================== +--- imapclient-2.3.1.orig/imapclient/datetime_util.py ++++ imapclient-2.3.1/imapclient/datetime_util.py +@@ -2,8 +2,6 @@ + # Released subject to the New BSD License + # Please see http://en.wikipedia.org/wiki/BSD_licenses + +-from __future__ import unicode_literals +- + import re + from datetime import datetime + from email.utils import parsedate_tz +Index: imapclient-2.3.1/imapclient/fixed_offset.py +=================================================================== +--- imapclient-2.3.1.orig/imapclient/fixed_offset.py ++++ imapclient-2.3.1/imapclient/fixed_offset.py +@@ -2,8 +2,6 @@ + # Released subject to the New BSD License + # Please see http://en.wikipedia.org/wiki/BSD_licenses + +-from __future__ import unicode_literals +- + import time + from datetime import tzinfo, timedelta + +Index: imapclient-2.3.1/imapclient/imap_utf7.py +=================================================================== +--- imapclient-2.3.1.orig/imapclient/imap_utf7.py ++++ imapclient-2.3.1/imapclient/imap_utf7.py +@@ -6,10 +6,8 @@ + # base64 encoding context), which is & in this modified UTF-7 convention, + # since + is considered as mainly used in mailbox names. + # Other variations and examples can be found in the RFC 3501, section 5.1.3. +-from __future__ import unicode_literals + + import binascii +-from six import binary_type, text_type, byte2int, iterbytes, unichr + + + def encode(s): +@@ -18,7 +16,7 @@ def encode(s): + Input is unicode; output is bytes (Python 3) or str (Python 2). If + non-unicode input is provided, the input is returned unchanged. + """ +- if not isinstance(s, text_type): ++ if not isinstance(s, str): + return s + + res = bytearray() +@@ -56,8 +54,8 @@ def encode(s): + return bytes(res) + + +-AMPERSAND_ORD = byte2int(b"&") +-DASH_ORD = byte2int(b"-") ++AMPERSAND_ORD = ord("&") ++DASH_ORD = ord("-") + + + def decode(s): +@@ -67,13 +65,13 @@ def decode(s): + unicode. If non-bytes/str input is provided, the input is returned + unchanged. + """ +- if not isinstance(s, binary_type): ++ if not isinstance(s, bytes): + return s + + res = [] + # Store base64 substring that will be decoded once stepping on end shift character + b64_buffer = bytearray() +- for c in iterbytes(s): ++ for c in s: + # Shift character without anything in buffer -> starts storing base64 substring + if c == AMPERSAND_ORD and not b64_buffer: + b64_buffer.append(c) +@@ -90,7 +88,7 @@ def decode(s): + b64_buffer.append(c) + # No buffer initialized yet, should be an ASCII printable char + else: +- res.append(unichr(c)) ++ res.append(chr(c)) + + # Decode the remaining buffer if any + if b64_buffer: +Index: imapclient-2.3.1/imapclient/imapclient.py +=================================================================== +--- imapclient-2.3.1.orig/imapclient/imapclient.py ++++ imapclient-2.3.1/imapclient/imapclient.py +@@ -2,8 +2,6 @@ + # Released subject to the New BSD License + # Please see http://en.wikipedia.org/wiki/BSD_licenses + +-from __future__ import unicode_literals +- + import functools + import imaplib + import itertools +@@ -17,8 +15,6 @@ from datetime import datetime, date + from operator import itemgetter + from logging import LoggerAdapter, getLogger + +-from six import moves, iteritems, text_type, integer_types, PY3, binary_type, iterbytes +- + from . import exceptions + from . import imap4 + from . import response_lexer +@@ -28,8 +24,6 @@ from .imap_utf7 import encode as encode_ + from .response_parser import parse_response, parse_message_list, parse_fetch_response + from .util import to_bytes, to_unicode, assert_imap_protocol, chunk + +-xrange = moves.xrange +- + try: + from select import poll + +@@ -38,9 +32,6 @@ except: + # Fallback to select() on systems that don't support poll() + POLL_SUPPORT = False + +-if PY3: +- long = int # long is just int in python3 +- + + logger = getLogger(__name__) + +@@ -744,11 +735,11 @@ class IMAPClient(object): + ret = [] + parsed = parse_response(folder_data) + for flags, delim, name in chunk(parsed, size=3): +- if isinstance(name, (int, long)): ++ if isinstance(name, int): + # Some IMAP implementations return integer folder names + # with quotes. These get parsed to ints so convert them + # back to strings. +- name = text_type(name) ++ name = str(name) + elif self.folder_encode: + name = decode_utf7(name) + +@@ -838,7 +829,7 @@ class IMAPClient(object): + if key == b"PERMANENTFLAGS": + out[key] = tuple(match.group("data").split()) + +- for key, value in iteritems(untagged): ++ for key, value in untagged.items(): + key = key.upper() + if key in (b"OK", b"PERMANENTFLAGS"): + continue # already handled above +@@ -1190,7 +1181,7 @@ class IMAPClient(object): + ] + args.extend(_normalise_search_criteria(criteria, charset)) + ids = self._raw_command_untagged(b"SORT", args, unpack=True) +- return [long(i) for i in ids.split()] ++ return [int(i) for i in ids.split()] + + def thread(self, algorithm="REFERENCES", criteria="ALL", charset="UTF-8"): + """Return a list of messages threads from the currently +@@ -1276,7 +1267,7 @@ class IMAPClient(object): + response = self.fetch(messages, [b"X-GM-LABELS"]) + response = self._filter_fetch_dict(response, b"X-GM-LABELS") + return { +- msg: utf7_decode_sequence(labels) for msg, labels in iteritems(response) ++ msg: utf7_decode_sequence(labels) for msg, labels in response.items() + } + + def add_gmail_labels(self, messages, labels, silent=False): +@@ -1405,10 +1396,7 @@ class IMAPClient(object): + """ + if msg_time: + time_val = '"%s"' % datetime_to_INTERNALDATE(msg_time) +- if PY3: +- time_val = to_unicode(time_val) +- else: +- time_val = to_bytes(time_val) ++ time_val = to_unicode(time_val) + else: + time_val = None + return self._command_and_check( +@@ -1528,7 +1516,7 @@ class IMAPClient(object): + data = self._command_and_check("getacl", self._normalise_folder(folder)) + parts = list(response_lexer.TokenSource(data)) + parts = parts[1:] # First item is folder name +- return [(parts[i], parts[i + 1]) for i in xrange(0, len(parts), 2)] ++ return [(parts[i], parts[i + 1]) for i in range(0, len(parts), 2)] + + @require_capability("ACL") + def setacl(self, folder, who, what): +@@ -1730,8 +1718,7 @@ class IMAPClient(object): + assert not kwargs, "unexpected keyword args: " + ", ".join(kwargs) + + if uid and self.use_uid: +- if PY3: +- command = to_unicode(command) # imaplib must die ++ command = to_unicode(command) # imaplib must die + typ, data = self._imap.uid(command, *args) + else: + meth = getattr(self._imap, to_unicode(command)) +@@ -1749,7 +1736,7 @@ class IMAPClient(object): + cmd, messages, self._normalise_labels(labels), b"X-GM-LABELS", silent=silent + ) + return ( +- {msg: utf7_decode_sequence(labels) for msg, labels in iteritems(response)} ++ {msg: utf7_decode_sequence(labels) for msg, labels in response.items()} + if response + else None + ) +@@ -1772,17 +1759,17 @@ class IMAPClient(object): + return self._filter_fetch_dict(parse_fetch_response(data), fetch_key) + + def _filter_fetch_dict(self, fetch_dict, key): +- return dict((msgid, data[key]) for msgid, data in iteritems(fetch_dict)) ++ return dict((msgid, data[key]) for msgid, data in fetch_dict.items()) + + def _normalise_folder(self, folder_name): +- if isinstance(folder_name, binary_type): ++ if isinstance(folder_name, bytes): + folder_name = folder_name.decode("ascii") + if self.folder_encode: + folder_name = encode_utf7(folder_name) + return _quote(folder_name) + + def _normalise_labels(self, labels): +- if isinstance(labels, (text_type, binary_type)): ++ if isinstance(labels, (str, bytes)): + labels = (labels,) + return [_quote(encode_utf7(l)) for l in labels] + +@@ -1796,7 +1783,7 @@ class IMAPClient(object): + + + def _quote(arg): +- if isinstance(arg, text_type): ++ if isinstance(arg, str): + arg = arg.replace("\\", "\\\\") + arg = arg.replace('"', '\\"') + q = '"' +@@ -1813,7 +1800,7 @@ def _normalise_search_criteria(criteria, + if not charset: + charset = "us-ascii" + +- if isinstance(criteria, (text_type, binary_type)): ++ if isinstance(criteria, (str, bytes)): + return [to_bytes(criteria, charset)] + + out = [] +@@ -1834,7 +1821,7 @@ def _normalise_search_criteria(criteria, + + + def _normalise_sort_criteria(criteria, charset=None): +- if isinstance(criteria, (text_type, binary_type)): ++ if isinstance(criteria, (str, bytes)): + criteria = [criteria] + return b"(" + b" ".join(to_bytes(item).upper() for item in criteria) + b")" + +@@ -1845,7 +1832,7 @@ class _literal(bytes): + pass + + +-class _quoted(binary_type): ++class _quoted(bytes): + """ + This class holds a quoted bytes value which provides access to the + unquoted value via the *original* attribute. +@@ -1892,7 +1879,7 @@ def _join_and_paren(items): + + + def _normalise_text_list(items): +- if isinstance(items, (text_type, binary_type)): ++ if isinstance(items, (str, bytes)): + items = (items,) + return (to_unicode(c) for c in items) + +@@ -1901,14 +1888,14 @@ def join_message_ids(messages): + """Convert a sequence of messages ids or a single integer message id + into an id byte string for use with IMAP commands + """ +- if isinstance(messages, (text_type, binary_type, integer_types)): ++ if isinstance(messages, (str, bytes, int)): + messages = (to_bytes(messages),) + return b",".join(_maybe_int_to_bytes(m) for m in messages) + + + def _maybe_int_to_bytes(val): +- if isinstance(val, integer_types): +- return str(val).encode("us-ascii") if PY3 else str(val) ++ if isinstance(val, int): ++ return str(val).encode("us-ascii") + return to_bytes(val) + + +@@ -1943,7 +1930,7 @@ def as_triplets(items): + + + def _is8bit(data): +- return isinstance(data, _literal) or any(b > 127 for b in iterbytes(data)) ++ return isinstance(data, _literal) or any(b > 127 for b in data) + + + def _iter_with_last(items): +@@ -1964,7 +1951,7 @@ class _dict_bytes_normaliser(object): + self._d = d + + def iteritems(self): +- for key, value in iteritems(self._d): ++ for key, value in self._d.items(): + yield to_bytes(key), value + + # For Python 3 compatibility. +@@ -1998,7 +1985,7 @@ class _dict_bytes_normaliser(object): + + def _gen_keys(self, k): + yield k +- if isinstance(k, binary_type): ++ if isinstance(k, bytes): + yield to_unicode(k) + else: + yield to_bytes(k) +@@ -2037,7 +2024,7 @@ class IMAPlibLoggerAdapter(LoggerAdapter + def process(self, msg, kwargs): + # msg is usually unicode but see #367. Convert bytes to + # unicode if required. +- if isinstance(msg, binary_type): ++ if isinstance(msg, bytes): + msg = msg.decode("ascii", "ignore") + + for command in ("LOGIN", "AUTHENTICATE"): +Index: imapclient-2.3.1/imapclient/interact.py +=================================================================== +--- imapclient-2.3.1.orig/imapclient/interact.py ++++ imapclient-2.3.1/imapclient/interact.py +@@ -4,14 +4,9 @@ + # Released subject to the New BSD License + # Please see http://en.wikipedia.org/wiki/BSD_licenses + +-from __future__ import unicode_literals +- +- + from getpass import getpass + from optparse import OptionParser + +-from six import iteritems +- + from .config import parse_config_file, create_client_from_config, get_config_defaults + + +@@ -93,7 +88,7 @@ def command_line(): + # Scan through options, filling in defaults and prompting when + # a compulsory option wasn't provided. + compulsory_opts = ("host", "username", "password") +- for name, default_value in iteritems(get_config_defaults()): ++ for name, default_value in get_config_defaults().items(): + value = getattr(opts, name, default_value) + if name in compulsory_opts and value is None: + value = getpass(name + ": ") +Index: imapclient-2.3.1/imapclient/response_lexer.py +=================================================================== +--- imapclient-2.3.1.orig/imapclient/response_lexer.py ++++ imapclient-2.3.1/imapclient/response_lexer.py +@@ -9,19 +9,15 @@ Although Lexer does all the work, TokenS + external callers. + """ + +-from __future__ import unicode_literals +- +-import six +- + from .util import assert_imap_protocol + + __all__ = ["TokenSource"] + + CTRL_CHARS = frozenset(c for c in range(32)) + ALL_CHARS = frozenset(c for c in range(256)) +-SPECIALS = frozenset(c for c in six.iterbytes(b' ()%"[')) ++SPECIALS = frozenset(c for c in b' ()%"[') + NON_SPECIALS = ALL_CHARS - SPECIALS - CTRL_CHARS +-WHITESPACE = frozenset(c for c in six.iterbytes(b" \t\r\n")) ++WHITESPACE = frozenset(c for c in b" \t\r\n") + + BACKSLASH = ord("\\") + OPEN_SQUARE = ord("[") +@@ -146,7 +142,7 @@ class LiteralHandlingIter: + self.literal = None + + def __iter__(self): +- return PushableIterator(six.iterbytes(self.src_text)) ++ return PushableIterator(self.src_text) + + + class PushableIterator(object): +Index: imapclient-2.3.1/imapclient/response_parser.py +=================================================================== +--- imapclient-2.3.1.orig/imapclient/response_parser.py ++++ imapclient-2.3.1/imapclient/response_parser.py +@@ -11,21 +11,15 @@ Initially inspired by http://effbot.org/ + + # TODO more exact error reporting + +-from __future__ import unicode_literals +- + import re + import sys + from collections import defaultdict + +-import six +- + from .datetime_util import parse_to_datetime + from .response_lexer import TokenSource + from .response_types import BodyData, Envelope, Address, SearchIds + from .exceptions import ProtocolError + +-xrange = six.moves.xrange +- + __all__ = ["parse_response", "parse_message_list"] + + +@@ -60,7 +54,7 @@ def parse_message_list(data): + if not data: + return SearchIds() + +- if six.PY3 and isinstance(data, six.binary_type): ++ if isinstance(data, bytes): + data = data.decode("ascii") + + m = _msg_id_pattern.match(data) +@@ -133,7 +127,7 @@ def parse_fetch_response(text, normalise + # always return the sequence of the message, so it is available + # even if we return keyed by UID. + msg_data = {b"SEQ": seq} +- for i in xrange(0, len(msg_response), 2): ++ for i in range(0, len(msg_response), 2): + word = msg_response[i].upper() + value = msg_response[i + 1] + +Index: imapclient-2.3.1/imapclient/response_types.py +=================================================================== +--- imapclient-2.3.1.orig/imapclient/response_types.py ++++ imapclient-2.3.1/imapclient/response_types.py +@@ -2,13 +2,9 @@ + # Released subject to the New BSD License + # Please see http://en.wikipedia.org/wiki/BSD_licenses + +-from __future__ import unicode_literals +- + from collections import namedtuple + from email.utils import formataddr + +-import six +- + from .util import to_unicode + + +@@ -120,7 +116,7 @@ class BodyData(tuple): + if isinstance(response[0], tuple): + # Multipart, find where the message part tuples stop + for i, part in enumerate(response): +- if isinstance(part, six.binary_type): ++ if isinstance(part, bytes): + break + return cls(([cls.create(part) for part in response[:i]],) + response[i:]) + else: +Index: imapclient-2.3.1/imapclient/testable_imapclient.py +=================================================================== +--- imapclient-2.3.1.orig/imapclient/testable_imapclient.py ++++ imapclient-2.3.1/imapclient/testable_imapclient.py +@@ -2,8 +2,6 @@ + # Released subject to the New BSD License + # Please see http://en.wikipedia.org/wiki/BSD_licenses + +-from __future__ import unicode_literals +- + from .imapclient import IMAPClient + + try: +Index: imapclient-2.3.1/imapclient/util.py +=================================================================== +--- imapclient-2.3.1.orig/imapclient/util.py ++++ imapclient-2.3.1/imapclient/util.py +@@ -2,11 +2,7 @@ + # Released subject to the New BSD License + # Please see http://en.wikipedia.org/wiki/BSD_licenses + +-from __future__ import unicode_literals +- +-import six + import logging +-from six import binary_type, text_type + + from . import exceptions + +@@ -14,7 +10,7 @@ logger = logging.getLogger(__name__) + + + def to_unicode(s): +- if isinstance(s, binary_type): ++ if isinstance(s, bytes): + try: + return s.decode("ascii") + except UnicodeDecodeError: +@@ -28,7 +24,7 @@ def to_unicode(s): + + + def to_bytes(s, charset="ascii"): +- if isinstance(s, text_type): ++ if isinstance(s, str): + return s.encode(charset) + return s + +@@ -42,5 +38,5 @@ def assert_imap_protocol(condition, mess + + + def chunk(lst, size): +- for i in six.moves.range(0, len(lst), size): ++ for i in range(0, len(lst), size): + yield lst[i : i + size] +Index: imapclient-2.3.1/interact.py +=================================================================== +--- imapclient-2.3.1.orig/interact.py ++++ imapclient-2.3.1/interact.py +@@ -4,8 +4,6 @@ + # Released subject to the New BSD License + # Please see http://en.wikipedia.org/wiki/BSD_licenses + +-from __future__ import unicode_literals +- + from imapclient.interact import main + + main() +Index: imapclient-2.3.1/livetest.py +=================================================================== +--- imapclient-2.3.1.orig/livetest.py ++++ imapclient-2.3.1/livetest.py +@@ -5,8 +5,6 @@ + # Released subject to the New BSD License + # Please see http://en.wikipedia.org/wiki/BSD_licenses + +-from __future__ import print_function, unicode_literals +- + import copy + import imp + import os +@@ -19,8 +17,6 @@ import time + from datetime import datetime + from email.utils import make_msgid + +-from six import binary_type, text_type, PY3, iteritems +- + from imapclient.config import parse_config_file, create_client_from_config + from imapclient.exceptions import IMAPClientError + from imapclient.fixed_offset import FixedOffset +@@ -170,7 +166,7 @@ class _TestBase(unittest.TestCase): + self.client.expunge() + + def add_prefix_to_folder(self, folder): +- if isinstance(folder, binary_type): ++ if isinstance(folder, bytes): + return ( + self.base_folder.encode("ascii") + + self.folder_delimiter.encode("ascii") +@@ -219,7 +215,7 @@ class TestGeneral(_TestBase): + + def test_alternates(self): + # Check alternate connection/login configurations. +- for name, conf in iteritems(self.conf.alternates): ++ for name, conf in self.conf.alternates.items(): + try: + client = create_client_from_config(conf) + client.logout() +@@ -446,13 +442,13 @@ class TestGeneral(_TestBase): + for folder in folders: + self.client.create_folder(folder) + +- if isinstance(folder, binary_type): ++ if isinstance(folder, bytes): + new_folder = folder + b"x" + else: + new_folder = folder + "x" + + resp = self.client.rename_folder(folder, new_folder) +- self.assertIsInstance(resp, binary_type) ++ self.assertIsInstance(resp, bytes) + self.assertTrue(len(resp) > 0) + + self.assertFalse(self.client.folder_exists(folder)) +@@ -510,7 +506,7 @@ class TestGeneral(_TestBase): + finally: + text, more_responses = self.client.idle_done() + self.assertIn((1, b"EXISTS"), responses) +- self.assertTrue(isinstance(text, binary_type)) ++ self.assertTrue(isinstance(text, bytes)) + self.assertGreater(len(text), 0) + self.assertTrue(isinstance(more_responses, list)) + +@@ -529,7 +525,7 @@ class TestGeneral(_TestBase): + return + + self.assertIn((2, b"EXISTS"), responses) +- self.assertTrue(isinstance(text, binary_type)) ++ self.assertTrue(isinstance(text, bytes)) + self.assertGreater(len(text), 0) + + def test_noop(self): +@@ -537,7 +533,7 @@ class TestGeneral(_TestBase): + + # Initially there should be no responses + text, resps = self.client.noop() +- self.assertTrue(isinstance(text, binary_type)) ++ self.assertTrue(isinstance(text, bytes)) + self.assertGreater(len(text), 0) + self.assertEqual(resps, []) + +@@ -549,7 +545,7 @@ class TestGeneral(_TestBase): + + # Check for this addition in the NOOP data + msg, resps = self.client.noop() +- self.assertTrue(isinstance(text, binary_type)) ++ self.assertTrue(isinstance(text, bytes)) + self.assertGreater(len(text), 0) + self.assertTrue(isinstance(resps, list)) + self.assertIn((1, b"EXISTS"), resps) +@@ -614,7 +610,7 @@ def createUidTestClass(conf, use_uid): + resp = self.client.append( + self.base_folder, in_message, ("abc", "def"), msg_time + ) +- self.assertIsInstance(resp, binary_type) ++ self.assertIsInstance(resp, bytes) + + # Retrieve the just added message and check that all looks well + self.assertEqual(self.client.select_folder(self.base_folder)[b"EXISTS"], 1) +@@ -1068,7 +1064,7 @@ def createUidTestClass(conf, use_uid): + + # Test empty mailbox + text, resps = self.client.expunge() +- self.assertTrue(isinstance(text, binary_type)) ++ self.assertTrue(isinstance(text, bytes)) + self.assertGreater(len(text), 0) + # Some servers return nothing while others (e.g. Exchange) return (0, 'EXISTS') + self.assertIn(resps, ([], [(0, b"EXISTS")])) +@@ -1078,7 +1074,7 @@ def createUidTestClass(conf, use_uid): + + msg, resps = self.client.expunge() + +- self.assertTrue(isinstance(text, binary_type)) ++ self.assertTrue(isinstance(text, bytes)) + self.assertGreater(len(text), 0) + self.assertTrue(isinstance(resps, list)) + if not self.is_gmail(): +@@ -1138,7 +1134,7 @@ def quiet_logout(client): + + + def maybe_lower(val): +- if isinstance(val, (text_type, binary_type)): ++ if isinstance(val, (str, bytes)): + return val.lower() + return val + +@@ -1197,8 +1193,6 @@ def main(): + if name is None: + name = klass.__name__ + else: +- if not PY3: +- name = name.encode("ascii") + klass.__name__ = name + setattr(live_test_mod, name, klass) + +Index: imapclient-2.3.1/setup.py +=================================================================== +--- imapclient-2.3.1.orig/setup.py ++++ imapclient-2.3.1/setup.py +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + + # Copyright (c) 2017, Menno Smits + # Released subject to the New BSD License +@@ -9,17 +9,11 @@ from os import path + + from setuptools import setup + +-MAJ_MIN_MIC = sys.version_info[:3] +-IS_PY3 = MAJ_MIN_MIC >= (3, 0, 0) +- + # Read version info + here = path.dirname(__file__) + version_file = path.join(here, "imapclient", "version.py") + info = {} +-if IS_PY3: +- exec(open(version_file).read(), {}, info) +-else: +- execfile(version_file, {}, info) ++exec(open(version_file).read(), {}, info) + + desc = """\ + IMAPClient is an easy-to-use, Pythonic and complete IMAP client library. +@@ -33,14 +27,12 @@ Features: + * Convenience methods are provided for commonly used functionality. + * Exceptions are raised when errors occur. + +-Python versions 2.7 and 3.4 through 3.9 are officially supported. ++Python versions 3.4 through 3.9 are officially supported. + + IMAPClient includes comprehensive units tests and automated + functional tests that can be run against a live IMAP server. + """ + +-main_deps = ["six"] +-test_deps = ['mock>=1.3.0; python_version < "3.4"'] + doc_deps = ["sphinx"] + + setup( +@@ -57,10 +49,9 @@ setup( + download_url="http://menno.io/projects/IMAPClient/IMAPClient-%s.zip" % info["version"], + packages=["imapclient"], + package_data=dict(imapclient=["examples/*.py"]), +- install_requires=main_deps, +- tests_require=test_deps, +- extras_require={"test": test_deps, "doc": doc_deps}, ++ extras_require={"doc": doc_deps}, + long_description=desc, ++ python_requires=">=3.4.0", + classifiers=[ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", +Index: imapclient-2.3.1/tests/imapclient_test.py +=================================================================== +--- imapclient-2.3.1.orig/tests/imapclient_test.py ++++ imapclient-2.3.1/tests/imapclient_test.py +@@ -1,5 +1,5 @@ + from imapclient.testable_imapclient import TestableIMAPClient as IMAPClient +-from .util import unittest ++import unittest + + + class IMAPClientTest(unittest.TestCase): +Index: imapclient-2.3.1/tests/test_auth.py +=================================================================== +--- imapclient-2.3.1.orig/tests/test_auth.py ++++ imapclient-2.3.1/tests/test_auth.py +@@ -2,8 +2,6 @@ + # Released subject to the New BSD License + # Please see http://en.wikipedia.org/wiki/BSD_licenses + +-from __future__ import unicode_literals +- + from imapclient import IMAPClient + from imapclient.exceptions import LoginError + from .imapclient_test import IMAPClientTest +Index: imapclient-2.3.1/tests/test_datetime_util.py +=================================================================== +--- imapclient-2.3.1.orig/tests/test_datetime_util.py ++++ imapclient-2.3.1/tests/test_datetime_util.py +@@ -2,9 +2,9 @@ + # Released subject to the New BSD License + # Please see http://en.wikipedia.org/wiki/BSD_licenses + +-from __future__ import unicode_literals +- + from datetime import datetime, date ++import unittest ++from unittest.mock import patch + + + from imapclient.datetime_util import ( +@@ -14,7 +14,6 @@ from imapclient.datetime_util import ( + parse_to_datetime, + ) + from imapclient.fixed_offset import FixedOffset +-from .util import unittest, patch + + + class TestParsing(unittest.TestCase): +Index: imapclient-2.3.1/tests/test_enable.py +=================================================================== +--- imapclient-2.3.1.orig/tests/test_enable.py ++++ imapclient-2.3.1/tests/test_enable.py +@@ -2,13 +2,11 @@ + # Released subject to the New BSD License + # Please see http://en.wikipedia.org/wiki/BSD_licenses + +-from __future__ import unicode_literals +- ++from unittest.mock import Mock + + from imapclient import IMAPClient + from imapclient.exceptions import IllegalStateError + from .imapclient_test import IMAPClientTest +-from .util import Mock + + + class TestEnable(IMAPClientTest): +Index: imapclient-2.3.1/tests/test_fixed_offset.py +=================================================================== +--- imapclient-2.3.1.orig/tests/test_fixed_offset.py ++++ imapclient-2.3.1/tests/test_fixed_offset.py +@@ -2,12 +2,11 @@ + # Released subject to the New BSD License + # Please see http://en.wikipedia.org/wiki/BSD_licenses + +-from __future__ import unicode_literals +- + from datetime import timedelta ++import unittest ++from unittest.mock import Mock, patch, DEFAULT + + from imapclient.fixed_offset import FixedOffset +-from .util import unittest, Mock, patch, DEFAULT + + + class TestFixedOffset(unittest.TestCase): +Index: imapclient-2.3.1/tests/test_folder_status.py +=================================================================== +--- imapclient-2.3.1.orig/tests/test_folder_status.py ++++ imapclient-2.3.1/tests/test_folder_status.py +@@ -2,10 +2,9 @@ + # Released subject to the New BSD License + # Please see http://en.wikipedia.org/wiki/BSD_licenses + +-from __future__ import unicode_literals ++from unittest.mock import Mock + + from .imapclient_test import IMAPClientTest +-from .util import Mock + + + class TestFolderStatus(IMAPClientTest): +Index: imapclient-2.3.1/tests/test_imap_utf7.py +=================================================================== +--- imapclient-2.3.1.orig/tests/test_imap_utf7.py ++++ imapclient-2.3.1/tests/test_imap_utf7.py +@@ -2,12 +2,9 @@ + # Released subject to the New BSD License + # Please see http://en.wikipedia.org/wiki/BSD_licenses + +-from __future__ import unicode_literals +- +-from six import text_type, binary_type, int2byte, unichr ++import unittest + + from imapclient.imap_utf7 import decode, encode +-from tests.util import unittest + + + class IMAP4UTF7TestCase(unittest.TestCase): +@@ -30,13 +27,13 @@ class IMAP4UTF7TestCase(unittest.TestCas + def test_encode(self): + for (input, output) in self.tests: + encoded = encode(input) +- self.assertIsInstance(encoded, binary_type) ++ self.assertIsInstance(encoded, bytes) + self.assertEqual(encoded, output) + + def test_decode(self): + for (input, output) in self.tests: + decoded = decode(output) +- self.assertIsInstance(decoded, text_type) ++ self.assertIsInstance(decoded, str) + self.assertEqual(input, decoded) + + def test_printable_singletons(self): +@@ -46,8 +43,8 @@ class IMAP4UTF7TestCase(unittest.TestCas + """ + # All printables represent themselves + for o in list(range(0x20, 0x26)) + list(range(0x27, 0x7F)): +- self.assertEqual(int2byte(o), encode(unichr(o))) +- self.assertEqual(unichr(o), decode(int2byte(o))) ++ self.assertEqual(bytes((o,)), encode(chr(o))) ++ self.assertEqual(chr(o), decode(bytes((o,)))) + self.assertEqual(encode("&"), b"&-") + self.assertEqual(encode("&"), b"&-") + self.assertEqual(decode(b"&-"), "&") +Index: imapclient-2.3.1/tests/test_imapclient.py +=================================================================== +--- imapclient-2.3.1.orig/tests/test_imapclient.py ++++ imapclient-2.3.1/tests/test_imapclient.py +@@ -2,16 +2,15 @@ + # Released subject to the New BSD License + # Please see http://en.wikipedia.org/wiki/BSD_licenses + +-from __future__ import unicode_literals +- ++import io + import itertools + import socket + import sys + import warnings + from datetime import datetime + import logging ++from unittest.mock import patch, sentinel, Mock + +-import six + from select import POLLIN + + from imapclient.exceptions import CapabilityError, IMAPClientError, ProtocolError +@@ -27,7 +26,6 @@ from imapclient.fixed_offset import Fixe + from imapclient.testable_imapclient import TestableIMAPClient as IMAPClient + + from .imapclient_test import IMAPClientTest +-from .util import patch, sentinel, Mock + + + class TestListFolders(IMAPClientTest): +@@ -738,7 +736,7 @@ class TestDebugLogging(IMAPClientTest): + # prevent basicConfig from being executed + for handler in logging.root.handlers[:]: + logging.root.removeHandler(handler) +- log_stream = six.StringIO() ++ log_stream = io.StringIO() + logging.basicConfig(stream=log_stream, level=logging.DEBUG) + + self.client._imap._mesg("two") +@@ -750,23 +748,16 @@ class TestDebugLogging(IMAPClientTest): + logger_mock.getEffectiveLevel.return_value = logging.DEBUG + + adapter = IMAPlibLoggerAdapter(logger_mock, dict()) +- if six.PY3: +- adapter.info("""> b'ICHH1 LOGIN foo@bar.org "secret"'""") +- if sys.version_info >= (3, 6, 4): +- # LoggerAdapter in Python 3.6.4+ calls logger.log() +- logger_mock.log.assert_called_once_with( +- logging.INFO, "> b'ICHH1 LOGIN **REDACTED**", extra={} +- ) +- else: +- # LoggerAdapter in Python 3.4 to 3.6 calls logger._log() +- logger_mock._log.assert_called_once_with( +- logging.INFO, "> b'ICHH1 LOGIN **REDACTED**", (), extra={} +- ) ++ adapter.info("""> b'ICHH1 LOGIN foo@bar.org "secret"'""") ++ if sys.version_info >= (3, 6, 4): ++ # LoggerAdapter in Python 3.6.4+ calls logger.log() ++ logger_mock.log.assert_called_once_with( ++ logging.INFO, "> b'ICHH1 LOGIN **REDACTED**", extra={} ++ ) + else: +- # LoggerAdapter in Python 2.7 calls logger.info() +- adapter.info('> ICHH1 LOGIN foo@bar.org "secret"') +- logger_mock.info.assert_called_once_with( +- "> ICHH1 LOGIN **REDACTED**", extra={} ++ # LoggerAdapter in Python 3.4 to 3.6 calls logger._log() ++ logger_mock._log.assert_called_once_with( ++ logging.INFO, "> b'ICHH1 LOGIN **REDACTED**", (), extra={} + ) + + +Index: imapclient-2.3.1/tests/test_init.py +=================================================================== +--- imapclient-2.3.1.orig/tests/test_init.py ++++ imapclient-2.3.1/tests/test_init.py +@@ -2,8 +2,10 @@ + # Released subject to the New BSD License + # Please see http://en.wikipedia.org/wiki/BSD_licenses + ++import unittest ++from unittest.mock import patch, sentinel, Mock ++ + from imapclient.imapclient import IMAPClient, SocketTimeout +-from .util import unittest, patch, sentinel, Mock + + + class TestInit(unittest.TestCase): +Index: imapclient-2.3.1/tests/test_response_lexer.py +=================================================================== +--- imapclient-2.3.1.orig/tests/test_response_lexer.py ++++ imapclient-2.3.1/tests/test_response_lexer.py +@@ -2,12 +2,9 @@ + # Released subject to the New BSD License + # Please see http://en.wikipedia.org/wiki/BSD_licenses + +-from __future__ import unicode_literals +- +-from six import next ++import unittest + + from imapclient.response_lexer import TokenSource +-from tests.util import unittest + + + class TestTokenSource(unittest.TestCase): +Index: imapclient-2.3.1/tests/test_response_parser.py +=================================================================== +--- imapclient-2.3.1.orig/tests/test_response_parser.py ++++ imapclient-2.3.1/tests/test_response_parser.py +@@ -6,9 +6,9 @@ + Unit tests for the FetchTokeniser and FetchParser classes + """ + +-from __future__ import unicode_literals +- ++import unittest + from datetime import datetime ++from unittest.mock import patch + + from imapclient.datetime_util import datetime_to_native + from imapclient.fixed_offset import FixedOffset +@@ -19,8 +19,6 @@ from imapclient.response_parser import ( + ) + from imapclient.response_types import Envelope, Address + from imapclient.exceptions import ProtocolError +-from tests.util import unittest +-from .util import patch + + # TODO: test invalid dates and times + +Index: imapclient-2.3.1/tests/test_search.py +=================================================================== +--- imapclient-2.3.1.orig/tests/test_search.py ++++ imapclient-2.3.1/tests/test_search.py +@@ -2,16 +2,14 @@ + # Released subject to the New BSD License + # Please see http://en.wikipedia.org/wiki/BSD_licenses + +-from __future__ import unicode_literals +- + from datetime import date, datetime ++from unittest.mock import Mock + + import imaplib + + from imapclient.exceptions import InvalidCriteriaError + from imapclient.imapclient import _quoted + from .imapclient_test import IMAPClientTest +-from .util import Mock + + + class TestSearchBase(IMAPClientTest): +Index: imapclient-2.3.1/tests/test_sort.py +=================================================================== +--- imapclient-2.3.1.orig/tests/test_sort.py ++++ imapclient-2.3.1/tests/test_sort.py +@@ -2,12 +2,11 @@ + # Released subject to the New BSD License + # Please see http://en.wikipedia.org/wiki/BSD_licenses + +-from __future__ import unicode_literals ++from unittest.mock import Mock + + from imapclient.exceptions import CapabilityError + + from .imapclient_test import IMAPClientTest +-from .util import Mock + + + class TestSort(IMAPClientTest): +Index: imapclient-2.3.1/tests/test_starttls.py +=================================================================== +--- imapclient-2.3.1.orig/tests/test_starttls.py ++++ imapclient-2.3.1/tests/test_starttls.py +@@ -2,13 +2,12 @@ + # Released subject to the New BSD License + # Please see http://en.wikipedia.org/wiki/BSD_licenses + +-from __future__ import unicode_literals ++from unittest.mock import Mock, patch, sentinel + + from imapclient.imapclient import IMAPClient + from imapclient.exceptions import IMAPClientError + + from .imapclient_test import IMAPClientTest +-from .util import Mock, patch, sentinel + + + class TestStarttls(IMAPClientTest): +Index: imapclient-2.3.1/tests/test_store.py +=================================================================== +--- imapclient-2.3.1.orig/tests/test_store.py ++++ imapclient-2.3.1/tests/test_store.py +@@ -3,19 +3,16 @@ + # Released subject to the New BSD License + # Please see http://en.wikipedia.org/wiki/BSD_licenses + +-from __future__ import unicode_literals +- +-import six ++from unittest.mock import patch, sentinel, Mock + + from imapclient.imapclient import DELETED, SEEN, ANSWERED, FLAGGED, DRAFT, RECENT + from .imapclient_test import IMAPClientTest +-from .util import patch, sentinel, Mock + + + class TestFlagsConsts(IMAPClientTest): + def test_flags_are_bytes(self): + for flag in DELETED, SEEN, ANSWERED, FLAGGED, DRAFT, RECENT: +- if not isinstance(flag, six.binary_type): ++ if not isinstance(flag, bytes): + self.fail("%r flag is not bytes" % flag) + + +Index: imapclient-2.3.1/tests/test_thread.py +=================================================================== +--- imapclient-2.3.1.orig/tests/test_thread.py ++++ imapclient-2.3.1/tests/test_thread.py +@@ -2,12 +2,11 @@ + # Released subject to the New BSD License + # Please see http://en.wikipedia.org/wiki/BSD_licenses + +-from __future__ import unicode_literals ++from unittest.mock import Mock + + from imapclient.exceptions import CapabilityError + + from .imapclient_test import IMAPClientTest +-from .util import Mock + + + class TestThread(IMAPClientTest): +Index: imapclient-2.3.1/tests/test_util_functions.py +=================================================================== +--- imapclient-2.3.1.orig/tests/test_util_functions.py ++++ imapclient-2.3.1/tests/test_util_functions.py +@@ -2,7 +2,7 @@ + # Released subject to the New BSD License + # Please see http://en.wikipedia.org/wiki/BSD_licenses + +-from __future__ import unicode_literals ++import unittest + + from imapclient.exceptions import InvalidCriteriaError, ProtocolError + from imapclient.imapclient import ( +@@ -15,7 +15,6 @@ from imapclient.imapclient import ( + _parse_untagged_response, + ) + from imapclient.util import assert_imap_protocol +-from tests.util import unittest + + + class Test_normalise_text_list(unittest.TestCase): +Index: imapclient-2.3.1/tests/test_version.py +=================================================================== +--- imapclient-2.3.1.orig/tests/test_version.py ++++ imapclient-2.3.1/tests/test_version.py +@@ -2,10 +2,9 @@ + # Released subject to the New BSD License + # Please see http://en.wikipedia.org/wiki/BSD_licenses + +-from __future__ import unicode_literals ++import unittest + + from imapclient.version import _imapclient_version_string +-from .util import unittest + + + class TestVersionString(unittest.TestCase): +Index: imapclient-2.3.1/tests/util.py +=================================================================== +--- imapclient-2.3.1.orig/tests/util.py ++++ /dev/null +@@ -1,41 +0,0 @@ +-# Copyright (c) 2014, Menno Smits +-# Released subject to the New BSD License +-# Please see http://en.wikipedia.org/wiki/BSD_licenses +- +-from __future__ import unicode_literals +- +-try: +- from unittest.mock import Mock, patch, sentinel, DEFAULT +-except ImportError: +- from mock import Mock, patch, sentinel, DEFAULT +- +- +-def find_unittest2(): +- import unittest +- +- if hasattr(unittest, "skip") and hasattr(unittest, "loader"): +- return unittest # unittest from stdlib is unittest2, use that +- try: +- import unittest2 # try for a separately installed unittest2 package +- except ImportError: +- raise ImportError( +- "unittest2 not installed and unittest in standard library is not unittest2" +- ) +- else: +- return unittest2 +- +- +-unittest = find_unittest2() +- +- +-def patch_TestCase(): +- TestCase = unittest.TestCase +- # Older versions of unittest2 don't have +- # TestCase.assertRaisesRegex and newer version raises warnings +- # when you use assertRaisesRegexp. This helps deal with the +- # mismatch. +- if not hasattr(TestCase, "assertRaisesRegex"): +- TestCase.assertRaisesRegex = TestCase.assertRaisesRegexp +- +- +-patch_TestCase() +Index: imapclient-2.3.1/tox.ini +=================================================================== +--- imapclient-2.3.1.orig/tox.ini ++++ imapclient-2.3.1/tox.ini +@@ -1,17 +1,10 @@ + [tox] +-envlist=py27,py34,py35,py36,py37,py38,py39 ++envlist=py34,py35,py36,py37,py38,py39 + requires=sphinx + + [testenv] + commands=python -m unittest + +-[testenv:py27] +-setenv= +- VIRTUALENV_PIP=19.0.1 +- VIRTUALENV_SETUPTOOLS=43.0.0 +-deps=mock +-commands=python -m unittest discover +- + [testenv:py34] + setenv= + VIRTUALENV_PIP=19.0.1 diff --git a/python-IMAPClient.changes b/python-IMAPClient.changes index e1b159d..9d9b7c2 100644 --- a/python-IMAPClient.changes +++ b/python-IMAPClient.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Mon Nov 7 10:45:39 UTC 2022 - pgajdos@suse.com + +- do not require six for build +- added patches + fix https://github.com/mjs/imapclient/commit/6e6ec34b0e71975134d9492add22361ce4beb2a0 + + python-IMAPClient-no-python2.patch + ------------------------------------------------------------------- Tue Aug 2 15:54:01 UTC 2022 - Otto Hollmann diff --git a/python-IMAPClient.spec b/python-IMAPClient.spec index 93f32bb..c79a980 100644 --- a/python-IMAPClient.spec +++ b/python-IMAPClient.spec @@ -17,7 +17,6 @@ # -%{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-IMAPClient Version: 2.3.1 Release: 0 @@ -26,12 +25,12 @@ License: BSD-3-Clause Group: Development/Languages/Python URL: https://github.com/mjs/imapclient/ Source0: https://github.com/mjs/imapclient/archive/%{version}.tar.gz +# https://github.com/mjs/imapclient/commit/6e6ec34b0e71975134d9492add22361ce4beb2a0 +Patch0: python-IMAPClient-no-python2.patch BuildRequires: %{python_module pytest} BuildRequires: %{python_module setuptools >= 20.5} -BuildRequires: %{python_module six} BuildRequires: fdupes BuildRequires: python-rpm-macros -Requires: python-six BuildArch: noarch %python_subpackages @@ -52,8 +51,10 @@ functional tests that can be run against a live IMAP server. %prep %setup -q -n imapclient-%{version} +%patch0 -p1 %build +sed -i 's:#!::' imapclient/interact.py %python_build %install @@ -67,6 +68,7 @@ functional tests that can be run against a live IMAP server. %files %{python_files} %doc README.rst %license COPYING -%{python_sitelib}/* +%{python_sitelib}/IMAPClient-*-info +%{python_sitelib}/imapclient %changelog