more python2 removal

This commit is contained in:
Alexandre Detiste 2024-02-23 00:40:25 +01:00
parent 3afd2dcdc7
commit 1cfe843d23
192 changed files with 0 additions and 1037 deletions

View File

@ -12,9 +12,6 @@
# All configuration values have a default; values that are commented out # All configuration values have a default; values that are commented out
# serve to show the default. # serve to show the default.
import sys
import os
# If extensions (or modules to document with autodoc) are in another directory, # If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the # add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here. # documentation root, use os.path.abspath to make it absolute, like shown here.

View File

@ -6,11 +6,6 @@
# longer" to start the first test as the fixtures get built # longer" to start the first test as the fixtures get built
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
def test_create_flogger(flog_gatherer): def test_create_flogger(flog_gatherer):
print("Created flog_gatherer") print("Created flog_gatherer")

View File

@ -10,11 +10,6 @@ These tests use Paramiko, rather than Twisted's Conch, because:
2. Its API is much simpler to use. 2. Its API is much simpler to use.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import os.path import os.path
from posixpath import join from posixpath import join
from stat import S_ISDIR from stat import S_ISDIR

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from six import ensure_text from six import ensure_text
import json import json

View File

@ -1,11 +1,5 @@
#! /usr/bin/env python #! /usr/bin/env python
from future.utils import PY2
if PY2:
from future.builtins import input
import random, math, re import random, math, re
from twisted.python import usage from twisted.python import usage

View File

@ -2,11 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import sys import sys
from allmydata.scripts.runner import run from allmydata.scripts.runner import run

View File

@ -4,41 +4,14 @@ Monkey-patching of third party libraries.
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2 from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from warnings import catch_warnings from warnings import catch_warnings
def patch(): def patch():
"""Path third-party libraries to make Tahoe-LAFS work.""" """Path third-party libraries to make Tahoe-LAFS work."""
# Make sure Foolscap always get native strings passed to method names in callRemote.
# This can be removed when any one of the following happens:
#
# 1. Tahoe-LAFS on Python 2 switches to version of Foolscap that fixes
# https://github.com/warner/foolscap/issues/72
# 2. Foolscap is dropped as a dependency.
# 3. Tahoe-LAFS drops Python 2 support.
if not PY2: if not PY2:
# Python 3 doesn't need to monkey patch Foolscap # Python 3 doesn't need to monkey patch Foolscap
return return
# We need to suppress warnings so as to prevent unexpected output from
# breaking some integration tests.
with catch_warnings(record=True):
# Only tested with this version; ensure correctness with new releases,
# and then either update the assert or hopefully drop the monkeypatch.
from foolscap import __version__
assert __version__ == "0.13.1", "Wrong version %s of Foolscap" % (__version__,)
from foolscap.referenceable import RemoteReference
original_getMethodInfo = RemoteReference._getMethodInfo
def _getMethodInfo(self, name):
if isinstance(name, str):
name = name.encode("utf-8")
return original_getMethodInfo(self, name)
RemoteReference._getMethodInfo = _getMethodInfo

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import os import os
from zope.interface import implementer from zope.interface import implementer

View File

@ -1,10 +1,6 @@
"""Ported to Python 3. """Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from past.builtins import unicode from past.builtins import unicode
from zope.interface import implementer from zope.interface import implementer

View File

@ -4,10 +4,6 @@ CRS encoding and decoding.
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from zope.interface import implementer from zope.interface import implementer
from allmydata.util import mathutil from allmydata.util import mathutil
from allmydata.util.assertutil import precondition from allmydata.util.assertutil import precondition

View File

@ -9,7 +9,3 @@ objects that `cryptography` documents.
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401

View File

@ -10,10 +10,6 @@ objects that `cryptography` documents.
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import six import six
from cryptography.hazmat.backends import default_backend from cryptography.hazmat.backends import default_backend

View File

@ -4,11 +4,6 @@ Exceptions raise by allmydata.crypto.* modules
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
class BadSignature(Exception): class BadSignature(Exception):
""" """
An alleged signature did not match An alleged signature did not match

View File

@ -4,10 +4,6 @@ Utilities used by allmydata.crypto modules
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from allmydata.crypto.error import BadPrefixError from allmydata.crypto.error import BadPrefixError

View File

@ -3,10 +3,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import math import math
from allmydata.interfaces import IImmutableFileNode from allmydata.interfaces import IImmutableFileNode

View File

@ -3,10 +3,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
# Skip dict so it doesn't break things.
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, list, object, range, str, max, min # noqa: F401
from past.builtins import unicode from past.builtins import unicode
import time import time

View File

@ -2,10 +2,6 @@
Authentication for frontends. Authentication for frontends.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from zope.interface import implementer from zope.interface import implementer
from twisted.internet import defer from twisted.internet import defer
from twisted.cred import checkers, credentials from twisted.cred import checkers, credentials

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import six import six
import heapq, traceback, stat, struct import heapq, traceback, stat, struct
from stat import S_IFREG, S_IFDIR from stat import S_IFREG, S_IFDIR

View File

@ -49,11 +49,6 @@ or eat your children, but it might. Use at your own risk.
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from allmydata.util import mathutil # from the pyutil library from allmydata.util import mathutil # from the pyutil library
from allmydata.util import base32 from allmydata.util import base32

View File

@ -1,11 +1,6 @@
"""Ported to Python 3. """Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import weakref import weakref
class History(object): class History(object):

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from zope.interface import implementer from zope.interface import implementer
from twisted.internet import defer from twisted.internet import defer
from foolscap.api import DeadReferenceError, RemoteException from foolscap.api import DeadReferenceError, RemoteException

View File

@ -1,9 +1,3 @@
""" """
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401

View File

@ -2,11 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
(AVAILABLE, PENDING, OVERDUE, COMPLETE, CORRUPT, DEAD, BADSEGNUM) = \ (AVAILABLE, PENDING, OVERDUE, COMPLETE, CORRUPT, DEAD, BADSEGNUM) = \
("AVAILABLE", "PENDING", "OVERDUE", "COMPLETE", "CORRUPT", "DEAD", "BADSEGNUM") ("AVAILABLE", "PENDING", "OVERDUE", "COMPLETE", "CORRUPT", "DEAD", "BADSEGNUM")

View File

@ -2,11 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from twisted.python.failure import Failure from twisted.python.failure import Failure
from foolscap.api import eventually from foolscap.api import eventually
from allmydata.interfaces import NotEnoughSharesError, NoSharesError from allmydata.interfaces import NotEnoughSharesError, NoSharesError

View File

@ -2,9 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from six import ensure_str from six import ensure_str
import time import time

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import time import time
now = time.time now = time.time
from zope.interface import Interface from zope.interface import Interface

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import time import time
now = time.time now = time.time
from zope.interface import implementer from zope.interface import implementer

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import struct import struct
import time import time
now = time.time now = time.time

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import itertools import itertools
from zope.interface import implementer from zope.interface import implementer
from allmydata.interfaces import IDownloadStatus from allmydata.interfaces import IDownloadStatus

View File

@ -4,11 +4,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import time import time
from zope.interface import implementer from zope.interface import implementer
from twisted.internet import defer from twisted.internet import defer

View File

@ -2,11 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from functools import reduce from functools import reduce
import binascii import binascii
from time import time as now from time import time as now

View File

@ -5,11 +5,6 @@ on.
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
# We omit dict, just in case newdict breaks things for external Python 2 code.
from builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, list, object, range, str, max, min # noqa: F401
from queue import PriorityQueue from queue import PriorityQueue

View File

@ -2,11 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from io import BytesIO from io import BytesIO
from zope.interface import implementer from zope.interface import implementer

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import os, stat, time, weakref import os, stat, time, weakref
from zope.interface import implementer from zope.interface import implementer
from twisted.internet import defer from twisted.internet import defer

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from zope.interface import implementer from zope.interface import implementer
from twisted.internet import defer from twisted.internet import defer
from allmydata.storage.server import si_b2a from allmydata.storage.server import si_b2a

View File

@ -7,10 +7,6 @@ Note that for RemoteInterfaces, the __remote_name__ needs to be a native string
""" """
from future.utils import PY2, native_str from future.utils import PY2, native_str
if PY2:
# Don't import object/str/dict/etc. types, so we don't break any
# interfaces. Not importing open() because it triggers bogus flake8 error.
from builtins import filter, map, zip, ascii, chr, hex, input, next, oct, pow, round, super, range, max, min # noqa: F401
from past.builtins import long from past.builtins import long
from typing import Dict from typing import Dict

View File

@ -2,12 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from allmydata.introducer.server import create_introducer from allmydata.introducer.server import create_introducer
# apparently need to support "old .tac files" that may have # apparently need to support "old .tac files" that may have

View File

@ -2,9 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from past.builtins import long from past.builtins import long
from six import ensure_text, ensure_str from six import ensure_text, ensure_str

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import re import re
from foolscap.furl import decode_furl from foolscap.furl import decode_furl

View File

@ -4,9 +4,6 @@ Ported to Python 3.
from future.utils import PY2, native_str from future.utils import PY2, native_str
if PY2:
# Omitted types (bytes etc.) so future variants don't confuse Foolscap.
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, object, range, max, min # noqa: F401
from zope.interface import Interface from zope.interface import Interface
from foolscap.api import StringConstraint, SetOf, DictOf, Any, \ from foolscap.api import StringConstraint, SetOf, DictOf, Any, \

View File

@ -4,10 +4,6 @@ Manage status of long-running operations.
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from zope.interface import Interface, implementer from zope.interface import Interface, implementer
from allmydata.util import observer from allmydata.util import observer

View File

@ -2,9 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from six import ensure_str from six import ensure_str
from allmydata.uri import from_string from allmydata.uri import from_string

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
# Omit dict so Python 3 changes don't leak into API callers on Python 2.
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, list, object, range, str, max, min # noqa: F401
from past.utils import old_div from past.utils import old_div
import struct import struct

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import os, time import os, time
from io import BytesIO from io import BytesIO
from itertools import count from itertools import count

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from zope.interface import implementer from zope.interface import implementer
from twisted.internet import defer from twisted.internet import defer
from allmydata.interfaces import IRepairResults, ICheckResults from allmydata.interfaces import IRepairResults, ICheckResults

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from six import ensure_binary from six import ensure_binary
from twisted.python import usage from twisted.python import usage

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import os.path, sys, time, random, stat import os.path, sys, time, random, stat
from allmydata.util.netstring import netstring from allmydata.util.netstring import netstring

View File

@ -2,11 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import sys import sys
import six import six
from allmydata.util.assertutil import precondition from allmydata.util.assertutil import precondition

View File

@ -107,27 +107,6 @@ def parse_options(argv, config=None):
try: try:
config.parseOptions(argv) config.parseOptions(argv)
except usage.error as e: except usage.error as e:
if six.PY2:
# On Python 2 the exception may hold non-ascii in a byte string.
# This makes it impossible to convert the exception to any kind of
# string using str() or unicode(). It could also hold non-ascii
# in a unicode string which still makes it difficult to convert it
# to a byte string later.
#
# So, reach inside and turn it into some entirely safe ascii byte
# strings that will survive being written to stdout without
# causing too much damage in the process.
#
# As a result, non-ascii will not be rendered correctly but
# instead as escape sequences. At least this can go away when
# we're done with Python 2 support.
raise usage.error(*(
arg.encode("ascii", errors="backslashreplace")
if isinstance(arg, unicode)
else arg.decode("utf-8").encode("ascii", errors="backslashreplace")
for arg
in e.args
))
raise raise
return config return config

View File

@ -3,8 +3,6 @@ Ported to Python 3.
""" """
from future.utils import PY2, PY3 from future.utils import PY2, PY3
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from six import ensure_str from six import ensure_str

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import os.path import os.path
import codecs import codecs

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import os.path import os.path
import time import time
from urllib.parse import quote as url_quote from urllib.parse import quote as url_quote

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from six import ensure_str, ensure_text from six import ensure_str, ensure_text
from urllib.parse import quote as url_quote from urllib.parse import quote as url_quote

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import os.path import os.path
from urllib.parse import quote as url_quote from urllib.parse import quote as url_quote
from collections import defaultdict from collections import defaultdict

View File

@ -3,8 +3,6 @@ Ported to Python 3.
""" """
from future.utils import PY2, PY3 from future.utils import PY2, PY3
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from urllib.parse import quote as url_quote from urllib.parse import quote as url_quote
from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path, \ from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path, \

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from six import ensure_text from six import ensure_text
import time import time

View File

@ -3,8 +3,6 @@ Ported to Python 3.
""" """
from future.utils import PY2, PY3 from future.utils import PY2, PY3
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from six import ensure_str from six import ensure_str

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from urllib.parse import quote as url_quote from urllib.parse import quote as url_quote
from allmydata.scripts.common_http import do_http, check_http_error from allmydata.scripts.common_http import do_http, check_http_error
from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, UnknownAliasError from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, UnknownAliasError

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import re import re
from urllib.parse import quote as url_quote from urllib.parse import quote as url_quote
import json import json

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
__all__ = [ __all__ = [
"RunOptions", "RunOptions",
"run", "run",

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import os import os
from sys import stdout as _sys_stdout from sys import stdout as _sys_stdout
from urllib.parse import urlencode from urllib.parse import urlencode

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from urllib.parse import quote as url_quote from urllib.parse import quote as url_quote
from allmydata.scripts.common_http import do_http, format_http_success, format_http_error from allmydata.scripts.common_http import do_http, format_http_success, format_http_error
from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path, \ from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path, \

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from urllib.parse import quote as url_quote from urllib.parse import quote as url_quote
from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path, \ from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path, \

View File

@ -3,8 +3,6 @@ Ported to Python 3.
""" """
from future.utils import PY2, PY3 from future.utils import PY2, PY3
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import os.path import os.path
from allmydata.util import base32 from allmydata.util import base32

View File

@ -6,8 +6,6 @@ Ported to Python 3.
from future.utils import PY2, PY3 from future.utils import PY2, PY3
if PY2:
from builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import os import os
import time import time

View File

@ -1,7 +1,3 @@
from future.utils import PY2
if PY2:
from builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import json import json
import time import time
import os import os

View File

@ -4,8 +4,6 @@ Ported to Python 3.
from future.utils import PY2, bytes_to_native_str from future.utils import PY2, bytes_to_native_str
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import os, stat, struct, time import os, stat, struct, time

View File

@ -2,11 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import struct import struct
import attr import attr

View File

@ -2,11 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import struct, time import struct, time
import attr import attr

View File

@ -2,11 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import os, stat, struct import os, stat, struct
from allmydata.interfaces import ( from allmydata.interfaces import (

View File

@ -2,11 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import struct import struct
import attr import attr

View File

@ -2,11 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from allmydata.storage.mutable import MutableShareFile from allmydata.storage.mutable import MutableShareFile
from allmydata.storage.immutable import ShareFile from allmydata.storage.immutable import ShareFile

View File

@ -16,10 +16,6 @@ some side-effects which make things better when the test suite runs.
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from traceback import extract_stack, format_list from traceback import extract_stack, format_list
from foolscap.pb import Listener from foolscap.pb import Listener

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from six import ensure_str, ensure_text from six import ensure_str, ensure_text
from ...scripts import runner from ...scripts import runner

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
# We're going to override stdin/stderr, so want to match their behavior on respective Python versions. # We're going to override stdin/stderr, so want to match their behavior on respective Python versions.
from io import StringIO from io import StringIO

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import json import json
from twisted.trial import unittest from twisted.trial import unittest

View File

@ -3,8 +3,6 @@ Ported to Python 3.
""" """
from future.utils import PY2 from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import os.path import os.path
from six.moves import cStringIO as StringIO from six.moves import cStringIO as StringIO
@ -368,8 +366,6 @@ class Backup(GridTestMixin, CLITestMixin, StallMixin, unittest.TestCase):
nice_doc = u"nice_d\u00F8c.lyx" nice_doc = u"nice_d\u00F8c.lyx"
try: try:
doc_pattern_arg_unicode = doc_pattern_arg = u"*d\u00F8c*" doc_pattern_arg_unicode = doc_pattern_arg = u"*d\u00F8c*"
if PY2:
doc_pattern_arg = doc_pattern_arg.encode(get_io_encoding())
except UnicodeEncodeError: except UnicodeEncodeError:
raise unittest.SkipTest("A non-ASCII command argument could not be encoded on this platform.") raise unittest.SkipTest("A non-ASCII command argument could not be encoded on this platform.")

View File

@ -2,11 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
# Don't import future bytes so we don't break a couple of tests
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, dict, list, object, range, str, max, min # noqa: F401
import sys import sys
import os.path, time import os.path, time
from six.moves import cStringIO as StringIO from six.moves import cStringIO as StringIO

View File

@ -1,7 +1,3 @@
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from six import ensure_text from six import ensure_text
import os.path import os.path

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from six.moves import cStringIO as StringIO from six.moves import cStringIO as StringIO
import re import re
from six import ensure_text from six import ensure_text

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import os.path, json import os.path, json
from twisted.trial import unittest from twisted.trial import unittest
from twisted.python import usage from twisted.python import usage
@ -73,8 +69,6 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
self.failUnlessIn("files whose names could not be converted", err) self.failUnlessIn("files whose names could not be converted", err)
else: else:
self.failUnlessReallyEqual(rc, 0) self.failUnlessReallyEqual(rc, 0)
if PY2:
out = out.decode(get_io_encoding())
self.failUnlessReallyEqual(out, u"Metallica\n\u00C4rtonwall\n\u00C4rtonwall-2\n") self.failUnlessReallyEqual(out, u"Metallica\n\u00C4rtonwall\n\u00C4rtonwall-2\n")
self.assertEqual(len(err), 0, err) self.assertEqual(len(err), 0, err)
d.addCallback(_check) d.addCallback(_check)
@ -231,8 +225,6 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
self.failUnlessIn("files whose names could not be converted", err) self.failUnlessIn("files whose names could not be converted", err)
else: else:
self.failUnlessReallyEqual(rc, 0) self.failUnlessReallyEqual(rc, 0)
if PY2:
out = out.decode(get_io_encoding())
self.failUnlessReallyEqual(out, u"\u00C4rtonwall\n") self.failUnlessReallyEqual(out, u"\u00C4rtonwall\n")
self.assertEqual(len(err), 0, err) self.assertEqual(len(err), 0, err)
d.addCallback(_check) d.addCallback(_check)

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from six.moves import StringIO from six.moves import StringIO
import os.path import os.path
from twisted.trial import unittest from twisted.trial import unittest

View File

@ -3,8 +3,6 @@ Ported to Python 3.
""" """
from future.utils import PY2, PY3 from future.utils import PY2, PY3
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from six import ensure_str from six import ensure_str
from twisted.trial import unittest from twisted.trial import unittest

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import os.path import os.path
from twisted.trial import unittest from twisted.trial import unittest
from allmydata.util import fileutil from allmydata.util import fileutil

View File

@ -2,9 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from six import ensure_text from six import ensure_text
import os import os

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
__all__ = [ __all__ = [
"CLINodeAPI", "CLINodeAPI",
"Expect", "Expect",

View File

@ -1427,7 +1427,4 @@ class TrialTestCase(_TrialTestCase):
you try to turn that Exception instance into a string. you try to turn that Exception instance into a string.
""" """
if six.PY2:
if isinstance(msg, six.text_type):
return super(TrialTestCase, self).fail(msg.encode("utf8"))
return super(TrialTestCase, self).fail(msg) return super(TrialTestCase, self).fail(msg)

View File

@ -4,8 +4,6 @@ Ported to Python 3.
from future.utils import PY2, PY3, bchr, binary_type from future.utils import PY2, PY3, bchr, binary_type
from future.builtins import str as future_str from future.builtins import str as future_str
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, dict, list, object, range, str, max, min # noqa: F401
import os import os
import sys import sys

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from six import ensure_str from six import ensure_str
__all__ = [ __all__ = [

View File

@ -4,10 +4,6 @@ Testtools-style matchers useful to the Tahoe-LAFS test suite.
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import attr import attr
from hyperlink import DecodedURL from hyperlink import DecodedURL

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from ..common import AsyncTestCase from ..common import AsyncTestCase
from foolscap.api import flushEventualQueue from foolscap.api import flushEventualQueue
from allmydata.monitor import Monitor from allmydata.monitor import Monitor

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from ..common import SyncTestCase from ..common import SyncTestCase
from allmydata.mutable.publish import MutableData from allmydata.mutable.publish import MutableData
from testtools.matchers import Equals, HasLength from testtools.matchers import Equals, HasLength

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from ..common import AsyncTestCase from ..common import AsyncTestCase
from .util import FakeStorage, make_nodemaker from .util import FakeStorage, make_nodemaker

View File

@ -2,11 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from ..common import SyncTestCase from ..common import SyncTestCase
from allmydata.mutable.common import NeedMoreDataError, UncoordinatedWriteError from allmydata.mutable.common import NeedMoreDataError, UncoordinatedWriteError

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import os import os
from io import BytesIO from io import BytesIO
from ..common import SyncTestCase from ..common import SyncTestCase

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from six.moves import cStringIO as StringIO from six.moves import cStringIO as StringIO
from twisted.internet import defer, reactor from twisted.internet import defer, reactor
from ..common import AsyncBrokenTestCase from ..common import AsyncBrokenTestCase

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import os, base64 import os, base64
from ..common import AsyncTestCase from ..common import AsyncTestCase
from testtools.matchers import HasLength from testtools.matchers import HasLength

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from ..common import AsyncTestCase from ..common import AsyncTestCase
from testtools.matchers import Equals from testtools.matchers import Equals
from allmydata.interfaces import SDMF_VERSION from allmydata.interfaces import SDMF_VERSION

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from ..common import AsyncTestCase from ..common import AsyncTestCase
from testtools.matchers import Equals, HasLength from testtools.matchers import Equals, HasLength
from allmydata.monitor import Monitor from allmydata.monitor import Monitor

View File

@ -2,10 +2,6 @@
Ported to Python 3. Ported to Python 3.
""" """
from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
import os, base64 import os, base64
from ..common import AsyncTestCase from ..common import AsyncTestCase
from testtools.matchers import HasLength from testtools.matchers import HasLength

Some files were not shown because too many files have changed in this diff Show More