Skip to content

Commit 0751174

Browse files
authored
removing tiny remaining bits of Python2 hybridation (#763)
* removing tiny remaining bits of Python2 hybridation * please the hound * please flake8
1 parent 686d770 commit 0751174

File tree

3 files changed

+12
-43
lines changed

3 files changed

+12
-43
lines changed

kazoo/protocol/connection.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import select
88
import socket
99
import ssl
10-
import sys
1110
import time
1211

1312
from kazoo.exceptions import (
@@ -75,16 +74,10 @@
7574

7675
CLOSE_RESPONSE = Close.type
7776

78-
if sys.version_info > (3,): # pragma: nocover
7977

80-
def buffer(obj, offset=0):
81-
return memoryview(obj)[offset:]
82-
83-
advance_iterator = next
84-
else: # pragma: nocover
85-
86-
def advance_iterator(it):
87-
return it.next()
78+
# removed from Python3+
79+
def buffer(obj, offset=0):
80+
return memoryview(obj)[offset:]
8881

8982

9083
class RWPinger(object):
@@ -526,7 +519,7 @@ def _send_ping(self, connect_timeout):
526519

527520
# Determine if we need to check for a r/w server
528521
if self._ro_mode:
529-
result = advance_iterator(self._ro_mode)
522+
result = next(self._ro_mode)
530523
if result:
531524
self._rw_server = result
532525
raise RWServerAvailable()

kazoo/tests/test_client.py

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import os
22
import socket
3-
import sys
43
import tempfile
54
import threading
65
import time
@@ -30,17 +29,6 @@
3029
from kazoo.tests.util import CI_ZK_VERSION
3130

3231

33-
if sys.version_info > (3,): # pragma: nocover
34-
35-
def u(s):
36-
return s
37-
38-
else: # pragma: nocover
39-
40-
def u(s):
41-
return unicode(s, "unicode_escape") # noqa
42-
43-
4432
class TestClientTransitions(KazooTestCase):
4533
@staticmethod
4634
def make_event():
@@ -197,8 +185,8 @@ def test_connect_auth(self):
197185
client.close()
198186

199187
def test_unicode_auth(self):
200-
username = u(r"xe4/\hm")
201-
password = u(r"/\xe4hm")
188+
username = r"xe4/\hm"
189+
password = r"/\xe4hm"
202190
digest_auth = "%s:%s" % (username, password)
203191
acl = self._makeAuth(username, password, all=True)
204192

@@ -543,10 +531,10 @@ def test_create_empty_string(self):
543531

544532
def test_create_unicode_path(self):
545533
client = self.client
546-
path = client.create(u("/ascii"))
547-
assert path == u("/ascii")
548-
path = client.create(u("/\xe4hm"))
549-
assert path == u("/\xe4hm")
534+
path = client.create("/ascii")
535+
assert path == "/ascii"
536+
path = client.create("/\xe4hm")
537+
assert path == "/\xe4hm"
550538

551539
def test_create_async_returns_unchrooted_path(self):
552540
client = self.client
@@ -593,7 +581,7 @@ def test_create_value(self):
593581
def test_create_unicode_value(self):
594582
client = self.client
595583
with pytest.raises(TypeError):
596-
client.create("/1", u("\xe4hm"))
584+
client.create("/1", "\xe4hm")
597585

598586
def test_create_large_value(self):
599587
client = self.client

kazoo/tests/test_paths.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
1-
import sys
21
from unittest import TestCase
32

43
import pytest
54

65
from kazoo.protocol import paths
76

87

9-
if sys.version_info > (3,): # pragma: nocover
10-
11-
def u(s):
12-
return s
13-
14-
else: # pragma: nocover
15-
16-
def u(s):
17-
return unicode(s, "unicode_escape") # noqa
18-
19-
208
class NormPathTestCase(TestCase):
219
def test_normpath(self):
2210
assert paths.normpath("/a/b") == "/a/b"
@@ -25,7 +13,7 @@ def test_normpath_empty(self):
2513
assert paths.normpath("") == ""
2614

2715
def test_normpath_unicode(self):
28-
assert paths.normpath(u("/\xe4/b")) == u("/\xe4/b")
16+
assert paths.normpath("/\xe4/b") == "/\xe4/b"
2917

3018
def test_normpath_dots(self):
3119
assert paths.normpath("/a./b../c") == "/a./b../c"

0 commit comments

Comments
 (0)