title: Record where files are opened to debug "ResourceWarning: unclosed file"
body: <p>I'm in the process of porting a <a href="https://www.samba.org/~jelmer/dulwich/" rel="noreferrer">library</a> to Python3. One of the issues that popped up is all the <a href="https://bugs.python.org/issue10093" rel="noreferrer">"unclosed file" warnings</a> when running the test suite. I've resolved 95% of the warnings, but a couple remain that I'm struggling to find where in the code the file is opened. </p>
  
  <p>Is there some way to get Python to record the stack frame when the file is opened, and show me that stack frame when the warning is raised? </p>
  
  <p>I would be happy with something that monkey patches the stdlib code, as I will only be using this for once off debugging.</p>