shanecode / psutil

Automatically exported from code.google.com/p/psutil
Other
0 stars 0 forks source link

psutil.Process(4).exe has inconsistent behavior between WinXP and Win7 #414

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. psutil.Process(4).exe   (inadvertantly from calling as_dict())

Drilled down to the lowest call:
>>> _psutil_mswindows.get_process_exe(4)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
WindowsError: [Error 5] Access is denied

>>> _psutil_mswindows.get_process_exe(4)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
WindowsError: [Error 87] The parameter is incorrect

What is the expected output?
psutil._error.AccessDenied: (pid=4)

What do you see instead?
WindowsError [Error 87] The parameter is incorrect

What version of psutil are you using? What Python version?
psutil tip (02ce4f7587ef)
Python 2.7.5

On what operating system? Is it 32bit or 64bit version?
Win7SP1 x86
WinXPSP3 x86

Please provide any additional information below.
This is because of the inconsistent errno returned by GetProcessImageFileName.  
We can't control what Windows returns to us but we can try to make it 
consistent to the end user.  

[proc.as_dict(ad_value="ACCESS DENIED") for proc in psutil.process_iter()] 
works gracefully on Win7.  On WinXP, the exception bubbles up and breaks 
execution.

In _psmswindows.py:wrap_exceptions a check is made to see if the WindowsError 
errno is in the a predefined ACCESS_DENIED_SET.  In the case of WinXP, the 
error raised is ERROR_INVALID_PARAMETER which is not in this set.

I'm not sure when the errno changes between Windows versions, I only have WinXP 
and Win7 to test with.

Original issue reported on code.google.com by thep...@gmail.com on 28 Jul 2013 at 4:10

GoogleCodeExporter commented 9 years ago
I fixed this in revision 5c64fe6dcdef.
I didn't actually tested it on Win XP but I assume it works.

Original comment by g.rodola on 29 Jul 2013 at 2:01

GoogleCodeExporter commented 9 years ago
Confirmed patch works.

Original comment by thep...@gmail.com on 29 Jul 2013 at 2:06

GoogleCodeExporter commented 9 years ago

Original comment by g.rodola on 26 Aug 2013 at 10:25

GoogleCodeExporter commented 9 years ago

Original comment by g.rodola on 28 Sep 2013 at 10:06

GoogleCodeExporter commented 9 years ago
Closing out as fixed. Release 1.1.0 is now available for download.

Original comment by g.rodola on 28 Sep 2013 at 5:32