andyvand / pefile

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

pefile raise PEFormatError ,but a only #23

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?

Please provide any additional information below.

Original issue reported on code.google.com by whiled...@gmail.com on 10 Dec 2010 at 11:07

GoogleCodeExporter commented 9 years ago
I use pefile to detect a list of pe file,but when pefile raise 
PEFormatError,the script will exit.but I only want pefile to skip the bad 
format pe file.

Original comment by whiled...@gmail.com on 10 Dec 2010 at 11:09

GoogleCodeExporter commented 9 years ago
That's the intended behavior. The PEFormatError exception is raised to indicate 
problems parsing the file.

You can achieve the result you seek by simply catching the exception in your 
script, for instance:

try:
  pe = pefile.PE('/path/to/executable')
except pefile.PEFormatError:
  pass

That will catch the exceptions and do nothing about it.

Original comment by ero.carr...@gmail.com on 10 Dec 2010 at 3:39