From b79f8b30eb195b3d0d915191db1811079564dab5 Mon Sep 17 00:00:00 2001 From: joo Date: Mon, 17 Aug 2020 06:41:06 +0200 Subject: [PATCH] Remove support for Python 2.7 --- .travis.yml | 2 -- README.rst | 2 -- minecraft/compat.py | 24 ------------------------ minecraft/networking/connection.py | 10 ++++------ minecraft/networking/types/basic.py | 1 - minecraft/networking/types/utility.py | 2 -- requirements.txt | 1 - start.py | 3 --- tests/compat.py | 7 ------- tests/fake_server.py | 6 ++---- tests/test_authentication.py | 4 ++-- tests/test_connection.py | 3 +-- tox.ini | 7 +------ 13 files changed, 10 insertions(+), 62 deletions(-) delete mode 100644 minecraft/compat.py delete mode 100644 tests/compat.py diff --git a/.travis.yml b/.travis.yml index 687d02c..e5f09fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,6 @@ python: 3.8 matrix: include: - - python: 2.7 - env: TOX_ENV=py27 - python: pypy env: TOX_ENV=pypy - python: 3.5 diff --git a/README.rst b/README.rst index e47bb54..520b42c 100644 --- a/README.rst +++ b/README.rst @@ -50,7 +50,6 @@ Supported Python versions ------------------------- pyCraft is compatible with (at least) the following Python implementations: -* Python 2.7 * Python 3.5 * Python 3.6 * Python 3.7 @@ -61,7 +60,6 @@ Requirements ------------ - `cryptography `_ - `requests `_ -- `future `_ The requirements are also stored in ``requirements.txt`` diff --git a/minecraft/compat.py b/minecraft/compat.py deleted file mode 100644 index b44c8f9..0000000 --- a/minecraft/compat.py +++ /dev/null @@ -1,24 +0,0 @@ -""" -This module stores code used for making pyCraft compatible with -both Python2 and Python3 while using the same codebase. -""" - -# Raw input -> input shenangians -# example -# > from minecraft.compat import input -# > input("asd") - -# Hi, I'm pylint, and sometimes I act silly, at which point my programmer -# overlords need to correct me. - -# pylint: disable=undefined-variable,redefined-builtin,invalid-name -try: - input = raw_input -except NameError: - input = input - -try: - unicode = unicode -except NameError: - unicode = str -# pylint: enable=undefined-variable,redefined-builtin,invalid-name diff --git a/minecraft/networking/connection.py b/minecraft/networking/connection.py index d61db97..5c6d76a 100644 --- a/minecraft/networking/connection.py +++ b/minecraft/networking/connection.py @@ -1,5 +1,3 @@ -from __future__ import print_function - from collections import deque from threading import RLock import zlib @@ -11,8 +9,6 @@ import sys import json import re -from future.utils import raise_ - from .types import VarInt from .packets import clientbound, serverbound from . import packets @@ -491,7 +487,8 @@ class Connection(object): # If allowed by the final exception handler, re-raise the exception. if self.handle_exception is None and not caught: - raise_(*exc_info) + exc_value, exc_tb = exc_info[1:] + raise exc_value.with_traceback(exc_tb) def _version_mismatch(self, server_protocol=None, server_version=None): if server_protocol is None: @@ -592,7 +589,8 @@ class NetworkingThread(threading.Thread): exc_info = None if exc_info is not None: - raise_(*exc_info) + exc_value, exc_tb = exc_info[1:] + raise exc_value.with_traceback(exc_tb) class PacketReactor(object): diff --git a/minecraft/networking/types/basic.py b/minecraft/networking/types/basic.py index 4ccf627..e91db13 100644 --- a/minecraft/networking/types/basic.py +++ b/minecraft/networking/types/basic.py @@ -2,7 +2,6 @@ Each type has a method which is used to read and write it. These definitions and methods are used by the packet definitions """ -from __future__ import division import struct import uuid diff --git a/minecraft/networking/types/utility.py b/minecraft/networking/types/utility.py index 2916437..0103cc4 100644 --- a/minecraft/networking/types/utility.py +++ b/minecraft/networking/types/utility.py @@ -1,8 +1,6 @@ """Minecraft data types that are used by packets, but don't have a specific network representation. """ -from __future__ import division - from collections import namedtuple from itertools import chain diff --git a/requirements.txt b/requirements.txt index 0f1d0b1..27732d2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,2 @@ cryptography>=1.5 requests -future diff --git a/start.py b/start.py index 2b019d5..353a158 100755 --- a/start.py +++ b/start.py @@ -1,7 +1,5 @@ #!/usr/bin/env python -from __future__ import print_function - import getpass import sys import re @@ -11,7 +9,6 @@ from minecraft import authentication from minecraft.exceptions import YggdrasilError from minecraft.networking.connection import Connection from minecraft.networking.packets import Packet, clientbound, serverbound -from minecraft.compat import input def get_options(): diff --git a/tests/compat.py b/tests/compat.py deleted file mode 100644 index ffaa534..0000000 --- a/tests/compat.py +++ /dev/null @@ -1,7 +0,0 @@ -import platform -from distutils.version import StrictVersion - -if StrictVersion(platform.python_version()) < StrictVersion("3.3.0"): - import mock # noqa -else: - from unittest import mock # noqa diff --git a/tests/fake_server.py b/tests/fake_server.py index ead9e9e..788fdd0 100644 --- a/tests/fake_server.py +++ b/tests/fake_server.py @@ -1,5 +1,3 @@ -from __future__ import print_function - from minecraft import SUPPORTED_MINECRAFT_VERSIONS from minecraft.networking import connection from minecraft.networking import types @@ -11,7 +9,6 @@ from minecraft.networking.encryption import ( ) from cryptography.hazmat.primitives.asymmetric.padding import PKCS1v15 -from future.utils import raise_ from numbers import Integral import unittest @@ -576,7 +573,8 @@ class _FakeServerTest(unittest.TestCase): logging.error(**error) self.fail('Multiple errors: see logging output.') elif errors and 'exc_info' in errors[0]: - raise_(*errors[0]['exc_info']) + exc_value, exc_tb = errors[0]['exc_info'][1:] + raise exc_value.with_traceback(exc_tb) elif errors: self.fail(errors[0]['msg']) diff --git a/tests/test_authentication.py b/tests/test_authentication.py index c028aa6..460f779 100644 --- a/tests/test_authentication.py +++ b/tests/test_authentication.py @@ -4,11 +4,11 @@ from minecraft.authentication import _make_request from minecraft.authentication import _raise_from_response from minecraft.exceptions import YggdrasilError +from unittest import mock +import unittest import requests import json -import unittest import os -from .compat import mock FAKE_DATA = { "id_": "85e2c12b9eab4a7dabf61babc11354c2", diff --git a/tests/test_connection.py b/tests/test_connection.py index 59b5bea..1f52f29 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -5,7 +5,6 @@ from minecraft.networking.connection import Connection from minecraft.exceptions import ( VersionMismatch, LoginDisconnect, InvalidState, IgnorePacket ) -from minecraft.compat import unicode from . import fake_server @@ -92,7 +91,7 @@ class DefaultStatusTest(ConnectTest): def setUp(self): class FakeStdOut(io.BytesIO): def write(self, data): - if isinstance(data, unicode): + if isinstance(data, str): data = data.encode('utf8') super(FakeStdOut, self).write(data) sys.stdout, self.old_stdout = FakeStdOut(), sys.stdout diff --git a/tox.ini b/tox.ini index 5b67f02..a465d4b 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ # and then run "tox" from this directory. [tox] -envlist = py27, py35, py36, py37, py38, pypy, flake8, pylint-errors, pylint-full, verify-manifest +envlist = py35, py36, py37, py38, pypy, flake8, pylint-errors, pylint-full, verify-manifest [testenv] commands = nosetests --with-timer @@ -27,11 +27,6 @@ commands = deps = coveralls -[testenv:py27] -deps = - {[testenv]deps} - mock - [testenv:py38] setenv = PYCRAFT_RUN_INTERNET_TESTS=1