On Thu, 2010-10-21 at 14:40 -0700, Jean-Marc Eurin wrote:
> Closing f too.

Looks good to me, applied, thanks!

http://autotest.kernel.org/changeset/4899

> Signed-off-by: Jean-Marc Eurin <[email protected]>
> 
> --- autotest/cli/cli_mock.py  2010-04-28 16:36:10.000000000 -0700
> +++ autotest/cli/cli_mock.py  2010-10-21 14:30:42.000000000 -0700
> @@ -18,7 +18,6 @@
>  def create_file(content):
>      file_temp = autotemp.tempfile(unique_id='cli_mock', text=True)
>      os.write(file_temp.fd, content)
> -    os.close(file_temp.fd)
>      return file_temp
>  
> 
> --- autotest/client/common_lib/autotemp.py    2009-07-06 16:26:39.000000000 
> -0700
> +++ autotest/client/common_lib/autotemp.py    2010-10-21 14:30:42.000000000 
> -0700
> @@ -31,6 +31,7 @@
>          t = autotemp.tempfile(unique_id='fig')
>          t.name # name of file
>          t.fd   # file descriptor
> +        t.fo   # file object
>          t.clean() # clean up after yourself
>      """
>      def __init__(self, unique_id, suffix='', prefix='', dir=None,
> @@ -40,6 +41,7 @@
>          self.fd, self.name = module_tempfile.mkstemp(suffix=suffix,
>                                                       prefix=prefix,
>                                                       dir=dir, text=text)
> +        self.fo = os.fdopen(self.fd)
>  
> 
>      def clean(self):
> @@ -47,15 +49,17 @@
>          Remove the temporary file that was created.
>          This is also called by the destructor.
>          """
> +        if self.fo:
> +            self.fo.close()
>          if self.name and os.path.exists(self.name):
>              os.remove(self.name)
>  
> -        self.fd = self.name = None
> +        self.fd = self.fo = self.name = None
>  
> 
>      def __del__(self):
>          try:
> -            if self.name:
> +            if self.name is not None:
>                  logging.debug('Clean was not called for ' + self.name)
>                  self.clean()
>          except:
> --- autotest/client/common_lib/control_data_unittest.py       2009-07-06 
> 16:26:39.000000000 -0700
> +++ autotest/client/common_lib/control_data_unittest.py       2010-10-21 
> 14:30:42.000000000 -0700
> @@ -27,7 +27,6 @@
>          self.control_tmp = autotemp.tempfile(unique_id='control_unit',
>                                               text=True)
>          os.write(self.control_tmp.fd, CONTROL)
> -        os.close(self.control_tmp.fd)
>  
> 
>      def tearDown(self):
> --- autotest/client/common_lib/global_config_unittest.py      2009-07-06 
> 16:26:39.000000000 -0700
> +++ autotest/client/common_lib/global_config_unittest.py      2010-10-21 
> 14:30:42.000000000 -0700
> @@ -35,13 +35,11 @@
>      global_temp = autotemp.tempfile("global", ".ini",
>                                              text=True)
>      os.write(global_temp.fd, global_config_ini_contents)
> -    os.close(global_temp.fd)
>  
>      shadow_temp = autotemp.tempfile("shadow", ".ini",
>                                             text=True)
>      fd = shadow_temp.fd
>      os.write(shadow_temp.fd, shadow_config_ini_contents)
> -    os.close(shadow_temp.fd)
>  
>      return (global_temp, shadow_temp)
> _______________________________________________
> Autotest mailing list
> [email protected]
> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest


_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to