Remove support for Python 2.7

This commit is contained in:
joo 2020-08-17 06:41:06 +02:00
parent 3723655fa3
commit b79f8b30eb
13 changed files with 10 additions and 62 deletions

View File

@ -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

View File

@ -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 <https://github.com/pyca/cryptography#cryptography>`_
- `requests <http://docs.python-requests.org/en/latest/>`_
- `future <http://python-future.org/>`_
The requirements are also stored in ``requirements.txt``

View File

@ -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

View File

@ -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):

View File

@ -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

View File

@ -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

View File

@ -1,3 +1,2 @@
cryptography>=1.5
requests
future

View File

@ -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():

View File

@ -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

View File

@ -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'])

View File

@ -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",

View File

@ -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

View File

@ -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