Skip to content

Commit

Permalink
Merge pull request #1359 from a-detiste/remove-future
Browse files Browse the repository at this point in the history
more python2 removal

Fixes ticket:4092
  • Loading branch information
itamarst committed Feb 27, 2024
2 parents a23a97d + 3fb0bcf commit dcf8570
Show file tree
Hide file tree
Showing 193 changed files with 15 additions and 1,059 deletions.
3 changes: 0 additions & 3 deletions docs/conf.py
Expand Up @@ -12,9 +12,6 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys
import os

# 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
# documentation root, use os.path.abspath to make it absolute, like shown here.
Expand Down
5 changes: 0 additions & 5 deletions integration/test_aaa_aardvark.py
Expand Up @@ -6,11 +6,6 @@
# 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):
print("Created flog_gatherer")

Expand Down
5 changes: 0 additions & 5 deletions integration/test_sftp.py
Expand Up @@ -10,11 +10,6 @@
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
from posixpath import join
from stat import S_ISDIR
Expand Down
4 changes: 0 additions & 4 deletions integration/test_streaming_logs.py
Expand Up @@ -2,10 +2,6 @@
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

import json
Expand Down
6 changes: 0 additions & 6 deletions misc/simulators/sizes.py
@@ -1,11 +1,5 @@
#! /usr/bin/env python


from future.utils import PY2
if PY2:
from future.builtins import input


import random, math, re
from twisted.python import usage

Expand Down
Empty file added newsfragments/4092.minor
Empty file.
5 changes: 0 additions & 5 deletions src/allmydata/__main__.py
Expand Up @@ -2,11 +2,6 @@
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

from allmydata.scripts.runner import run
Expand Down
28 changes: 0 additions & 28 deletions src/allmydata/_monkeypatch.py
Expand Up @@ -4,41 +4,13 @@
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 warnings import catch_warnings


def patch():
"""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:
# Python 3 doesn't need to monkey patch Foolscap
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
4 changes: 0 additions & 4 deletions src/allmydata/blacklist.py
Expand Up @@ -2,10 +2,6 @@
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

from zope.interface import implementer
Expand Down
4 changes: 0 additions & 4 deletions src/allmydata/check_results.py
@@ -1,10 +1,6 @@
"""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 zope.interface import implementer
Expand Down
4 changes: 0 additions & 4 deletions src/allmydata/codec.py
Expand Up @@ -4,10 +4,6 @@
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 allmydata.util import mathutil
from allmydata.util.assertutil import precondition
Expand Down
4 changes: 0 additions & 4 deletions src/allmydata/crypto/__init__.py
Expand Up @@ -9,7 +9,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
4 changes: 0 additions & 4 deletions src/allmydata/crypto/aes.py
Expand Up @@ -10,10 +10,6 @@
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

from cryptography.hazmat.backends import default_backend
Expand Down
5 changes: 0 additions & 5 deletions src/allmydata/crypto/error.py
Expand Up @@ -4,11 +4,6 @@
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):
"""
An alleged signature did not match
Expand Down
4 changes: 0 additions & 4 deletions src/allmydata/crypto/util.py
Expand Up @@ -4,10 +4,6 @@
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


Expand Down
4 changes: 0 additions & 4 deletions src/allmydata/deep_stats.py
Expand Up @@ -3,10 +3,6 @@
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

from allmydata.interfaces import IImmutableFileNode
Expand Down
4 changes: 0 additions & 4 deletions src/allmydata/dirnode.py
Expand Up @@ -3,10 +3,6 @@
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

import time
Expand Down
4 changes: 0 additions & 4 deletions src/allmydata/frontends/auth.py
Expand Up @@ -2,10 +2,6 @@
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 twisted.internet import defer
from twisted.cred import checkers, credentials
Expand Down
4 changes: 0 additions & 4 deletions src/allmydata/frontends/sftpd.py
Expand Up @@ -2,10 +2,6 @@
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 heapq, traceback, stat, struct
from stat import S_IFREG, S_IFDIR
Expand Down
5 changes: 0 additions & 5 deletions src/allmydata/hashtree.py
Expand Up @@ -49,11 +49,6 @@
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 base32
Expand Down
5 changes: 0 additions & 5 deletions src/allmydata/history.py
@@ -1,11 +1,6 @@
"""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

class History(object):
Expand Down
4 changes: 0 additions & 4 deletions src/allmydata/immutable/checker.py
Expand Up @@ -2,10 +2,6 @@
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 twisted.internet import defer
from foolscap.api import DeadReferenceError, RemoteException
Expand Down
6 changes: 0 additions & 6 deletions src/allmydata/immutable/downloader/__init__.py
@@ -1,9 +1,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

5 changes: 0 additions & 5 deletions src/allmydata/immutable/downloader/common.py
Expand Up @@ -2,11 +2,6 @@
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")

Expand Down
5 changes: 0 additions & 5 deletions src/allmydata/immutable/downloader/fetcher.py
Expand Up @@ -2,11 +2,6 @@
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 foolscap.api import eventually
from allmydata.interfaces import NotEnoughSharesError, NoSharesError
Expand Down
3 changes: 0 additions & 3 deletions src/allmydata/immutable/downloader/finder.py
Expand Up @@ -2,9 +2,6 @@
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

import time
Expand Down
4 changes: 0 additions & 4 deletions src/allmydata/immutable/downloader/node.py
Expand Up @@ -2,10 +2,6 @@
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
now = time.time
from zope.interface import Interface
Expand Down
4 changes: 0 additions & 4 deletions src/allmydata/immutable/downloader/segmentation.py
Expand Up @@ -2,10 +2,6 @@
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
now = time.time
from zope.interface import implementer
Expand Down
4 changes: 0 additions & 4 deletions src/allmydata/immutable/downloader/share.py
Expand Up @@ -2,10 +2,6 @@
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 time
now = time.time
Expand Down
4 changes: 0 additions & 4 deletions src/allmydata/immutable/downloader/status.py
Expand Up @@ -2,10 +2,6 @@
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
from zope.interface import implementer
from allmydata.interfaces import IDownloadStatus
Expand Down
5 changes: 0 additions & 5 deletions src/allmydata/immutable/encode.py
Expand Up @@ -4,11 +4,6 @@
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
from zope.interface import implementer
from twisted.internet import defer
Expand Down
5 changes: 0 additions & 5 deletions src/allmydata/immutable/filenode.py
Expand Up @@ -2,11 +2,6 @@
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
import binascii
from time import time as now
Expand Down
5 changes: 0 additions & 5 deletions src/allmydata/immutable/happiness_upload.py
Expand Up @@ -5,11 +5,6 @@
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


Expand Down

0 comments on commit dcf8570

Please sign in to comment.