From a412cfb9bd4acf4e6fa94697662e5431cad388b8 Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Tue, 16 Aug 2022 06:21:11 -0700 Subject: [PATCH] Remove path and maxint from py3compat --- elftools/common/py3compat.py | 12 ------------ examples/dwarf_decode_address.py | 2 +- examples/dwarf_die_tree.py | 4 ++-- examples/examine_dwarf_info.py | 4 ++-- 4 files changed, 5 insertions(+), 17 deletions(-) diff --git a/elftools/common/py3compat.py b/elftools/common/py3compat.py index 0086132..f853d60 100644 --- a/elftools/common/py3compat.py +++ b/elftools/common/py3compat.py @@ -16,7 +16,6 @@ please download an older pyelftools version (such as version 0.29). if PY3: import io - from pathlib import Path StringIO = io.StringIO BytesIO = io.BytesIO @@ -33,15 +32,9 @@ if PY3: def int2byte(i): return bytes((i,)) def byte2int(b): return b - maxint = sys.maxsize - - def path_to_posix(s): - return Path(s).as_posix() - else: import cStringIO import os - import posixpath StringIO = BytesIO = cStringIO.StringIO @@ -51,8 +44,3 @@ else: byte2int = ord def iterbytes(b): return iter(b) - - maxint = sys.maxint - - def path_to_posix(s): - return posixpath.join(*os.path.split(s)) diff --git a/examples/dwarf_decode_address.py b/examples/dwarf_decode_address.py index e206ae9..007ba08 100644 --- a/examples/dwarf_decode_address.py +++ b/examples/dwarf_decode_address.py @@ -14,7 +14,7 @@ import sys # examples/ dir of the source distribution. sys.path[0:0] = ['.', '..'] -from elftools.common.py3compat import maxint, bytes2str +from elftools.common.py3compat import bytes2str from elftools.dwarf.descriptions import describe_form_class from elftools.elf.elffile import ELFFile diff --git a/examples/dwarf_die_tree.py b/examples/dwarf_die_tree.py index afda68c..6a1545e 100644 --- a/examples/dwarf_die_tree.py +++ b/examples/dwarf_die_tree.py @@ -8,6 +8,7 @@ # This code is in the public domain #------------------------------------------------------------------------------- from __future__ import print_function +from pathlib import Path import sys # If pyelftools is not installed, the example can also run from the root or @@ -15,7 +16,6 @@ import sys sys.path[0:0] = ['.', '..'] from elftools.elf.elffile import ELFFile -from elftools.common.py3compat import path_to_posix def process_file(filename): @@ -45,7 +45,7 @@ def process_file(filename): print(' Top DIE with tag=%s' % top_DIE.tag) # We're interested in the filename... - print(' name=%s' % path_to_posix(top_DIE.get_full_path())) + print(' name=%s' % Path(top_DIE.get_full_path()).as_posix()) # Display DIEs recursively starting with top_DIE die_info_rec(top_DIE) diff --git a/examples/examine_dwarf_info.py b/examples/examine_dwarf_info.py index fdf10da..5871ab5 100644 --- a/examples/examine_dwarf_info.py +++ b/examples/examine_dwarf_info.py @@ -7,6 +7,7 @@ # This code is in the public domain #------------------------------------------------------------------------------- from __future__ import print_function +from pathlib import Path import sys # If pyelftools is not installed, the example can also run from the root or @@ -14,7 +15,6 @@ import sys sys.path[0:0] = ['.', '..'] from elftools.elf.elffile import ELFFile -from elftools.common.py3compat import path_to_posix def process_file(filename): @@ -44,7 +44,7 @@ def process_file(filename): print(' Top DIE with tag=%s' % top_DIE.tag) # We're interested in the filename... - print(' name=%s' % path_to_posix(top_DIE.get_full_path())) + print(' name=%s' % Path(top_DIE.get_full_path()).as_posix()) if __name__ == '__main__': if sys.argv[1] == '--test': -- 2.30.2