Skip to content

Commit d6689e3

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Remove six.byte2int/int2byte"
2 parents 6898cf2 + f6d74ea commit d6689e3

File tree

8 files changed

+14
-17
lines changed

8 files changed

+14
-17
lines changed

nova/api/validation/parameter_types.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
import re
2121
import unicodedata
2222

23-
import six
24-
2523
from nova.i18n import _
2624
from nova.objects import tag
2725

@@ -94,7 +92,7 @@ def _is_printable(char):
9492

9593
def _get_all_chars():
9694
for i in range(0xFFFF):
97-
yield six.unichr(i)
95+
yield chr(i)
9896

9997

10098
# build a regex that matches all printable characters. This allows

nova/cmd/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def validate_args(fn, *args, **kwargs):
7171
num_defaults = len(argspec.defaults or [])
7272
required_args = argspec.args[:len(argspec.args) - num_defaults]
7373

74-
if six.get_method_self(fn) is not None:
74+
if fn.__self__ is not None:
7575
required_args.pop(0)
7676

7777
missing = [arg for arg in required_args if arg not in kwargs]

nova/compute/api.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def check_instance_state(vm_state=None, task_state=(None,),
130130
task_state = set(task_state)
131131

132132
def outer(f):
133-
@six.wraps(f)
133+
@functools.wraps(f)
134134
def inner(self, context, instance, *args, **kw):
135135
if vm_state is not None and instance.vm_state not in vm_state:
136136
raise exception.InstanceInvalidState(
@@ -170,7 +170,7 @@ def reject_instance_state(vm_state=None, task_state=None):
170170
task_state = _set_or_none(task_state)
171171

172172
def outer(f):
173-
@six.wraps(f)
173+
@functools.wraps(f)
174174
def inner(self, context, instance, *args, **kw):
175175
_InstanceInvalidState = functools.partial(
176176
exception.InstanceInvalidState,
@@ -202,7 +202,7 @@ def check_instance_host(check_is_up=False):
202202
compute service status is not UP or MAINTENANCE
203203
"""
204204
def outer(function):
205-
@six.wraps(function)
205+
@functools.wraps(function)
206206
def wrapped(self, context, instance, *args, **kwargs):
207207
if not instance.host:
208208
raise exception.InstanceNotReady(instance_id=instance.uuid)
@@ -221,7 +221,7 @@ def wrapped(self, context, instance, *args, **kwargs):
221221

222222

223223
def check_instance_lock(function):
224-
@six.wraps(function)
224+
@functools.wraps(function)
225225
def inner(self, context, instance, *args, **kwargs):
226226
if instance.locked and not context.is_admin:
227227
raise exception.InstanceIsLocked(instance_uuid=instance.uuid)

nova/compute/manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6663,7 +6663,7 @@ def get_console_output(self, context, instance, tail_length):
66636663
output = self.driver.get_console_output(context, instance)
66646664

66656665
if type(output) is six.text_type:
6666-
output = six.b(output)
6666+
output = output.encode("latin-1")
66676667

66686668
if tail_length is not None:
66696669
output = self._tail_log(output, tail_length)

nova/console/securityproxy/rfb.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def recv(sock, num):
123123
raise exception.SecurityProxyNegotiationFailed(reason=reason)
124124

125125
# Negotiate security with server
126-
permitted_auth_types_cnt = six.byte2int(recv(compute_sock, 1))
126+
permitted_auth_types_cnt = recv(compute_sock, 1)[0]
127127

128128
if permitted_auth_types_cnt == 0:
129129
# Decode the reason why the request failed
@@ -148,8 +148,8 @@ def recv(sock, num):
148148
# Negotiate security with client before we say "ok" to the server
149149
# send 1:[None]
150150
tenant_sock.sendall(auth.AUTH_STATUS_PASS +
151-
six.int2byte(auth.AuthType.NONE))
152-
client_auth = six.byte2int(recv(tenant_sock, 1))
151+
bytes((auth.AuthType.NONE,)))
152+
client_auth = recv(tenant_sock, 1)[0]
153153

154154
if client_auth != auth.AuthType.NONE:
155155
self._fail(tenant_sock, compute_sock,
@@ -172,7 +172,7 @@ def recv(sock, num):
172172
raise exception.SecurityProxyNegotiationFailed(
173173
reason=_("No compute auth available: %s") % six.text_type(e))
174174

175-
compute_sock.sendall(six.int2byte(scheme.security_type()))
175+
compute_sock.sendall(bytes((scheme.security_type(),)))
176176

177177
LOG.debug("Using security type %d with server, None with client",
178178
scheme.security_type())

nova/tests/functional/api_sample_tests/test_servers.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
from oslo_utils import fixture as utils_fixture
2020
from oslo_utils import timeutils
21-
import six
2221

2322
from nova.api.openstack import api_version_request as avr
2423
import nova.conf
@@ -33,7 +32,7 @@ class ServersSampleBase(api_sample_base.ApiSampleTestBaseV21):
3332
microversion = None
3433
sample_dir = 'servers'
3534

36-
user_data_contents = six.b('#!/bin/bash\n/bin/su\necho "I am in you!"\n')
35+
user_data_contents = b'#!/bin/bash\n/bin/su\necho "I am in you!"\n'
3736
user_data = base64.b64encode(user_data_contents)
3837

3938
common_req_names = [

nova/tests/unit/test_api_validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def test_build_regex_range(self):
8080
# about. The algorithm works for all ranges.
8181
def _get_all_chars():
8282
for i in range(0x7F):
83-
yield six.unichr(i)
83+
yield chr(i)
8484

8585
self.useFixture(fixtures.MonkeyPatch(
8686
'nova.api.validation.parameter_types._get_all_chars',

nova/tests/unit/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ def test_exception_converted(self):
585585
max_value=54)
586586
self.assertRaises(exception.InvalidInput,
587587
utils.validate_integer,
588-
six.unichr(129), "UnicodeError",
588+
chr(129), "UnicodeError",
589589
max_value=1000)
590590

591591

0 commit comments

Comments
 (0)