This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Unsupported provider

classification
Title: Move tarfile.filemode() into stat module
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: giampaolo.rodola Nosy List: giampaolo.rodola, lars.gustaebel, pitrou, python-dev, terry.reedy
Priority: normal Keywords: easy, patch

Created on 2012-05-14 13:04 by giampaolo.rodola, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
filemode.patch giampaolo.rodola, 2012-05-14 13:04 review
filemode.patch giampaolo.rodola, 2012-05-14 18:59 review
Messages (13)
msg160621 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2012-05-14 13:04
As per:
http://mail.python.org/pipermail/python-ideas/2012-May/015104.html
Patch is in attachment.
msg160643 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-05-14 17:28
I'm not sure filemode() is the best name for this. On the other hand, I don't have any suggestion.
I don't understand why you're using atexit. tearDown() and addCleanup() are your friends.
The call_safely thing also looks unwarranted. support.unlink() should be able to help you.
msg160650 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2012-05-14 18:00
1. After careful check, I am convince that converted _filemode_table (now private) is correct. Ditto for copied filemode function with adjusted docstring.

2. New test_stat.py is nice. I believe there is a new style of actually running the tests that somehow collects the list of TestCase subclasses without having to hand edit the run_unittest() call when new ones are added. I think it was briefly discussed on pydev list, but remenber nothing else. 

I mention this because I wonder if you think stat should have more tests (and TestCase classes). If so, a new issue could be opened after this is applied and mentioned on mentor list as an entry level issue for newer contributors.

3. I think the back compatibility alias should be wrapped with a deprecation warning. I believe the standard method would be something like the following

import warnings
def filemode(mode):
    "Deprecated in this location; use stat.filemode."
    warnings.warn("The undocumented tarfile.filemode function\n"
                  "has been moved to stat and documented there.",
                   DeprecationWarning, 2)
    return stat.filemode(mode)

Removal could be scheduled for 3.5 if not 3.4. There apparently is a way (unknown to me) to add a test that will fail in the future as a reminder.

4. Misc/NEWS entry suggestion:

- Issue 14807: Move undocumented tarfile.filemode() to stat.filemode() and add doc entry. Add tarfile.filemode alias with deprecation warning. Schedule alias for removal in 3.5.

5. stat module doc entry.
msg160656 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2012-05-14 18:59
Updated patch in attachment.
msg160658 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2012-05-14 19:16
Looks good enough to me except for the alias docstring. If someone does dir(tarfile) and help(filemode), they should get the message that it is a deprecated alias and should not use it.
msg160726 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-05-15 13:30
New changeset 492e6c6a01bb by Giampaolo Rodola' in branch 'default':
#14807: move undocumented tarfile.filemode() to stat.filemode(). Add tarfile.filemode alias with deprecation warning.
http://hg.python.org/cpython/rev/492e6c6a01bb
msg160757 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-05-15 20:03
Buildbot failures:
http://www.python.org/dev/buildbot/all/builders/AMD64%20FreeBSD%209.0%203.x/builds/2540
http://www.python.org/dev/buildbot/all/builders/x86%20Tiger%203.x/builds/4572
msg160759 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-05-15 20:21
New changeset 539fbd6e58f6 by Giampaolo Rodola' in branch 'default':
#14807: fix bb failure due to symlink test relying on hard-coded permissions
http://hg.python.org/cpython/rev/539fbd6e58f6
msg160760 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2012-05-15 20:21
Thanks. It should now be fixed.
msg160840 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-05-16 12:12
And there are test failures under Windows too :)

======================================================================
ERROR: test_link (test.test_stat.TestFilemode)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\cygwin\home\db3l\buildarea\3.x.bolen-windows\build\lib\test\test_stat.py", line 42, in test_link
    os.symlink(os.getcwd(), TESTFN)
NotImplementedError: CreateSymbolicLinkW not found

======================================================================
FAIL: test_directory (test.test_stat.TestFilemode)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\cygwin\home\db3l\buildarea\3.x.bolen-windows\build\lib\test\test_stat.py", line 38, in test_directory
    self.assertEqual(get_mode(), 'drwx------')
AssertionError: 'drwxrwxrwx' != 'drwx------'
- drwxrwxrwx
+ drwx------


======================================================================
FAIL: test_mode (test.test_stat.TestFilemode)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\cygwin\home\db3l\buildarea\3.x.bolen-windows\build\lib\test\test_stat.py", line 27, in test_mode
    self.assertEqual(get_mode(), '-rwx------')
AssertionError: '-rw-rw-rw-' != '-rwx------'
- -rw-rw-rw-
+ -rwx------


http://www.python.org/dev/buildbot/all/builders/x86%20Windows7%203.x/builds/4962/steps/test/logs/stdio
msg160864 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-05-16 14:03
New changeset 39d24533c6b7 by Giampaolo Rodola' in branch 'default':
#14807: fix BB failures on Windows - avoid to to rely too many details of the mode string.
http://hg.python.org/cpython/rev/39d24533c6b7
msg160865 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2012-05-16 14:04
Let's see how it goes now.
msg179040 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2013-01-04 16:30
Previous issue should have been fixed by now.
Closing.
History
Date User Action Args
2022-04-11 14:57:30adminsetgithub: 59012
2013-01-04 16:30:09giampaolo.rodolasetstatus: pending -> closed

messages: + msg179040
2013-01-04 15:13:14serhiy.storchakasetstatus: open -> pending
2012-05-16 14:04:48giampaolo.rodolasetmessages: + msg160865
2012-05-16 14:03:13python-devsetmessages: + msg160864
2012-05-16 12:12:42pitrousetstatus: closed -> open

messages: + msg160840
2012-05-15 20:21:41giampaolo.rodolasetstatus: open -> closed

messages: + msg160760
2012-05-15 20:21:08python-devsetmessages: + msg160759
2012-05-15 20:03:56pitrousetstatus: closed -> open

messages: + msg160757
2012-05-15 13:34:44giampaolo.rodolasetassignee: giampaolo.rodola
2012-05-15 13:33:48giampaolo.rodolasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2012-05-15 13:30:30python-devsetnosy: + python-dev
messages: + msg160726
2012-05-14 19:16:42terry.reedysetmessages: + msg160658
2012-05-14 18:59:10giampaolo.rodolasetfiles: + filemode.patch

messages: + msg160656
2012-05-14 18:00:01terry.reedysettype: enhancement
messages: + msg160650
2012-05-14 17:30:42lars.gustaebelsetnosy: + lars.gustaebel
2012-05-14 17:28:16pitrousetnosy: + pitrou

messages: + msg160643
stage: patch review
2012-05-14 13:04:37giampaolo.rodolacreate