Skip to content

Commit

Permalink
Remove support for end-of-life Python 2.7 (#1318)
Browse files Browse the repository at this point in the history
Remove support for end-of-life Python 2.7

Python 2.7 is end of life. It is no longer receiving bug fixes,
including for security issues. Python 2.7 went EOL on 2020-01-01. For
additional details on support Python versions, see:

Supported: https://devguide.python.org/#status-of-python-branches
EOL: https://devguide.python.org/devcycle/#end-of-life-branches

Removing support for EOL Pythons will reduce testing and maintenance
resources while allowing the library to move towards a modern Python 3
style. Python 2.7 users can continue to use the previous version of
redis-py.

Was able to simplify the code:

- Removed redis._compat module
- Removed __future__ imports
- Removed object from class definition (all classes are new style)
- Removed long (Python 3 unified numeric types)
- Removed deprecated __nonzero__ method
- Use simpler Python 3 super() syntax
- Use unified OSError exception
- Use yield from syntax

Co-authored-by: Andy McCurdy <andy@andymccurdy.com>
  • Loading branch information
jdufresne and andymccurdy committed Aug 6, 2020
1 parent c6f13c3 commit 8c5a41b
Show file tree
Hide file tree
Showing 27 changed files with 378 additions and 654 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
@@ -1,3 +1,5 @@
**/__pycache__
**/*.pyc
.tox
.coverage
.coverage.*
1 change: 1 addition & 0 deletions CHANGES
@@ -1,4 +1,5 @@
* (in development)
* Removed support for end of life Python 2.7.
* Provide a development and testing environment via docker. Thanks
@abrookins. #1365
* Added support for the LPOS command available in Redis 6.0.6. Thanks
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Expand Up @@ -87,7 +87,7 @@ provide an upgrade path for users migrating from 2.X to 3.0.
Python Version Support
^^^^^^^^^^^^^^^^^^^^^^

redis-py 3.0 supports Python 2.7 and Python 3.5+.
redis-py supports Python 3.5+.


Client Classes: Redis and StrictRedis
Expand Down
5 changes: 2 additions & 3 deletions benchmarks/base.py
Expand Up @@ -3,10 +3,9 @@
import redis
import sys
import timeit
from redis._compat import izip


class Benchmark(object):
class Benchmark:
ARGUMENTS = ()

def __init__(self):
Expand Down Expand Up @@ -34,7 +33,7 @@ def run_benchmark(self):
group_names = [group['name'] for group in self.ARGUMENTS]
group_values = [group['values'] for group in self.ARGUMENTS]
for value_set in itertools.product(*group_values):
pairs = list(izip(group_names, value_set))
pairs = list(zip(group_names, value_set))
arg_string = ', '.join(['%s=%s' % (p[0], p[1]) for p in pairs])
sys.stdout.write('Benchmark: %s... ' % arg_string)
sys.stdout.flush()
Expand Down
12 changes: 3 additions & 9 deletions benchmarks/basic_operations.py
@@ -1,13 +1,8 @@
from __future__ import print_function
import redis
import time
import sys
from functools import wraps
from argparse import ArgumentParser

if sys.version_info[0] == 3:
long = int


def parse_args():
parser = ArgumentParser()
Expand Down Expand Up @@ -47,17 +42,17 @@ def run():
def timer(func):
@wraps(func)
def wrapper(*args, **kwargs):
start = time.clock()
start = time.monotonic()
ret = func(*args, **kwargs)
duration = time.clock() - start
duration = time.monotonic() - start
if 'num' in kwargs:
count = kwargs['num']
else:
count = args[1]
print('{} - {} Requests'.format(func.__name__, count))
print('Duration = {}'.format(duration))
print('Rate = {}'.format(count/duration))
print('')
print()
return ret
return wrapper

Expand Down Expand Up @@ -185,7 +180,6 @@ def hmset(conn, num, pipeline_size, data_size):

set_data = {'str_value': 'string',
'int_value': 123456,
'long_value': long(123456),
'float_value': 123456.0}
for i in range(num):
conn.hmset('hmset_key', set_data)
Expand Down
5 changes: 2 additions & 3 deletions benchmarks/command_packer_benchmark.py
@@ -1,7 +1,6 @@
import socket
from redis.connection import (Connection, SYM_STAR, SYM_DOLLAR, SYM_EMPTY,
SYM_CRLF)
from redis._compat import imap
from base import Benchmark


Expand Down Expand Up @@ -29,7 +28,7 @@ def pack_command(self, *args):
args_output = SYM_EMPTY.join([
SYM_EMPTY.join(
(SYM_DOLLAR, str(len(k)).encode(), SYM_CRLF, k, SYM_CRLF))
for k in imap(self.encoder.encode, args)])
for k in map(self.encoder.encode, args)])
output = SYM_EMPTY.join(
(SYM_STAR, str(len(args)).encode(), SYM_CRLF, args_output))
return output
Expand Down Expand Up @@ -61,7 +60,7 @@ def pack_command(self, *args):
buff = SYM_EMPTY.join(
(SYM_STAR, str(len(args)).encode(), SYM_CRLF))

for k in imap(self.encoder.encode, args):
for k in map(self.encoder.encode, args):
if len(buff) > 6000 or len(k) > 6000:
buff = SYM_EMPTY.join(
(buff, SYM_DOLLAR, str(len(k)).encode(), SYM_CRLF))
Expand Down
26 changes: 12 additions & 14 deletions docs/conf.py
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
#
# redis-py documentation build configuration file, created by
# sphinx-quickstart on Fri Feb 8 00:47:08 2013.
#
Expand Down Expand Up @@ -43,8 +41,8 @@
master_doc = 'index'

# General information about the project.
project = u'redis-py'
copyright = u'2016, Andy McCurdy'
project = 'redis-py'
copyright = '2016, Andy McCurdy'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -188,8 +186,8 @@
# (source start file, target name, title, author, documentclass
# [howto/manual]).
latex_documents = [
('index', 'redis-py.tex', u'redis-py Documentation',
u'Andy McCurdy', 'manual'),
('index', 'redis-py.tex', 'redis-py Documentation',
'Andy McCurdy', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -218,8 +216,8 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'redis-py', u'redis-py Documentation',
[u'Andy McCurdy'], 1)
('index', 'redis-py', 'redis-py Documentation',
['Andy McCurdy'], 1)
]

# If true, show URL addresses after external links.
Expand All @@ -232,8 +230,8 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'redis-py', u'redis-py Documentation',
u'Andy McCurdy', 'redis-py',
('index', 'redis-py', 'redis-py Documentation',
'Andy McCurdy', 'redis-py',
'One line description of project.', 'Miscellaneous'),
]

Expand All @@ -246,7 +244,7 @@
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'

epub_title = u'redis-py'
epub_author = u'Andy McCurdy'
epub_publisher = u'Andy McCurdy'
epub_copyright = u'2011, Andy McCurdy'
epub_title = 'redis-py'
epub_author = 'Andy McCurdy'
epub_publisher = 'Andy McCurdy'
epub_copyright = '2011, Andy McCurdy'
188 changes: 0 additions & 188 deletions redis/_compat.py

This file was deleted.

0 comments on commit 8c5a41b

Please sign in to comment.