Skip to content

Commit d805e25

Browse files
committed
removing tiny remaining bits of Python2 hybridation
1 parent 686d770 commit d805e25

File tree

3 files changed

+12
-42
lines changed

3 files changed

+12
-42
lines changed

kazoo/protocol/connection.py

Lines changed: 4 additions & 12 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,9 @@
7574

7675
CLOSE_RESPONSE = Close.type
7776

78-
if sys.version_info > (3,): # pragma: nocover
79-
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()
77+
# removed from Python3+
78+
def buffer(obj, offset=0):
79+
return memoryview(obj)[offset:]
8880

8981

9082
class RWPinger(object):
@@ -526,7 +518,7 @@ def _send_ping(self, connect_timeout):
526518

527519
# Determine if we need to check for a r/w server
528520
if self._ro_mode:
529-
result = advance_iterator(self._ro_mode)
521+
result = next(self._ro_mode)
530522
if result:
531523
self._rw_server = result
532524
raise RWServerAvailable()

kazoo/tests/test_client.py

Lines changed: 7 additions & 18 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,16 +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-
4332

4433
class TestClientTransitions(KazooTestCase):
4534
@staticmethod
@@ -197,8 +186,8 @@ def test_connect_auth(self):
197186
client.close()
198187

199188
def test_unicode_auth(self):
200-
username = u(r"xe4/\hm")
201-
password = u(r"/\xe4hm")
189+
username = r"xe4/\hm"
190+
password = r"/\xe4hm"
202191
digest_auth = "%s:%s" % (username, password)
203192
acl = self._makeAuth(username, password, all=True)
204193

@@ -543,10 +532,10 @@ def test_create_empty_string(self):
543532

544533
def test_create_unicode_path(self):
545534
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")
535+
path = client.create("/ascii")
536+
assert path == "/ascii"
537+
path = client.create("/\xe4hm")
538+
assert path == "/\xe4hm"
550539

551540
def test_create_async_returns_unchrooted_path(self):
552541
client = self.client
@@ -593,7 +582,7 @@ def test_create_value(self):
593582
def test_create_unicode_value(self):
594583
client = self.client
595584
with pytest.raises(TypeError):
596-
client.create("/1", u("\xe4hm"))
585+
client.create("/1", "\xe4hm")
597586

598587
def test_create_large_value(self):
599588
client = self.client

kazoo/tests/test_paths.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +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-
198

209
class NormPathTestCase(TestCase):
2110
def test_normpath(self):
@@ -25,7 +14,7 @@ def test_normpath_empty(self):
2514
assert paths.normpath("") == ""
2615

2716
def test_normpath_unicode(self):
28-
assert paths.normpath(u("/\xe4/b")) == u("/\xe4/b")
17+
assert paths.normpath("/\xe4/b") == "/\xe4/b"
2918

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

0 commit comments

Comments
 (0)