[New-bugs-announce] [issue13222] Erroneous unclosed file warning

Giampaolo Rodola' report at bugs.python.org
Wed Oct 19 20:53:48 CEST 2011

New submission from Giampaolo Rodola' <g.rodola at gmail.com>:

/opt/python3.2/lib/python3.2/site-packages/psutil/_pslinux.py:389: ResourceWarning: unclosed file <_io.FileIO name=7 mode='rb'>
  return [x for x in f.read().split('\x00') if x]

I get this while running tests.
The method in question is defined as such:

    def get_process_cmdline(self):
        f = open("/proc/%s/cmdline" % self.pid)
            # return the args as a list
            return [x for x in f.read().split('\x00') if x]

...therefore, I'm closing the file object (in the finally block).

messages: 145936
nosy: giampaolo.rodola, pitrou
priority: normal
severity: normal
status: open
title: Erroneous unclosed file warning
versions: Python 3.2, Python 3.3

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list