Skip to content

Commit 1c92c0d

Browse files
Ensuring adr_dict is split correctly
Normally the dictionary adr_dict contains lines with four components all separated by a colon (:). In the case of generated code the last component may contain the generated code instead of the filename of the file where the code resides. Since generated code most likely will contain at least one colon the full line will contain more than the expected three colons resulting in a 'too many values to unpack' error. To ensure that this string can always be safely split the 'maxsplit' parameter should be set to 3.
1 parent 8d86cad commit 1c92c0d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

vmprof/stats.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ def get_name(self, addr):
4343

4444
def find_addrs_containing_name(self, part):
4545
for adr, name in self.adr_dict.items():
46-
n, symbol, _, _ = name.split(':')
46+
n, symbol, _, _ = name.split(':', 3)
4747
if part in symbol:
4848
yield adr
4949

5050
def get_addr_info(self, addr):
5151
name = self.adr_dict.get(addr, None)
5252
if not name:
5353
return None
54-
lang, symbol, line, file = name.split(':')
54+
lang, symbol, line, file = name.split(':', 3)
5555
return lang, symbol, line, file
5656

5757
def getargv(self):

0 commit comments

Comments
 (0)