Remove path and maxint from py3compat
authorEli Bendersky <eliben@gmail.com>
Tue, 16 Aug 2022 13:21:11 +0000 (06:21 -0700)
committerEli Bendersky <eliben@gmail.com>
Tue, 16 Aug 2022 13:21:11 +0000 (06:21 -0700)
elftools/common/py3compat.py
examples/dwarf_decode_address.py
examples/dwarf_die_tree.py
examples/examine_dwarf_info.py

index 0086132c76f487804670e20785c833975391d66e..f853d604aeb1ac071981cc297af9817f9b58c4a8 100644 (file)
@@ -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))
index e206ae9ae471c06b093928c5cb0fd7e67bb03310..007ba080478612e383d7956b14dc1fb0d6384b52 100644 (file)
@@ -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
 
index afda68cca7456da2eacc9be074a8f3cc33edc5be..6a1545e65c369b406a2995e6488819719408bc64 100644 (file)
@@ -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)
index fdf10dabb34838255b9a39f3b49616b443a92e3f..5871ab527aa79689bb894e8efe9a43a9e3ae7bae 100644 (file)
@@ -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':