[issue11503] Expand test coverage in posixpath
New submission from Evan Dandrea : I've expanded the coverage of the posixpath test. The following scenarios have been added: - lexists with a non-existent file. - ismount with binary data. - ismount with a directory that is not a mountpoint. - ismount with a non-existent file. - ismount with a symlink. - expanduser with $HOME unset. - realpath with a relative path. - sameopenfile with a basic test. I have tested it on Ubuntu natty (20110311) and Mac OSX 10.6.6. -- components: Tests files: test_posixpath.patch keywords: patch messages: 130856 nosy: ev priority: normal severity: normal status: open title: Expand test coverage in posixpath type: behavior Added file: http://bugs.python.org/file21122/test_posixpath.patch ___ Python tracker <http://bugs.python.org/issue11503> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11503] Expand test coverage in posixpath
Changes by Evan Dandrea : -- nosy: +michael.foord ___ Python tracker <http://bugs.python.org/issue11503> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11503] Expand test coverage in posixpath
Evan Dandrea added the comment: Fixed a typo in the previous patch. -- Added file: http://bugs.python.org/file21124/test_posixpath.patch ___ Python tracker <http://bugs.python.org/issue11503> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11503] Expand test coverage in posixpath
Evan Dandrea added the comment: Added an updated patch that includes testing whether ismount would succeed by faking path being on a different device from its parent. -- Added file: http://bugs.python.org/file21125/test_posixpath_with_same_device.patch ___ Python tracker <http://bugs.python.org/issue11503> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11503] Expand test coverage in posixpath
Evan Dandrea added the comment: It's probably best to give the fake stats inode numbers, so if the code does fail to check the st_dev fields, it will fail the test. I've updated the patch with this. -- Added file: http://bugs.python.org/file21128/test_posixpath_with_same_device.patch ___ Python tracker <http://bugs.python.org/issue11503> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11513] Infinite recursion around raising an exception in tarfile
New submission from Evan Dandrea : Using Python tip from Sunday, I noticed that tarfile does not elegantly handle ENOENT by raising a single exception: >>> tarfile.TarFile.gzopen('fdsfd', 'r') Traceback (most recent call last): File "/home/evan/hg/cpython/Lib/tarfile.py", line 1808, in gzopen fileobj = gzip.GzipFile(name, mode + "b", compresslevel, fileobj) File "/home/evan/hg/cpython/Lib/gzip.py", line 157, in __init__ fileobj = self.myfileobj = builtins.open(filename, mode or 'rb') IOError: [Errno 2] No such file or directory: 'fdsfd' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "", line 1, in File "/home/evan/hg/cpython/Lib/tarfile.py", line 1812, in gzopen fileobj.close() AttributeError: 'NoneType' object has no attribute 'close' I tried to fix this in a cross-platform way, by attempting to open the file before processing it, and letting the with statement handle calling close: diff -r 955547e57cff Lib/tarfile.py --- a/Lib/tarfile.pySun Mar 13 19:32:21 2011 +0100 +++ b/Lib/tarfile.pyMon Mar 14 19:33:21 2011 -0400 @@ -1793,6 +1793,10 @@ if len(mode) > 1 or mode not in "rw": raise ValueError("mode must be 'r' or 'w'") +if mode == "r": +# force an exception if the file does not exist. +with open(name): +pass try: import gzip gzip.GzipFile However, this produces infinite recursion: ... File "/home/evan/hg/cpython/Lib/tarfile.py", line 1738, in open return func(name, "r", fileobj, **kwargs) File "/home/evan/hg/cpython/Lib/tarfile.py", line 1798, in gzopen with open(name): File "/home/evan/hg/cpython/Lib/tarfile.py", line 1738, in open return func(name, "r", fileobj, **kwargs) RuntimeError: maximum recursion depth exceeded Curiously, if I force the ValueError in that same function to be triggered (by passing a three character string for the mode), that exception is raised fine. I am therefore wondering if this is a bug in the exit processing. Unfortunately, my attempts at producing a general test case have been unsuccessful thusfar. -- components: Interpreter Core messages: 130932 nosy: ev priority: normal severity: normal status: open title: Infinite recursion around raising an exception in tarfile ___ Python tracker <http://bugs.python.org/issue11513> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11548] Passing format= to unpack_archive fails
New submission from Evan Dandrea : Passing the format keyword parameter to shutil.unpack_archive triggers an exception: Traceback (most recent call last): File "Lib/test/test_shutil.py", line 650, in test_unpack_archive unpack_archive(filename, tmpdir2, format=format) File "/home/evan/hg/cpython/Lib/shutil.py", line 741, in unpack_archive func(filename, extract_dir, **dict(format_info[1])) TypeError: 'function' object is not iterable This is due to that function incorrectly using the _UNPACK_FORMATS dictionary, which is fixed with the attached patch and test case. -- components: Library (Lib) files: fix_unpack_with_format.patch keywords: patch messages: 130948 nosy: ev, tarek priority: normal severity: normal status: open title: Passing format= to unpack_archive fails type: crash Added file: http://bugs.python.org/file21196/fix_unpack_with_format.patch ___ Python tracker <http://bugs.python.org/issue11548> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11503] Expand test coverage in posixpath
Evan Dandrea added the comment: Updated the patch to address Michael's concerns. -- Added file: http://bugs.python.org/file21221/test_posixpath_with_same_device.patch ___ Python tracker <http://bugs.python.org/issue11503> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11503] Expand test coverage in posixpath
Evan Dandrea added the comment: I've looked at the sameopenfile code, and can see no reason why it would not work on Windows. I've asked Brian to verify this. -- ___ Python tracker <http://bugs.python.org/issue11503> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11503] Expand test coverage in posixpath
Evan Dandrea added the comment: I haven't used addCleanup here, but have noted it for the future. In this case, using it would require adding another function to handle the reassignment, which I think is a bit more messy than the extra bit of indentation. -- ___ Python tracker <http://bugs.python.org/issue11503> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11513] Infinite recursion around raising an exception in tarfile
Evan Dandrea added the comment: *facepalm* Indeed, thanks for pointing that out and nice catch on the race condition. Attached is a patch to fix the issue as you've suggested, and adds a test case for it. -- keywords: +patch Added file: http://bugs.python.org/file21222/tarfile-fix-multiple-exception-on-enoent.patch ___ Python tracker <http://bugs.python.org/issue11513> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11513] Infinite recursion around raising an exception in tarfile
Changes by Evan Dandrea : Added file: http://bugs.python.org/file21223/tarfile-fix-multiple-exception-on-enoent.patch ___ Python tracker <http://bugs.python.org/issue11513> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11513] Infinite recursion around raising an exception in tarfile
Changes by Evan Dandrea : Removed file: http://bugs.python.org/file21222/tarfile-fix-multiple-exception-on-enoent.patch ___ Python tracker <http://bugs.python.org/issue11513> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11548] Passing format= to unpack_archive fails
Changes by Evan Dandrea : Added file: http://bugs.python.org/file21228/fix_unpack_with_format.patch ___ Python tracker <http://bugs.python.org/issue11548> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11548] Passing format= to unpack_archive fails
Changes by Evan Dandrea : Removed file: http://bugs.python.org/file21196/fix_unpack_with_format.patch ___ Python tracker <http://bugs.python.org/issue11548> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11560] Expand test coverage in shutil
New submission from Evan Dandrea : The attached patch increases the coverage in shutil. It makes the following changes: - Tests the code paths for file and directory copies across filesystems by mocking out rename. - Adds a test for shutil.copy. - Adds a test for shutil.copy2. - Tests shutil.unpack_archive with the format specified. - Tests the code path for creating the target directory in _make_tarball. I have tested this on Ubuntu natty and OSX 10.6.6. Note that this will fail until http://bugs.python.org/issue11548 is applied. -- components: Tests files: increase_test_shutil_coverage.patch keywords: patch messages: 131041 nosy: ev, tarek priority: normal severity: normal status: open title: Expand test coverage in shutil Added file: http://bugs.python.org/file21229/increase_test_shutil_coverage.patch ___ Python tracker <http://bugs.python.org/issue11560> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11513] chained exception/incorrect exception from tarfile.open on a non-existent file
Evan Dandrea added the comment: David, Thanks for the pointers. I've updated the patch hopefully adequately addressing your concerns. -- components: +Interpreter Core -Library (Lib) type: behavior -> Added file: http://bugs.python.org/file21277/tarfile-fix-multiple-exception-on-enoent.patch ___ Python tracker <http://bugs.python.org/issue11513> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11513] chained exception/incorrect exception from tarfile.open on a non-existent file
Changes by Evan Dandrea : Removed file: http://bugs.python.org/file21223/tarfile-fix-multiple-exception-on-enoent.patch ___ Python tracker <http://bugs.python.org/issue11513> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com