summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHervé Beraud <hberaud@redhat.com>2020-03-02 15:54:14 +0100
committerHervé Beraud <hberaud@redhat.com>2020-03-12 09:28:33 +0100
commit55ef517065b63e20534bfccd22585a52d1f0f9f1 (patch)
tree3a8c715c567cf8f297efba2017787e3650f4150d
parent26abff6f5499a256ce9221e5512b8499d3e46e6f (diff)
downloadoslo-log-55ef517065b63e20534bfccd22585a52d1f0f9f1.tar.gz
drop use of six
Change-Id: I0ad972f48ee6bc331b96aa67bd7e69c97fa8e2c3
-rw-r--r--lower-constraints.txt1
-rw-r--r--oslo_log/cmds/convert_json.py5
-rw-r--r--oslo_log/formatters.py48
-rw-r--r--oslo_log/handlers.py25
-rw-r--r--oslo_log/log.py7
-rw-r--r--oslo_log/tests/unit/test_convert_json.py4
-rw-r--r--oslo_log/tests/unit/test_log.py103
-rw-r--r--oslo_log/tests/unit/test_rate_limit.py4
-rw-r--r--oslo_log/tests/unit/test_versionutils.py24
-rw-r--r--oslo_log/versionutils.py7
-rw-r--r--requirements.txt1
11 files changed, 75 insertions, 154 deletions
diff --git a/lower-constraints.txt b/lower-constraints.txt
index c7ca21f..3ac8087 100644
--- a/lower-constraints.txt
+++ b/lower-constraints.txt
@@ -54,7 +54,6 @@ reno==2.7.0
requests==2.18.4
requestsexceptions==1.4.0
rfc3986==1.1.0
-six==1.11.0
smmap2==2.0.3
snowballstemmer==1.2.1
Sphinx==1.8.0
diff --git a/oslo_log/cmds/convert_json.py b/oslo_log/cmds/convert_json.py
index ef914d1..466289b 100644
--- a/oslo_log/cmds/convert_json.py
+++ b/oslo_log/cmds/convert_json.py
@@ -21,7 +21,6 @@ import time
from oslo_serialization import jsonutils
from oslo_utils import importutils
-import six
from oslo_log import log
@@ -180,8 +179,8 @@ def console_format(prefix, locator, record, loggers=[], levels=[],
# Thrown when a non-string format-specifier can't be filled in.
# Dict comprehension cleans up the output
yield warn('Missing non-string placeholder in record',
- {str(k): str(v) if isinstance(v, six.string_types) else v
- for k, v in six.iteritems(record)})
+ {str(k): str(v) if isinstance(v, str) else v
+ for k, v in record.items()})
return
locator = ''
diff --git a/oslo_log/formatters.py b/oslo_log/formatters.py
index e37561f..8ca3f7e 100644
--- a/oslo_log/formatters.py
+++ b/oslo_log/formatters.py
@@ -13,6 +13,7 @@
import datetime
import debtcollector
import functools
+import io
import itertools
import logging
import logging.config
@@ -23,16 +24,11 @@ import sys
import traceback
from dateutil import tz
-import six
-from six import moves
from oslo_context import context as context_utils
from oslo_serialization import jsonutils
from oslo_utils import encodeutils
-if six.PY3:
- from functools import reduce
-
def _dictify_context(context):
if getattr(context, 'get_logging_values', None):
@@ -85,10 +81,10 @@ def _update_record_with_context(record):
def _ensure_unicode(msg):
"""Do our best to turn the input argument into a unicode object.
"""
- if isinstance(msg, six.text_type):
+ if isinstance(msg, str):
return msg
- if not isinstance(msg, six.binary_type):
- return six.text_type(msg)
+ if not isinstance(msg, bytes):
+ return str(msg)
return encodeutils.safe_decode(
msg,
incoming='utf-8',
@@ -157,7 +153,7 @@ def _get_error_summary(record):
error_summary = error_summary.split('\n', 1)[0]
except TypeError as type_err:
# Work around https://bugs.python.org/issue28603
- error_summary = "<exception with %s>" % six.text_type(type_err)
+ error_summary = "<exception with %s>" % str(type_err)
finally:
# Remove the local reference to the exception and
# traceback to avoid a memory leak through the frame
@@ -201,10 +197,10 @@ class JSONFormatter(logging.Formatter):
lines = traceback.format_exception(*ei)
except TypeError as type_error:
# Work around https://bugs.python.org/issue28603
- msg = six.text_type(type_error)
+ msg = str(type_error)
lines = ['<Unprintable exception due to %s>\n' % msg]
if strip_newlines:
- lines = [moves.filter(
+ lines = [filter(
lambda x: x,
line.rstrip().splitlines()) for line in lines]
lines = list(itertools.chain(*lines))
@@ -300,11 +296,12 @@ class FluentFormatter(logging.Formatter):
lines = traceback.format_exception(*exc_info)
except TypeError as type_error:
# Work around https://bugs.python.org/issue28603
- msg = six.text_type(type_error)
+ msg = str(type_error)
lines = ['<Unprintable exception due to %s>\n' % msg]
if strip_newlines:
- lines = reduce(lambda a, line: a + line.rstrip().splitlines(),
- lines, [])
+ lines = functools.reduce(lambda a,
+ line: a + line.rstrip().splitlines(),
+ lines, [])
return lines
def format(self, record):
@@ -345,8 +342,7 @@ class FluentFormatter(logging.Formatter):
message['context'] = {}
extra.pop('context', None)
# NOTE(vdrok): try to dump complex objects
- primitive_types = six.string_types + six.integer_types + (
- bool, type(None), float, list, dict)
+ primitive_types = (str, int, bool, type(None), float, list, dict)
for key, value in extra.items():
if not isinstance(value, primitive_types):
extra[key] = _json_dumps_with_fallback(value)
@@ -399,20 +395,6 @@ class ContextFormatter(logging.Formatter):
def format(self, record):
"""Uses contextstring if request_id is set, otherwise default."""
- if six.PY2:
- should_use_unicode = True
- args = (record.args.values() if isinstance(record.args, dict)
- else record.args)
- for arg in args or []:
- try:
- six.text_type(arg)
- except UnicodeDecodeError:
- should_use_unicode = False
- break
- if (not isinstance(record.msg, six.text_type)
- and should_use_unicode):
- record.msg = _ensure_unicode(record.msg)
-
# store project info
record.project = self.project
record.version = self.version
@@ -523,16 +505,16 @@ class ContextFormatter(logging.Formatter):
return logging.Formatter.formatException(self, exc_info)
except TypeError as type_error:
# Work around https://bugs.python.org/issue28603
- msg = six.text_type(type_error)
+ msg = str(type_error)
return '<Unprintable exception due to %s>\n' % msg
- stringbuffer = moves.StringIO()
+ stringbuffer = io.StringIO()
try:
traceback.print_exception(exc_info[0], exc_info[1], exc_info[2],
None, stringbuffer)
except TypeError as type_error:
# Work around https://bugs.python.org/issue28603
- msg = six.text_type(type_error)
+ msg = str(type_error)
stringbuffer.write('<Unprintable exception due to %s>\n' % msg)
lines = stringbuffer.getvalue().split('\n')
diff --git a/oslo_log/handlers.py b/oslo_log/handlers.py
index d602842..00ce64c 100644
--- a/oslo_log/handlers.py
+++ b/oslo_log/handlers.py
@@ -16,7 +16,6 @@ import logging
import logging.config
import logging.handlers
import os
-import six
try:
from systemd import journal
@@ -26,7 +25,6 @@ try:
import syslog
except ImportError:
syslog = None
-from oslo_utils import encodeutils
NullHandler = logging.NullHandler
@@ -71,29 +69,6 @@ class OSSysLogHandler(logging.Handler):
def emit(self, record):
priority = SYSLOG_MAP.get(record.levelname, 7)
message = self.format(record)
-
- # NOTE(gangila): In python2, the syslog function takes in 's' as
- # the format argument, which means it either accepts python string
- # (str = 'a') or unicode strings (str = u'a'), the PyArg_ParseTuple
- # then if needed converts the unicode objects to C strings using
- # the *default encoding*. This default encoding is 'ascii' in case
- # of python2 while it has been changed to 'utf-8' in case of
- # python3. What this leads to is when we supply a syslog message
- # like:
- # >>> syslog.syslog(syslog.LOG_DEBUG, u"François Deppierraz")
- # In case of python2 the above fails with TypeError: [priority,]
- # message string. Because python2 doesn't explicitly encode as
- # 'utf-8' and use the system default encoding ascii, which raises
- # a UnicodeEncodeError (UnicodeEncodeError: 'ascii' codec can't
- # encode character u'\xe7' in position 4: ordinal not in
- # range(128)), and hence the error message that's set in the code
- # (TypeError: [priority,] message string) gets shown to the user.
- # However, this in the case of Python3, where the system default
- # encoding is 'utf-8' works without any issues. Therefore, we need
- # to safe_encode in case of python2 and not in case of Python3.
- if six.PY2:
- message = encodeutils.safe_encode(self.format(record))
-
syslog.syslog(priority, message)
diff --git a/oslo_log/log.py b/oslo_log/log.py
index 479c4a8..1a61ce1 100644
--- a/oslo_log/log.py
+++ b/oslo_log/log.py
@@ -27,6 +27,7 @@ It also allows setting of formatting information through conf.
"""
+import configparser
import logging
import logging.config
import logging.handlers
@@ -41,8 +42,6 @@ except ImportError:
from oslo_config import cfg
from oslo_utils import importutils
from oslo_utils import units
-import six
-from six import moves
from oslo_log._i18n import _
from oslo_log import _options
@@ -232,8 +231,8 @@ def _load_log_config(log_config_append):
logging.config.fileConfig(log_config_append,
disable_existing_loggers=False)
_load_log_config.old_time = new_time
- except (moves.configparser.Error, KeyError, os.error) as exc:
- raise LogConfigError(log_config_append, six.text_type(exc))
+ except (configparser.Error, KeyError, os.error) as exc:
+ raise LogConfigError(log_config_append, str(exc))
def _mutate_hook(conf, fresh):
diff --git a/oslo_log/tests/unit/test_convert_json.py b/oslo_log/tests/unit/test_convert_json.py
index 3026393..5a48279 100644
--- a/oslo_log/tests/unit/test_convert_json.py
+++ b/oslo_log/tests/unit/test_convert_json.py
@@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-import six
+import io
from oslo_log.cmds import convert_json
from oslo_serialization import jsonutils
@@ -45,7 +45,7 @@ class ConvertJsonTestCase(test_base.BaseTestCase):
super(ConvertJsonTestCase, self).setUp()
def _reformat(self, text):
- fh = six.StringIO(text)
+ fh = io.StringIO(text)
return list(convert_json.reformat_json(fh, lambda x: [x]))
def test_reformat_json_single(self):
diff --git a/oslo_log/tests/unit/test_log.py b/oslo_log/tests/unit/test_log.py
index cb74fb5..6db3032 100644
--- a/oslo_log/tests/unit/test_log.py
+++ b/oslo_log/tests/unit/test_log.py
@@ -19,6 +19,7 @@
from contextlib import contextmanager
import copy
import datetime
+import io
import logging
import os
import platform
@@ -40,7 +41,6 @@ from oslo_context import fixture as fixture_context
from oslo_i18n import fixture as fixture_trans
from oslo_serialization import jsonutils
from oslotest import base as test_base
-import six
import testtools
from oslo_log import _options
@@ -251,7 +251,7 @@ class LogTestBase(BaseTestCase):
:param formatter: The formatter class to set on the handler. Must be
the class itself, not an instance.
"""
- self.stream = six.StringIO()
+ self.stream = io.StringIO()
if handler is None:
handler = logging.StreamHandler
self.handler = handler(self.stream)
@@ -364,17 +364,12 @@ class OSSysLogHandlerTestCase(BaseTestCase):
def test_syslog(self):
msg_unicode = u"Benoît Knecht & François Deppierraz login failure"
- msg_utf8 = msg_unicode.encode('utf-8')
-
handler = handlers.OSSysLogHandler()
syslog.syslog = mock.Mock()
handler.emit(
logging.LogRecord("name", logging.INFO, "path", 123,
msg_unicode, None, None))
- if six.PY2:
- syslog.syslog.assert_called_once_with(syslog.LOG_INFO, msg_utf8)
- else:
- syslog.syslog.assert_called_once_with(syslog.LOG_INFO, msg_unicode)
+ syslog.syslog.assert_called_once_with(syslog.LOG_INFO, msg_unicode)
class OSJournalHandlerTestCase(BaseTestCase):
@@ -412,13 +407,13 @@ class OSJournalHandlerTestCase(BaseTestCase):
self.journal.send.call_args)
args, kwargs = self.journal.send.call_args
self.assertEqual(len(args), 1)
- self.assertIsInstance(args[0], six.string_types)
+ self.assertIsInstance(args[0], str)
self.assertIsInstance(kwargs['CODE_LINE'], int)
self.assertIsInstance(kwargs['PRIORITY'], int)
del kwargs['CODE_LINE'], kwargs['PRIORITY']
for key, arg in kwargs.items():
- self.assertIsInstance(key, six.string_types)
- self.assertIsInstance(arg, six.string_types + (six.binary_type,))
+ self.assertIsInstance(key, str)
+ self.assertIsInstance(arg, (bytes, str))
def test_emit_exception(self):
l = log.getLogger('nova-exception.foo')
@@ -443,13 +438,13 @@ class OSJournalHandlerTestCase(BaseTestCase):
self.journal.send.call_args)
args, kwargs = self.journal.send.call_args
self.assertEqual(len(args), 1)
- self.assertIsInstance(args[0], six.string_types)
+ self.assertIsInstance(args[0], str)
self.assertIsInstance(kwargs['CODE_LINE'], int)
self.assertIsInstance(kwargs['PRIORITY'], int)
del kwargs['CODE_LINE'], kwargs['PRIORITY']
for key, arg in kwargs.items():
- self.assertIsInstance(key, six.string_types)
- self.assertIsInstance(arg, six.string_types + (six.binary_type,))
+ self.assertIsInstance(key, str)
+ self.assertIsInstance(arg, (bytes, str))
class LogLevelTestCase(BaseTestCase):
@@ -610,15 +605,14 @@ class JSONFormatterTestCase(LogTestBase):
def test_can_process_strings(self):
expected = b'\\u2622'
- if six.PY3:
- # see ContextFormatterTestCase.test_can_process_strings
- expected = '\\\\xe2\\\\x98\\\\xa2'
+ # see ContextFormatterTestCase.test_can_process_strings
+ expected = '\\\\xe2\\\\x98\\\\xa2'
self.log.info(b'%s', u'\u2622'.encode('utf8'))
self.assertIn(expected, self.stream.getvalue())
def test_exception(self):
ctxt = _fake_context()
- ctxt.request_id = six.text_type('99')
+ ctxt.request_id = str('99')
try:
raise RuntimeError('test_exception')
except RuntimeError:
@@ -630,7 +624,7 @@ class JSONFormatterTestCase(LogTestBase):
def test_no_exception(self):
ctxt = _fake_context()
- ctxt.request_id = six.text_type('99')
+ ctxt.request_id = str('99')
self.log.info('testing', context=ctxt)
data = jsonutils.loads(self.stream.getvalue())
self.assertIn('error_summary', data)
@@ -638,7 +632,7 @@ class JSONFormatterTestCase(LogTestBase):
def test_exception_without_exc_info_passed(self):
ctxt = _fake_context()
- ctxt.request_id = six.text_type('99')
+ ctxt.request_id = str('99')
try:
raise RuntimeError('test_exception\ntraceback\nfrom\nremote error')
except RuntimeError:
@@ -649,7 +643,7 @@ class JSONFormatterTestCase(LogTestBase):
def test_exception_with_exc_info_passed(self):
ctxt = _fake_context()
- ctxt.request_id = six.text_type('99')
+ ctxt.request_id = str('99')
try:
raise RuntimeError('test_exception\ntraceback\nfrom\nremote error')
except RuntimeError:
@@ -836,14 +830,14 @@ class ContextFormatterTestCase(LogTestBase):
def test_message_logging_3rd_party_log_records(self):
ctxt = _fake_context()
- ctxt.request_id = six.text_type('99')
+ ctxt.request_id = str('99')
sa_log = logging.getLogger('sqlalchemy.engine')
sa_log.setLevel(logging.INFO)
- message = self.trans_fixture.lazy('test ' + six.unichr(128))
+ message = self.trans_fixture.lazy('test ' + chr(128))
sa_log.info(message)
expected = ('HAS CONTEXT [%s]: %s\n' % (ctxt.request_id,
- six.text_type(message)))
+ str(message)))
self.assertEqual(expected, self.stream.getvalue())
def test_debugging_log(self):
@@ -858,11 +852,11 @@ class ContextFormatterTestCase(LogTestBase):
# the Message object, with a wrong encoding. This test case
# tests that problem does not occur.
ctxt = _fake_context()
- ctxt.request_id = six.text_type('99')
- message = self.trans_fixture.lazy('test ' + six.unichr(128))
+ ctxt.request_id = str('99')
+ message = self.trans_fixture.lazy('test ' + chr(128))
self.log.info(message, context=ctxt)
expected = "HAS CONTEXT [%s]: %s\n" % (ctxt.request_id,
- six.text_type(message))
+ str(message))
self.assertEqual(expected, self.stream.getvalue())
def test_exception_logging(self):
@@ -870,8 +864,8 @@ class ContextFormatterTestCase(LogTestBase):
# does not appear in the format string, ensure that it is
# appended to the end of the log lines.
ctxt = _fake_context()
- ctxt.request_id = six.text_type('99')
- message = self.trans_fixture.lazy('test ' + six.unichr(128))
+ ctxt.request_id = str('99')
+ message = self.trans_fixture.lazy('test ' + chr(128))
try:
raise RuntimeError('test_exception_logging')
except RuntimeError:
@@ -883,8 +877,8 @@ class ContextFormatterTestCase(LogTestBase):
# NOTE(dhellmann): Several of the built-in exception types
# should not be automatically added to the log output.
ctxt = _fake_context()
- ctxt.request_id = six.text_type('99')
- message = self.trans_fixture.lazy('test ' + six.unichr(128))
+ ctxt.request_id = str('99')
+ message = self.trans_fixture.lazy('test ' + chr(128))
ignored_exceptions = [
ValueError, TypeError, KeyError, AttributeError, ImportError
]
@@ -902,8 +896,8 @@ class ContextFormatterTestCase(LogTestBase):
# that position in the output.
self.config(logging_context_format_string="A %(error_summary)s B")
ctxt = _fake_context()
- ctxt.request_id = six.text_type('99')
- message = self.trans_fixture.lazy('test ' + six.unichr(128))
+ ctxt.request_id = str('99')
+ message = self.trans_fixture.lazy('test ' + chr(128))
try:
raise RuntimeError('test_exception_logging')
except RuntimeError:
@@ -917,32 +911,32 @@ class ContextFormatterTestCase(LogTestBase):
# inserted.
self.config(logging_context_format_string="%(error_summary)s")
ctxt = _fake_context()
- ctxt.request_id = six.text_type('99')
- message = self.trans_fixture.lazy('test ' + six.unichr(128))
+ ctxt.request_id = str('99')
+ message = self.trans_fixture.lazy('test ' + chr(128))
self.log.info(message, context=ctxt)
expected = '-\n'
self.assertTrue(self.stream.getvalue().startswith(expected))
def test_unicode_conversion_in_adapter(self):
ctxt = _fake_context()
- ctxt.request_id = six.text_type('99')
+ ctxt.request_id = str('99')
message = "Exception is (%s)"
- ex = Exception(self.trans_fixture.lazy('test' + six.unichr(128)))
+ ex = Exception(self.trans_fixture.lazy('test' + chr(128)))
self.log.debug(message, ex, context=ctxt)
- message = six.text_type(message) % ex
+ message = str(message) % ex
expected = "HAS CONTEXT [%s]: %s --DBG\n" % (ctxt.request_id,
message)
self.assertEqual(expected, self.stream.getvalue())
def test_unicode_conversion_in_formatter(self):
ctxt = _fake_context()
- ctxt.request_id = six.text_type('99')
+ ctxt.request_id = str('99')
no_adapt_log = logging.getLogger('no_adapt')
no_adapt_log.setLevel(logging.INFO)
message = "Exception is (%s)"
- ex = Exception(self.trans_fixture.lazy('test' + six.unichr(128)))
+ ex = Exception(self.trans_fixture.lazy('test' + chr(128)))
no_adapt_log.info(message, ex)
- message = six.text_type(message) % ex
+ message = str(message) % ex
expected = "HAS CONTEXT [%s]: %s\n" % (ctxt.request_id,
message)
self.assertEqual(expected, self.stream.getvalue())
@@ -959,7 +953,7 @@ class ContextFormatterTestCase(LogTestBase):
expected = ("HAS CONTEXT [%s %s %s %s %s %s]: %s\n" %
(ctxt.request_id, ctxt.user, ctxt.tenant, ctxt.domain,
ctxt.user_domain, ctxt.project_domain,
- six.text_type(message)))
+ str(message)))
self.assertEqual(expected, self.stream.getvalue())
def test_user_identity_logging_set_format(self):
@@ -975,7 +969,7 @@ class ContextFormatterTestCase(LogTestBase):
self.log.info(message, context=ctxt)
expected = ("HAS CONTEXT [%s %s %s]: %s\n" %
(ctxt.request_id, ctxt.user, ctxt.tenant,
- six.text_type(message)))
+ str(message)))
self.assertEqual(expected, self.stream.getvalue())
@mock.patch("datetime.datetime",
@@ -1009,11 +1003,10 @@ class ContextFormatterTestCase(LogTestBase):
def test_can_process_strings(self):
expected = b'\xe2\x98\xa2'
- if six.PY3:
- # in PY3 logging format string should be unicode string
- # or it will fail and inserting byte string in unicode string
- # causes such formatting
- expected = '\\xe2\\x98\\xa2'
+ # logging format string should be unicode string
+ # or it will fail and inserting byte string in unicode string
+ # causes such formatting
+ expected = '\\xe2\\x98\\xa2'
self.log.info(b'%s', u'\u2622'.encode('utf8'))
self.assertIn(expected, self.stream.getvalue())
@@ -1101,7 +1094,7 @@ class FancyRecordTestCase(LogTestBase):
# and goes to stderr. Suggests on a better way to do this are
# welcomed.
error = sys.stderr
- sys.stderr = six.StringIO()
+ sys.stderr = io.StringIO()
self.colorlog.info("foo")
self.assertNotEqual(-1,
@@ -1608,7 +1601,7 @@ keys=
root = logging.getLogger()
self.assertEqual(1, len(root.handlers))
handler = root.handlers[0]
- handler.stream = six.StringIO()
+ handler.stream = io.StringIO()
return handler.stream
def test_remove_handler(self):
@@ -1634,7 +1627,7 @@ keys=
'loggers': {'a.a': fake_logger}}
conf2 = {'root': {'handlers': 'fake'},
'handlers': {'fake': fake_handler}}
- stream = six.StringIO()
+ stream = io.StringIO()
with self.mutate_conf(conf1, conf2) as (loginis, confs):
stream = self.set_root_stream()
log = logging.getLogger("a.a")
@@ -1653,7 +1646,7 @@ class LogConfigOptsTestCase(BaseTestCase):
super(LogConfigOptsTestCase, self).setUp()
def test_print_help(self):
- f = six.StringIO()
+ f = io.StringIO()
self.CONF([])
self.CONF.print_help(file=f)
for option in ['debug', 'log-config', 'watch-log-file']:
@@ -1920,20 +1913,20 @@ class UnicodeConversionTestCase(BaseTestCase):
enc_msg = msg.encode('utf-8')
result = formatters._ensure_unicode(enc_msg)
self.assertEqual(msg, result)
- self.assertIsInstance(result, six.text_type)
+ self.assertIsInstance(result, str)
def test_unicode_to_unicode(self):
msg = self._MSG
result = formatters._ensure_unicode(msg)
self.assertEqual(msg, result)
- self.assertIsInstance(result, six.text_type)
+ self.assertIsInstance(result, str)
def test_exception_to_unicode(self):
msg = self._MSG
exc = Exception(msg)
result = formatters._ensure_unicode(exc)
self.assertEqual(msg, result)
- self.assertIsInstance(result, six.text_type)
+ self.assertIsInstance(result, str)
class LoggerNameTestCase(LoggerTestCase):
diff --git a/oslo_log/tests/unit/test_rate_limit.py b/oslo_log/tests/unit/test_rate_limit.py
index a81baa2..000ac3f 100644
--- a/oslo_log/tests/unit/test_rate_limit.py
+++ b/oslo_log/tests/unit/test_rate_limit.py
@@ -12,11 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+import io
import logging
import mock
from oslotest import base as test_base
-import six
from oslo_log import rate_limit
@@ -41,7 +41,7 @@ class LogRateLimitTestCase(test_base.BaseTestCase):
logger.removeHandler(handler)
# install our handler writing logs into a StringIO
- stream = six.StringIO()
+ stream = io.StringIO()
handler = logging.StreamHandler(stream)
logger.addHandler(handler)
diff --git a/oslo_log/tests/unit/test_versionutils.py b/oslo_log/tests/unit/test_versionutils.py
index 23ee8d4..4de91c7 100644
--- a/oslo_log/tests/unit/test_versionutils.py
+++ b/oslo_log/tests/unit/test_versionutils.py
@@ -13,11 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-import unittest
-
import mock
from oslotest import base as test_base
-import six
from testtools import matchers
from oslo_log import versionutils
@@ -248,27 +245,6 @@ class DeprecatedTestCase(test_base.BaseTestCase):
as_of='Juno',
remove_in='Kilo')
- @unittest.skipIf(
- six.PY3,
- 'Deprecated exception detection does not work for Python 3')
- @mock.patch('oslo_log.versionutils.report_deprecated_feature')
- def test_deprecated_exception(self, mock_log):
- @versionutils.deprecated(as_of=versionutils.deprecated.ICEHOUSE,
- remove_in=+1)
- class OldException(Exception):
- pass
-
- class NewException(OldException):
- pass
-
- try:
- raise NewException()
- except OldException:
- pass
-
- self.assert_deprecated(mock_log, what='OldException()',
- as_of='Icehouse', remove_in='Juno')
-
@mock.patch('oslo_log.versionutils.report_deprecated_feature')
def test_deprecated_exception_old(self, mock_log):
@versionutils.deprecated(as_of=versionutils.deprecated.ICEHOUSE,
diff --git a/oslo_log/versionutils.py b/oslo_log/versionutils.py
index 4b6dcd9..2b45a67 100644
--- a/oslo_log/versionutils.py
+++ b/oslo_log/versionutils.py
@@ -22,7 +22,6 @@ import inspect
import logging
from oslo_config import cfg
-import six
from oslo_log._i18n import _
@@ -180,7 +179,7 @@ class deprecated(object):
if inspect.isfunction(func_or_cls):
- @six.wraps(func_or_cls)
+ @functools.wraps(func_or_cls)
def wrapped(*args, **kwargs):
report_deprecated()
return func_or_cls(*args, **kwargs)
@@ -188,7 +187,7 @@ class deprecated(object):
elif inspect.isclass(func_or_cls):
orig_init = func_or_cls.__init__
- @six.wraps(orig_init, assigned=('__name__', '__doc__'))
+ @functools.wraps(orig_init, assigned=('__name__', '__doc__'))
def new_init(self, *args, **kwargs):
if self.__class__ in _DEPRECATED_EXCEPTIONS:
report_deprecated()
@@ -213,7 +212,7 @@ class deprecated(object):
report_deprecated()
return super(ExceptionMeta,
self).__subclasscheck__(subclass)
- func_or_cls = six.add_metaclass(ExceptionMeta)(func_or_cls)
+ func_or_cls.__meta__ = ExceptionMeta
_DEPRECATED_EXCEPTIONS.add(func_or_cls)
return func_or_cls
diff --git a/requirements.txt b/requirements.txt
index a25e739..963a95e 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,7 +3,6 @@
# process, which may cause wedges in the gate later.
pbr>=3.1.1 # Apache-2.0
-six>=1.11.0 # MIT
oslo.config>=5.2.0 # Apache-2.0
oslo.context>=2.20.0 # Apache-2.0
oslo.i18n>=3.20.0 # Apache-2.0