Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check if ":" exists before index(':') #1159

Merged
merged 5 commits into from
Jun 4, 2018

Conversation

excalibur44
Copy link
Contributor

When I use gdb.attach(p), I get an error: ValueError: substring not found

I debug it and found that the file /proc/%d/status may have blank line. But util/proc.py doesn't solve it very well. If status file has blank line, then it will raise an error.

So I add some code to detect if ":" exists. If find ":" failed, it will continue.

Sorry for my bad english ...

@@ -245,6 +245,8 @@ def status(pid):
try:
with open('/proc/%d/status' % pid) as fd:
for line in fd:
if -1 == line.find(':'):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this looks better?

if ':' not in line:
    continue

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this would probably be better. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@@ -245,6 +245,8 @@ def status(pid):
try:
with open('/proc/%d/status' % pid) as fd:
for line in fd:
if -1 == line.find(':'):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this would probably be better. Thanks!

@zachriggle zachriggle merged commit f4159bd into Gallopsled:stable Jun 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants