Skip to content

Commit

Permalink
Merge pull request #240 from liampauling/task/remove-py2
Browse files Browse the repository at this point in the history
remove py2 creation of NullHandler
  • Loading branch information
liampauling committed Oct 14, 2019
2 parents 648256e + 99b61c4 commit 413d124
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 55 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ language: python
sudo: false

python:
- "2.7"
- "3.5"
- "3.6"
# Enable 3.7 without globally enabling sudo and dist: xenial for other build jobs
Expand Down
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Release History
**Dependencies**

- ciso8601 upgraded from 2.0.1 to 2.1.1
- python 3 only

1.10.3 (2019-09-30)
+++++++++++++++++++
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Lightweight, super fast (uses c libraries) pythonic wrapper for [Betfair API-NG]

[Join slack group](https://betfairlightweight.herokuapp.com)

Currently tested on Python 2.7, 3.5, 3.6 and 3.7.
Currently tested on Python 3.5, 3.6 and 3.7.

# installation

Expand Down
3 changes: 0 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ build: off

environment:
matrix:
- PYTHON: "C:\\Python27"
PYTHON_VERSION: "2.7.x"

- PYTHON: "C:\\Python35"
PYTHON_VERSION: "3.5.x"

Expand Down
9 changes: 1 addition & 8 deletions betfairlightweight/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,4 @@
__author__ = 'Liam Pauling'

# Set default logging handler to avoid "No handler found" warnings.
try: # Python 2.7+
from logging import NullHandler
except ImportError:
class NullHandler(logging.Handler):
def emit(self, record):
pass

logging.getLogger(__name__).addHandler(NullHandler())
logging.getLogger(__name__).addHandler(logging.NullHandler())
3 changes: 0 additions & 3 deletions betfairlightweight/baseclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
AppKeyError,
CertsError,
)
from .compat import FileNotFoundError


class BaseClient(object):
Expand Down Expand Up @@ -140,8 +139,6 @@ def cert(self):
cert_path = os.listdir(ssl_path)
except FileNotFoundError:
raise CertsError(certs)
except OSError: # Python 2 compatability
raise CertsError(certs)

cert = None
key = None
Expand Down
28 changes: 3 additions & 25 deletions betfairlightweight/compat.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,8 @@
import sys
import datetime

_ver = sys.version_info

#: Python 2.x?
is_py2 = (_ver[0] == 2)

#: Python 3.x?
is_py3 = (_ver[0] == 3)


try:
from builtins import FileNotFoundError
except ImportError:
class FileNotFoundError(OSError):
pass


if is_py2:
basestring = basestring
numeric_types = (int, long, float)
integer_types = (int, long)
elif is_py3:
basestring = (str, bytes)
numeric_types = (int, float)
integer_types = (int,)
basestring = (str, bytes)
numeric_types = (int, float)
integer_types = (int,)

# will attempt to use c libraries if installed

Expand Down
10 changes: 2 additions & 8 deletions betfairlightweight/streaming/betfairstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
SocketError,
ListenerError,
)
from ..compat import (
is_py3,
json,
)
from ..compat import json


class BetfairStream(object):
Expand Down Expand Up @@ -202,10 +199,7 @@ def _receive_all(self):
till CRLF is detected.
"""
(data, part) = ('', '')
if is_py3:
crlf_bytes = bytes(self.__CRLF, encoding=self.__encoding)
else:
crlf_bytes = self.__CRLF
crlf_bytes = bytes(self.__CRLF, encoding=self.__encoding)

while self._running and part[-2:] != crlf_bytes:
try:
Expand Down
6 changes: 0 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
with open(os.path.join(os.path.dirname(__file__), 'requirements.txt')) as f:
INSTALL_REQUIRES = f.read().splitlines()

if sys.version_info < (3, 4):
INSTALL_REQUIRES.extend([
'enum34',
])

TESTS_REQUIRE = [
'mock==2.0.0'
]
Expand Down Expand Up @@ -46,7 +41,6 @@
classifiers=[
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
Expand Down

0 comments on commit 413d124

Please sign in to comment.