summaryrefslogtreecommitdiff
path: root/chromium/third_party/pyelftools/examples/elf_relocations.py
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/pyelftools/examples/elf_relocations.py')
-rw-r--r--chromium/third_party/pyelftools/examples/elf_relocations.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/chromium/third_party/pyelftools/examples/elf_relocations.py b/chromium/third_party/pyelftools/examples/elf_relocations.py
index 008626619f5..fd65541954c 100644
--- a/chromium/third_party/pyelftools/examples/elf_relocations.py
+++ b/chromium/third_party/pyelftools/examples/elf_relocations.py
@@ -10,10 +10,12 @@
from __future__ import print_function
import sys
-# If pyelftools is not installed, the example can also run from the root or
-# examples/ dir of the source distribution.
-sys.path[0:0] = ['.', '..']
-
+# If elftools is not installed, maybe we're running from the root or examples
+# dir of the source distribution
+try:
+ import elftools
+except ImportError:
+ sys.path.extend(['.', '..'])
from elftools.common.py3compat import bytes2str
from elftools.elf.elffile import ELFFile