Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove remaining six usage #1648

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ init-import=no

# List of qualified module names which can have objects that can redefine
# builtins.
redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io
redefining-builtins-modules=builtins,io


[FORMAT]
Expand Down
3 changes: 1 addition & 2 deletions pyocd/commands/execution_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import sys
from typing import (Any, Callable, cast, Dict, IO, Iterator, List, NamedTuple, Optional, Sequence,
TYPE_CHECKING)
import six
import pprint
import subprocess
from shutil import get_terminal_size
Expand Down Expand Up @@ -493,6 +492,6 @@ def handle_system(self, invocation: CommandInvocation) -> None:
"""@brief Evaluate a system call command."""
try:
output = subprocess.check_output(invocation.cmd, stderr=subprocess.STDOUT, shell=True)
self.write(six.ensure_str(output), end='')
self.write(str(output), end='')
except subprocess.CalledProcessError as err:
raise exceptions.CommandError(str(err)) from err
3 changes: 1 addition & 2 deletions pyocd/probe/jlink_probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import six
import logging
from time import sleep
import pylink
Expand Down Expand Up @@ -128,7 +127,7 @@ def __init__(self, serial_number):
self._protocol = None
self._default_protocol = None
self._is_open = False
self._product_name = six.ensure_str(info.acProduct)
self._product_name = str(info.acProduct)
self._memory_interfaces = {}

@property
Expand Down
3 changes: 1 addition & 2 deletions pyocd/probe/pydapaccess/interface/hidapi_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import logging
import platform
import six
import threading
import queue
from typing import Optional
Expand Down Expand Up @@ -63,7 +62,7 @@ def __init__(self, dev, info: dict):
self.vendor_name = info['manufacturer_string'] or f"{self.vid:#06x}"
self.product_name = info['product_string'] or f"{self.pid:#06x}"
self.serial_number = info['serial_number'] \
or generate_device_unique_id(self.vid, self.pid, six.ensure_str(info['path']))
or generate_device_unique_id(self.vid, self.pid, str(info['path']))
self.device_info = info
self.device = dev
self.closed = True
Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ install_requires =
pylink-square>=1.0,<2.0
pyusb>=1.2.1,<2.0
pyyaml>=6.0,<7.0
six>=1.15.0,<2.0
typing-extensions>=4.0,<5.0

[options.extras_require]
Expand Down
2 changes: 0 additions & 2 deletions test/basic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function

import argparse
import os
import sys
Expand Down
2 changes: 0 additions & 2 deletions test/blank_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function

import os
import sys
from time import sleep
Expand Down
2 changes: 0 additions & 2 deletions test/commands_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function

import argparse
import sys
import traceback
Expand Down
2 changes: 0 additions & 2 deletions test/concurrency_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function

import argparse
import os
import sys
Expand Down
2 changes: 0 additions & 2 deletions test/connect_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function

import os
import sys
import traceback
Expand Down
2 changes: 0 additions & 2 deletions test/cortex_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function

import argparse
import os
import sys
Expand Down
2 changes: 0 additions & 2 deletions test/debug_context_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function

import argparse
import os
import sys
Expand Down
2 changes: 0 additions & 2 deletions test/flash_loader_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function

import argparse
import os
import sys
Expand Down
2 changes: 0 additions & 2 deletions test/flash_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function

import argparse
import os
import sys
Expand Down
1 change: 0 additions & 1 deletion test/gdb_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function

# Note
# To run this script GNU Tools ARM Embedded must be installed,
Expand Down
1 change: 0 additions & 1 deletion test/gdb_test_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function

# Notes about this script
# 1. This script runs inside arm-none-eabi-gdb-py
Expand Down
2 changes: 0 additions & 2 deletions test/json_lists_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function

import argparse, os, sys
from time import sleep, time
from random import randrange
Expand Down
2 changes: 0 additions & 2 deletions test/parallel_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function

import threading
import multiprocessing

Expand Down
1 change: 0 additions & 1 deletion test/probeserver_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function

# Note
# To run this script GNU Tools ARM Embedded must be installed,
Expand Down
1 change: 0 additions & 1 deletion test/speed_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function

import os
import sys
Expand Down
8 changes: 3 additions & 5 deletions test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function

import logging
import os
import sys
import traceback
from xml.etree import ElementTree
import six
import subprocess
import tempfile
import threading
Expand Down Expand Up @@ -195,7 +193,7 @@ def __init__(self, iostream, level=logging.NOTSET):
def emit(self, record):
try:
message = self.format(record)
self.stream.write(six.u(message + "\n"))
self.stream.write(message + "\n")
except Exception:
self.handleError(record)

Expand Down Expand Up @@ -244,10 +242,10 @@ def get_test_case(self):

def filter_output(self, output):
"""@brief Hex-encode null byte and control characters."""
result = six.text_type()
result = str()
for c in output:
if (c not in ('\n', '\r', '\t')) and (0 <= ord(c) <= 31):
result += u"\\x{:02x}".format(ord(c))
result += "\\x{:02x}".format(ord(c))
else:
result += c
return result
Expand Down
3 changes: 1 addition & 2 deletions test/unit/test_cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# limitations under the License.

import pytest
import six

from pyocd.utility.cmdline import (
split_command_line,
Expand Down Expand Up @@ -89,7 +88,7 @@ def test_vc_str(self, vc, msk):
assert convert_vector_catch(vc) == msk

@pytest.mark.parametrize(("vc", "msk"),
[(six.b(x), y) for x,y in VECTOR_CATCH_CHAR_MAP.items()])
[(x.encode('latin1'), y) for x,y in VECTOR_CATCH_CHAR_MAP.items()])
def test_vc_b(self, vc, msk):
assert convert_vector_catch(vc) == msk

Expand Down
7 changes: 3 additions & 4 deletions test/unit/test_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# limitations under the License.

import pytest
import six

from pyocd.utility.conversion import (
byte_list_to_nbit_le_list,
Expand Down Expand Up @@ -245,7 +244,7 @@ def test_align_down(self, args, result):
class TestGdbEscape(object):
# Verify all chars that shouldn't be escaped pass through unmodified.
@pytest.mark.parametrize("data",
[six.int2byte(x) for x in range(256) if (x not in ESCAPEES)])
[bytes((x,)) for x in range(256) if (x not in ESCAPEES)])
def test_escape_passthrough(self, data):
assert escape(data) == data

Expand All @@ -263,9 +262,9 @@ def test_escape_2(self):

# Verify all chars that shouldn't be escaped pass through unmodified.
@pytest.mark.parametrize("data",
[six.int2byte(x) for x in range(256) if (x not in ESCAPEES)])
[bytes((x,)) for x in range(256) if (x not in ESCAPEES)])
def test_unescape_passthrough(self, data):
assert unescape(data) == [six.byte2int(data)]
assert unescape(data) == [data[0]]

@pytest.mark.parametrize(("expected", "data"), [
(0x23, b'}\x03'),
Expand Down
1 change: 0 additions & 1 deletion test/unit/test_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# limitations under the License.

import pytest
import six
from enum import Enum

from pyocd.utility.notification import (Notification, Notifier)
Expand Down
1 change: 0 additions & 1 deletion test/unit/test_options_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# limitations under the License.

import pytest
import six

from pyocd.core.options_manager import OptionsManager
from pyocd.core.options import OPTIONS_INFO
Expand Down
1 change: 0 additions & 1 deletion test/unit/test_sdc600.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# limitations under the License.

import pytest
import six
from unittest import mock

from .test_rom_table import (MockCoreSightComponent, MockCoreSight, MockCSSOC600Components)
Expand Down
13 changes: 6 additions & 7 deletions test/unit/test_semihosting.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import os
import logging
# import telnetlib
import six

from pyocd.core.helpers import ConnectHelper
from pyocd.core.target import Target
Expand Down Expand Up @@ -128,7 +127,7 @@ def read(self, fd, ptr, length):
d = self._in_data[fd][:length]
self._in_data[fd] = self._in_data[fd][length:]
assert self.agent
self.agent.context.write_memory_block8(ptr, bytearray(six.ensure_binary(d)))
self.agent.context.write_memory_block8(ptr, bytearray(bytes(d)))
return length - len(d)

def readc(self):
Expand Down Expand Up @@ -170,7 +169,7 @@ def do_open(self, filename, mode):
argsptr = self.setup_semihost_request(semihost.SemihostingRequests.SYS_OPEN)

# Write filename
filename = bytearray(six.ensure_binary(filename) + b'\x00')
filename = bytearray(bytes(filename) + b'\x00')
self.ctx.write_memory_block8(argsptr + 12, filename)

self.ctx.write32(argsptr, argsptr + 12) # null terminated filename
Expand All @@ -197,7 +196,7 @@ def do_write(self, fd, data):
argsptr = self.setup_semihost_request(semihost.SemihostingRequests.SYS_WRITE)

# Write data
data = six.ensure_binary(data)
data = bytes(data)
self.ctx.write_memory_block8(argsptr + 12, data)

self.ctx.write32(argsptr, fd) # fd
Expand Down Expand Up @@ -388,15 +387,15 @@ def test_file_write_read(self, semihost_builder, delete_testfile, mode, writeDat
assert result == 0

result = semihost_builder.do_flen(fd)
assert result == len(six.ensure_binary(writeData))
assert result == len(bytes(writeData))

if pos != -1:
result = semihost_builder.do_seek(fd, pos)
assert result == 0

result, data = semihost_builder.do_read(fd, readLen)
assert result == readResult
assert data == six.ensure_binary(writeData[pos:pos + readLen])
assert data == bytes(writeData[pos:pos + readLen])

result = semihost_builder.do_close(fd)
assert result == 0
Expand Down Expand Up @@ -676,7 +675,7 @@ class TestSemihostIOHandlerBase:
])
def test_std_open(self, ctx, ramrgn, ioh, filename, mode, expectedFd):
handler, agent = ioh
ctx.write_memory_block8(ramrgn.start, bytearray(six.ensure_binary(filename) + b'\x00'))
ctx.write_memory_block8(ramrgn.start, bytearray(bytes(filename) + b'\x00'))
assert handler._std_open(ramrgn.start, len(filename), mode) == (expectedFd, filename)

@pytest.mark.parametrize(("op", "args"), [
Expand Down
7 changes: 3 additions & 4 deletions test/unit/test_sequencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# limitations under the License.

import pytest
import six

from pyocd.utility.sequencer import CallSequence

Expand Down Expand Up @@ -127,10 +126,10 @@ def task_b():
assert cs.count == 2
it = iter(cs)
print("it=",repr(it),dir(it))
assert six.next(it) == ('a', task_a)
assert six.next(it) == ('b', task_b)
assert next(it) == ('a', task_a)
assert next(it) == ('b', task_b)
with pytest.raises(StopIteration):
six.next(it)
next(it)

def test_get(self):
results = []
Expand Down
1 change: 0 additions & 1 deletion test/user_script_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function

import argparse
import os
Expand Down