summaryrefslogtreecommitdiff
path: root/chromium/third_party/pyelftools/elftools/common/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/pyelftools/elftools/common/utils.py')
-rw-r--r--chromium/third_party/pyelftools/elftools/common/utils.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/chromium/third_party/pyelftools/elftools/common/utils.py b/chromium/third_party/pyelftools/elftools/common/utils.py
index a2c9edbe356..2daed04c51c 100644
--- a/chromium/third_party/pyelftools/elftools/common/utils.py
+++ b/chromium/third_party/pyelftools/elftools/common/utils.py
@@ -31,8 +31,8 @@ def struct_parse(struct, stream, stream_pos=None):
stream.seek(stream_pos)
return struct.parse_stream(stream)
except ConstructError as e:
- raise ELFParseError(str(e))
-
+ raise ELFParseError(e.message)
+
def parse_cstring_from_stream(stream, stream_pos=None):
""" Parse a C-string from the given stream. The string is returned without
@@ -41,8 +41,6 @@ def parse_cstring_from_stream(stream, stream_pos=None):
If stream_pos is provided, the stream is seeked to this position before
the parsing is done. Otherwise, the current position of the stream is
used.
- Note: a bytes object is returned here, because this is what's read from
- the binary file.
"""
if stream_pos is not None:
stream.seek(stream_pos)
@@ -78,10 +76,11 @@ def dwarf_assert(cond, msg=''):
@contextmanager
def preserve_stream_pos(stream):
""" Usage:
- # stream has some position FOO (return value of stream.tell())
- with preserve_stream_pos(stream):
- # do stuff that manipulates the stream
- # stream still has position FOO
+
+ # stream has some position FOO (return value of stream.tell())
+ with preserve_stream_pos(stream):
+ # do stuff that manipulates the stream
+ # stream still has position FOO
"""
saved_pos = stream.tell()
yield