I have a huge code base before me, and I have a place where a file with name "foobar" gets written.
I have no clue where this file gets read.
My idea how to solve this:
How to let the interpreter raise an exception if a file with given name gets opened?
I am sure that the place I search is pure python, not a c-extension.
I use Python 2.7
You can override (shadow) builtin open function. Add this in your main module:
import __builtin__
open_file = __builtin__.open
def fake_open(filename, *args, **kwargs):
if filename == 'foobar':
raise Exception('foobar filename')
else:
return open_file(filename, *args, **kwargs)
__builtin__.open = fake_open
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With