classification
Title: ResourceWarning: unclosed file <_io.TextIOWrapper
Type: Stage: resolved
Components: Versions:
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: eric.araujo Nosy List: Trundle, alexis, cjejuni2000, eric.araujo, nadeem.vawda, tarek
Priority: normal Keywords: patch

Created on 2011-02-26 21:38 by cjejuni2000, last changed 2011-05-26 16:53 by eric.araujo. This issue is now closed.

Files
File name Uploaded Description Edit
distutils-files.diff eric.araujo, 2011-02-27 16:14 review
Messages (21)
msg129598 - (view) Author: LW (cjejuni2000) Date: 2011-02-26 21:38
1 test failed:
    test_urllib2_localnet
1 test altered the execution environment:
    test_urllib2
21 tests skipped:
    test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp
    test_codecmaps_kr test_codecmaps_tw test_curses test_gdb
    test_kqueue test_ossaudiodev test_smtpnet test_socketserver
    test_startfile test_timeout test_tk test_ttk_guionly
    test_urllib2net test_urllibnet test_winreg test_winsound
    test_xmlrpc_net test_zipfile64
1 skip unexpected on linux2:
    test_ttk_guionly
sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper name='/dev/null' mode='a' encoding='UTF-8'>
make: *** [test] Error 1
msg129599 - (view) Author: LW (cjejuni2000) Date: 2011-02-26 21:42
[ 92/349] test_distutils
/home/les/Downloads/Python-3.2/Lib/distutils/command/sdist.py:197: ResourceWarning: unclosed file <_io.TextIOWrapper name='MANIFEST.in' mode='r' encoding='UTF-8'>
  self.read_template()
unknown, 0: Warning: using regular magic file `/etc/magic'
unknown, 0: Warning: using regular magic file `/etc/magic'
msg129632 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-02-27 15:04
Does the attached patch fix the issue?
msg129637 - (view) Author: Andreas Stührk (Trundle) * Date: 2011-02-27 16:12
@Éric: You should probably strip the colour from your diff :-)
msg129671 - (view) Author: LW (cjejuni2000) Date: 2011-02-28 00:20
hi eric: thanks for the reply. here is what i'm getting from 'patch --dry-run' command:

les@Liquid:~/Desktop$ patch -i ~/Desktop/distutils_files.diff -d ~/Downloads/Python-3.2/Lib/distutils --dry-run --backup
patching file bdist_wininst.py
Hunk #1 FAILED at 245.
1 out of 1 hunk FAILED -- saving rejects to file bdist_wininst.py.rej
patching file bdist_rpm.py
Hunk #1 FAILED at 511.
1 out of 1 hunk FAILED -- saving rejects to file bdist_rpm.py.rej
patching file upload.py
Hunk #1 FAILED at 124.
1 out of 1 hunk FAILED -- saving rejects to file upload.py.rej
patching file sdist.py
Hunk #1 FAILED at 294.
Hunk #2 FAILED at 359.
2 out of 2 hunks FAILED -- saving rejects to file sdist.py.rej
patching file sysconfig.py
les@Liquid:~/Desktop$
msg129673 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-02-28 00:23
Can you test with a checkout of the py3k branch?  http://docs.python.org/devguide/setup#checking-out-the-code
msg129681 - (view) Author: LW (cjejuni2000) Date: 2011-02-28 04:01
seemed no errors. end of check attach:

U   py3k
Checked out revision 88674.
msg129697 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-02-28 13:14
So the patch fixes the resource warnings?
msg129716 - (view) Author: LW (cjejuni2000) Date: 2011-02-28 16:54
only the sysconfig.py was patched, the rest were "reject'ed." no compilation yet at this time.
msg129819 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-03-01 22:08
Can you try updating your py3k checkout and applying with “patch -p1”?
msg129849 - (view) Author: LW (cjejuni2000) Date: 2011-03-02 02:00
thanks.py3k done. 
still having rejects, applied patch:  

les@Liquid:~$ patch -p1 -i ~/Desktop/distutils_files.diff ~/Downloads/Python-3.2/distutils/command
patching file /home/les/Downloads/Python-3.2/distutils/command
Hunk #1 FAILED at 245.
1 out of 1 hunk FAILED -- saving rejects to file /home/les/Downloads/Python-3.2/distutils/command.rej
patching file /home/les/Downloads/Python-3.2/distutils/command
Hunk #1 FAILED at 511.
1 out of 1 hunk FAILED -- saving rejects to file /home/les/Downloads/Python-3.2/distutils/command.rej
patching file /home/les/Downloads/Python-3.2/distutils/command
Hunk #1 FAILED at 124.
1 out of 1 hunk FAILED -- saving rejects to file /home/les/Downloads/Python-3.2/distutils/command.rej
patching file /home/les/Downloads/Python-3.2/distutils/command
Hunk #1 FAILED at 294.
Hunk #2 FAILED at 359.
2 out of 2 hunks FAILED -- saving rejects to file /home/les/Downloads/Python-3.2/distutils/command.rej
patching file /home/les/Downloads/Python-3.2/distutils/command
Hunk #1 FAILED at 270.
1 out of 1 hunk FAILED -- saving rejects to file /home/les/Downloads/Python-3.2/distutils/command.rej
les@Liquid:~$
msg129852 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-03-02 03:10
And of course, I said the wrong thing :)  This patch needs -p0.
msg129853 - (view) Author: LW (cjejuni2000) Date: 2011-03-02 03:31
btw, if not know yet the patches are applied to python 3.2.
anyway the patch -p0 resulted exactly the same rejects. 


les@Liquid:~$ patch -p0 -i ~/Desktop/distutils_files.diff ~/Downloads/Python-3.2/distutils/command
patching file /home/les/Downloads/Python-3.2/distutils/command
Hunk #1 FAILED at 245.
1 out of 1 hunk FAILED -- saving rejects to file /home/les/Downloads/Python-3.2/distutils/command.rej
patching file /home/les/Downloads/Python-3.2/distutils/command
Hunk #1 FAILED at 511.
1 out of 1 hunk FAILED -- saving rejects to file /home/les/Downloads/Python-3.2/distutils/command.rej
patching file /home/les/Downloads/Python-3.2/distutils/command
Hunk #1 FAILED at 124.
1 out of 1 hunk FAILED -- saving rejects to file /home/les/Downloads/Python-3.2/distutils/command.rej
patching file /home/les/Downloads/Python-3.2/distutils/command
Hunk #1 FAILED at 294.
Hunk #2 FAILED at 359.
2 out of 2 hunks FAILED -- saving rejects to file /home/les/Downloads/Python-3.2/distutils/command.rej
patching file /home/les/Downloads/Python-3.2/distutils/command
Hunk #1 FAILED at 270.
1 out of 1 hunk FAILED -- saving rejects to file /home/les/Downloads/Python-3.2/distutils/command.rej
les@Liquid:~$
msg129854 - (view) Author: LW (cjejuni2000) Date: 2011-03-02 04:10
hi eric,
maybe we are troubleshooting the wrong thing. so i downloaded the python3.2 package again. configured no error. 
now make gives, just one bad or missing module(s). 

Failed to build these modules:
ossaudiodev              

i can't find it in synaptic manager. what are the packages i need to install to build ossaudiodev! can you help or should i post?
thanks,
lw

--- On Tue, 3/1/11, Éric Araujo <report@bugs.python.org> wrote:

From: Éric Araujo <report@bugs.python.org>
Subject: [issue11342] ResourceWarning: unclosed file <_io.TextIOWrapper
To: cjejuni2000@yahoo.com
Date: Tuesday, March 1, 2011, 7:10 PM

Éric Araujo <merwok@netwok.org> added the comment:

And of course, I said the wrong thing :)  This patch needs -p0.

----------

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue11342>
_______________________________________
msg129855 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-03-02 04:21
ossaudiodev is a platform-specific module that you don’t have to care about.  It’s just a compilation warning that an option module has not been built, nothing to worry about.

I just realized that I was not paying enough attention to your error messages.  I have never used patch with the -d or -i options.  To apply the patch, change directory to the source of Python, where you should see the Lib and Modules directories for example, and then patch -p0 < distutils-files.diff
msg130016 - (view) Author: LW (cjejuni2000) Date: 2011-03-04 01:17
so i downloaded the python-3.2 source again, applied the .diff file. still getting _io.TextIOWrapper open file error. then ran the major 5 individual make test_ files errors. hope u can find from these:

===================================================================
les@Liquid:~/Desktop/Python-3.2$ ./python -m test -v test_distutils

== CPython 3.2 (r32:88445, Mar 3 2011, 16:17:04) [GCC 4.4.5]
==   Linux-2.6.35-27-generic-pae-i686-with-debian-squeeze-sid little-endian
==   /home/les/Desktop/Python-3.2/build/test_python_32202
Testing with flags: sys.flags(debug=0, division_warning=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=0, verbose=0, bytes_warning=0, quiet=0)

test_no_optimize_flag (distutils.tests.test_bdist_rpm.BuildRpmTestCase) ... unknown, 0: Warning: using regular magic file `/etc/magic'
ok
test_quiet (distutils.tests.test_bdist_rpm.BuildRpmTestCase) ... unknown, 0: Warning: using regular magic file `/etc/magic'
ok
==================================================================

==================================================================
./python -m test -v test_parser
test_trigger_memory_error (test.test_parser.ParserStackLimitTestCase) ... Expecting 's_push: parser stack overflow' in next line
s_push: parser stack overflow
ok

=================================================================
./python -m test -v test_startfile
test_startfile skipped -- module os has no attribute startfile
=================================================================

=================================================================
./python -m test -v test_subprocess

test_executable_without_cwd (test.test_subprocess.ProcessTestCase) ... skipped 'need an installed Python. See #7774'
test_stdout_none (test.test_subprocess.ProcessTestCase) ...     this bit of output is from a test of stdout in a different process ...
ok
test_pass_fds (test.test_subprocess.POSIXProcessTestCase) ...  -- maxfd = 1024
 -- fds that should have been closed: {4, 5, 6, 7, 8, 9, 10, 11, 12}
 -- fds that remained open: {0, 1, 2, 3}
 -- fds that should have been closed: {3, 5, 6, 7, 8, 9, 10, 11, 12}
 -- fds that remained open: {0, 1, 2, 4}
 -- fds that should have been closed: {3, 4, 6, 7, 8, 9, 10, 11, 12}
 -- fds that remained open: {0, 1, 2, 5}
 -- fds that should have been closed: {3, 4, 5, 7, 8, 9, 10, 11, 12}
 -- fds that remained open: {0, 1, 2, 6}
 -- fds that should have been closed: {3, 4, 5, 6, 8, 9, 10, 11, 12}
 -- fds that remained open: {0, 1, 2, 7}
 -- fds that should have been closed: {3, 4, 5, 6, 7, 9, 10, 11, 12}
 -- fds that remained open: {0, 1, 2, 8}
 -- fds that should have been closed: {3, 4, 5, 6, 7, 8, 10, 11, 12}
 -- fds that remained open: {0, 1, 2, 9}
 -- fds that should have been closed: {3, 4, 5, 6, 7, 8, 9, 11, 12}
 -- fds that remained open: {0, 1, 2, 10}
 -- fds that should have been closed: {3, 4, 5, 6, 7, 8, 9, 10, 12}
 -- fds that remained open: {0, 1, 2, 11}
 -- fds that should have been closed: {3, 4, 5, 6, 7, 8, 9, 10, 11}
 -- fds that remained open: {0, 1, 2, 12}
ok
test_executable_without_cwd (test.test_subprocess.ProcessTestCasePOSIXPurePython) ... skipped 'need an installed Python. See #7774'
==================================================================

==================================================================
./python -m test -v test_urllib2_localnet

test_sending_headers (test.test_urllib2_localnet.TestUrlopen) ... ok

======================================================================
FAIL: test_proxy_with_bad_password_raises_httperror (test.test_urllib2_localnet.ProxyAuthTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/les/Desktop/Python-3.2/Lib/test/test_urllib2_localnet.py", line 267, in test_proxy_with_bad_password_raises_httperror
    self.URL)
AssertionError: HTTPError not raised by open

======================================================================
FAIL: test_proxy_with_no_password_raises_httperror (test.test_urllib2_localnet.ProxyAuthTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/les/Desktop/Python-3.2/Lib/test/test_urllib2_localnet.py", line 273, in test_proxy_with_no_password_raises_httperror
    self.URL)
AssertionError: HTTPError not raised by open

----------------------------------------------------------------------
Ran 18 tests in 1.888s

FAILED (failures=2)
test test_urllib2_localnet failed -- multiple errors occurred
1 test failed:
    test_urllib2_localnet





thanks again
msg131552 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-03-20 21:55
The test failures you quoted are not related to distutils.

I cannot see the ResourceWarnings in 3.2 or 3.3, so I think I’m going to close this issue.
msg131581 - (view) Author: Nadeem Vawda (nadeem.vawda) * (Python committer) Date: 2011-03-21 00:22
The first ResourceWarning looks like the test_cgi leak from issue10512, which was fixed in changeset ae186b3b2c55.
msg131585 - (view) Author: Nadeem Vawda (nadeem.vawda) * (Python committer) Date: 2011-03-21 00:37
Sorry about accidentally changing the issue status to "open". It seems that I don't have the requisite privileges to change it back to "pending"...
msg131586 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-03-21 00:39
Any message will automatically change pending to open, don’t worry.
msg136983 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-05-26 16:53
Closing after no reply.  If someone can reproduce the bug, please say so and reopen.
History
Date User Action Args
2011-05-26 16:53:58eric.araujosetstatus: pending -> closed

messages: + msg136983
stage: resolved
2011-03-21 00:39:00eric.araujosetstatus: open -> pending

messages: + msg131586
resolution: works for me
nosy: nadeem.vawda, tarek, eric.araujo, Trundle, alexis, cjejuni2000
2011-03-21 00:37:18nadeem.vawdasetnosy: nadeem.vawda, tarek, eric.araujo, Trundle, alexis, cjejuni2000
messages: + msg131585
2011-03-21 00:22:18nadeem.vawdasetstatus: pending -> open
nosy: + nadeem.vawda
messages: + msg131581

2011-03-20 21:55:52eric.araujosetstatus: open -> pending
versions: - 3rd party, Python 3.1, Python 2.7, Python 3.2, Python 3.3
nosy: tarek, eric.araujo, Trundle, alexis, cjejuni2000
messages: + msg131552

components: - Distutils, Distutils2
2011-03-04 01:17:31cjejuni2000setnosy: tarek, eric.araujo, Trundle, alexis, cjejuni2000
messages: + msg130016
2011-03-02 04:22:49eric.araujosetfiles: - unnamed
nosy: tarek, eric.araujo, Trundle, alexis, cjejuni2000
2011-03-02 04:21:26eric.araujosetnosy: tarek, eric.araujo, Trundle, alexis, cjejuni2000
messages: + msg129855
2011-03-02 04:10:15cjejuni2000setfiles: + unnamed

messages: + msg129854
nosy: tarek, eric.araujo, Trundle, alexis, cjejuni2000
2011-03-02 03:31:18cjejuni2000setnosy: tarek, eric.araujo, Trundle, alexis, cjejuni2000
messages: + msg129853
2011-03-02 03:10:36eric.araujosetnosy: tarek, eric.araujo, Trundle, alexis, cjejuni2000
messages: + msg129852
2011-03-02 02:00:55cjejuni2000setnosy: tarek, eric.araujo, Trundle, alexis, cjejuni2000
messages: + msg129849
2011-03-01 22:08:55eric.araujosetnosy: tarek, eric.araujo, Trundle, alexis, cjejuni2000
messages: + msg129819
2011-02-28 16:54:02cjejuni2000setnosy: tarek, eric.araujo, Trundle, alexis, cjejuni2000
messages: + msg129716
2011-02-28 13:14:45eric.araujosetnosy: tarek, eric.araujo, Trundle, alexis, cjejuni2000
messages: + msg129697
2011-02-28 04:01:43cjejuni2000setnosy: tarek, eric.araujo, Trundle, alexis, cjejuni2000
messages: + msg129681
2011-02-28 00:23:08eric.araujosetnosy: tarek, eric.araujo, Trundle, alexis, cjejuni2000
messages: + msg129673
2011-02-28 00:20:35cjejuni2000setnosy: tarek, eric.araujo, Trundle, alexis, cjejuni2000
messages: + msg129671
2011-02-27 16:14:41eric.araujosetfiles: + distutils-files.diff
nosy: tarek, eric.araujo, Trundle, alexis, cjejuni2000
2011-02-27 16:14:27eric.araujosetfiles: - distutils-files.diff
nosy: tarek, eric.araujo, Trundle, alexis, cjejuni2000
2011-02-27 16:12:18Trundlesetnosy: + Trundle
messages: + msg129637
2011-02-27 15:04:27eric.araujosetfiles: + distutils-files.diff

assignee: tarek -> eric.araujo
components: + Distutils2
versions: + 3rd party, Python 3.1, Python 2.7, Python 3.3
keywords: + patch
nosy: + alexis

messages: + msg129632
2011-02-26 21:42:01cjejuni2000setnosy: + eric.araujo, tarek
messages: + msg129599

assignee: tarek
components: + Distutils, - IO
2011-02-26 21:38:57cjejuni2000create