From: Eli Bendersky Date: Tue, 16 Aug 2022 13:26:19 +0000 (-0700) Subject: Remove BytesIO and StringIO from py3compat X-Git-Tag: v0.30~28 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=dd3e9ccc054cc384c20d68b5a68337dcbc99f923;p=pyelftools.git Remove BytesIO and StringIO from py3compat --- diff --git a/elftools/common/py3compat.py b/elftools/common/py3compat.py index f853d60..681dc66 100644 --- a/elftools/common/py3compat.py +++ b/elftools/common/py3compat.py @@ -15,11 +15,6 @@ please download an older pyelftools version (such as version 0.29). if PY3: - import io - - StringIO = io.StringIO - BytesIO = io.BytesIO - # Functions for acting on bytestrings and strings. In Python 2 and 3, # strings and bytes are the same and chr/ord can be used to convert between # numeric byte values and their string representations. In Python 3, bytes @@ -33,11 +28,6 @@ if PY3: def byte2int(b): return b else: - import cStringIO - import os - - StringIO = BytesIO = cStringIO.StringIO - def bytes2str(b): return b def str2bytes(s): return s int2byte = chr diff --git a/elftools/dwarf/dwarf_expr.py b/elftools/dwarf/dwarf_expr.py index 899a5f7..cc081dd 100644 --- a/elftools/dwarf/dwarf_expr.py +++ b/elftools/dwarf/dwarf_expr.py @@ -7,8 +7,8 @@ # This code is in the public domain #------------------------------------------------------------------------------- from collections import namedtuple +from io import BytesIO -from ..common.py3compat import BytesIO from ..common.utils import struct_parse, bytelist2string, read_blob diff --git a/elftools/elf/elffile.py b/elftools/elf/elffile.py index d228db7..bddb77e 100644 --- a/elftools/elf/elffile.py +++ b/elftools/elf/elffile.py @@ -7,6 +7,7 @@ # This code is in the public domain #------------------------------------------------------------------------------- import io +from io import BytesIO import os import struct import zlib @@ -23,7 +24,6 @@ except ImportError: # Jython PAGESIZE = 4096 -from ..common.py3compat import BytesIO from ..common.exceptions import ELFError, ELFParseError from ..common.utils import struct_parse, elf_assert from .structs import ELFStructs diff --git a/test/test_arm_call_reloc.py b/test/test_arm_call_reloc.py index e23f25c..ec23606 100644 --- a/test/test_arm_call_reloc.py +++ b/test/test_arm_call_reloc.py @@ -9,10 +9,10 @@ # This code is in the public domain #------------------------------------------------------------------------------- import os +from io import BytesIO import sys import unittest -from elftools.common.py3compat import BytesIO from elftools.elf.elffile import ELFFile from elftools.elf.relocation import RelocationHandler diff --git a/test/test_callframe.py b/test/test_callframe.py index fc434f9..68cb060 100644 --- a/test/test_callframe.py +++ b/test/test_callframe.py @@ -5,8 +5,8 @@ # This code is in the public domain #------------------------------------------------------------------------------- import unittest +from io import BytesIO -from elftools.common.py3compat import BytesIO from elftools.dwarf.callframe import ( CallFrameInfo, CIE, FDE, instruction_name, CallFrameInstruction, RegisterRule, DecodedCallFrameTable, CFARule) diff --git a/test/test_dwarf_lineprogram.py b/test/test_dwarf_lineprogram.py index 526aa7b..56ad0a8 100644 --- a/test/test_dwarf_lineprogram.py +++ b/test/test_dwarf_lineprogram.py @@ -5,8 +5,8 @@ # This code is in the public domain #------------------------------------------------------------------------------- import unittest +from io import BytesIO -from elftools.common.py3compat import BytesIO from elftools.dwarf.lineprogram import LineProgram, LineState, LineProgramEntry from elftools.dwarf.structs import DWARFStructs from elftools.dwarf.constants import * diff --git a/test/test_relocations.py b/test/test_relocations.py index f1c8f10..eb908bc 100644 --- a/test/test_relocations.py +++ b/test/test_relocations.py @@ -1,8 +1,8 @@ import os +from io import BytesIO import sys import unittest -from elftools.common.py3compat import BytesIO from elftools.elf.elffile import ELFFile from elftools.elf.dynamic import DynamicSegment, DynamicSection diff --git a/test/test_utils.py b/test/test_utils.py index 23669e7..52b8391 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -5,9 +5,10 @@ # This code is in the public domain #------------------------------------------------------------------------------- import unittest +from io import BytesIO from random import randint -from elftools.common.py3compat import int2byte, BytesIO +from elftools.common.py3compat import int2byte from elftools.common.utils import (parse_cstring_from_stream, merge_dicts, preserve_stream_pos)