Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move tarfile.filemode() into stat module #59012

Closed
giampaolo opened this issue May 14, 2012 · 13 comments
Closed

Move tarfile.filemode() into stat module #59012

giampaolo opened this issue May 14, 2012 · 13 comments
Assignees
Labels
easy stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@giampaolo
Copy link
Contributor

BPO 14807
Nosy @terryjreedy, @gustaebel, @pitrou, @giampaolo
Files
  • filemode.patch
  • filemode.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/giampaolo'
    closed_at = <Date 2013-01-04.16:30:09.267>
    created_at = <Date 2012-05-14.13:04:37.705>
    labels = ['easy', 'type-feature', 'library']
    title = 'Move tarfile.filemode() into stat module'
    updated_at = <Date 2013-01-04.16:30:09.266>
    user = 'https://github.com/giampaolo'

    bugs.python.org fields:

    activity = <Date 2013-01-04.16:30:09.266>
    actor = 'giampaolo.rodola'
    assignee = 'giampaolo.rodola'
    closed = True
    closed_date = <Date 2013-01-04.16:30:09.267>
    closer = 'giampaolo.rodola'
    components = ['Library (Lib)']
    creation = <Date 2012-05-14.13:04:37.705>
    creator = 'giampaolo.rodola'
    dependencies = []
    files = ['25577', '25585']
    hgrepos = []
    issue_num = 14807
    keywords = ['patch', 'easy']
    message_count = 13.0
    messages = ['160621', '160643', '160650', '160656', '160658', '160726', '160757', '160759', '160760', '160840', '160864', '160865', '179040']
    nosy_count = 5.0
    nosy_names = ['terry.reedy', 'lars.gustaebel', 'pitrou', 'giampaolo.rodola', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue14807'
    versions = ['Python 3.3']

    @giampaolo
    Copy link
    Contributor Author

    As per:
    http://mail.python.org/pipermail/python-ideas/2012-May/015104.html
    Patch is in attachment.

    @giampaolo giampaolo added stdlib Python modules in the Lib dir easy labels May 14, 2012
    @pitrou
    Copy link
    Member

    pitrou commented May 14, 2012

    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.

    @terryjreedy
    Copy link
    Member

    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.

    1. 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.

    1. Misc/NEWS entry suggestion:
    • bpo-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.
    1. stat module doc entry.

    @terryjreedy terryjreedy added the type-feature A feature request or enhancement label May 14, 2012
    @giampaolo
    Copy link
    Contributor Author

    Updated patch in attachment.

    @terryjreedy
    Copy link
    Member

    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.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 15, 2012

    New changeset 492e6c6a01bb by Giampaolo Rodola' in branch 'default':
    bpo-14807: move undocumented tarfile.filemode() to stat.filemode(). Add tarfile.filemode alias with deprecation warning.
    http://hg.python.org/cpython/rev/492e6c6a01bb

    @giampaolo giampaolo self-assigned this May 15, 2012
    @pitrou pitrou reopened this May 15, 2012
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 15, 2012

    New changeset 539fbd6e58f6 by Giampaolo Rodola' in branch 'default':
    bpo-14807: fix bb failure due to symlink test relying on hard-coded permissions
    http://hg.python.org/cpython/rev/539fbd6e58f6

    @giampaolo
    Copy link
    Contributor Author

    Thanks. It should now be fixed.

    @pitrou
    Copy link
    Member

    pitrou commented May 16, 2012

    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

    @pitrou pitrou reopened this May 16, 2012
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 16, 2012

    New changeset 39d24533c6b7 by Giampaolo Rodola' in branch 'default':
    bpo-14807: fix BB failures on Windows - avoid to to rely too many details of the mode string.
    http://hg.python.org/cpython/rev/39d24533c6b7

    @giampaolo
    Copy link
    Contributor Author

    Let's see how it goes now.

    @giampaolo
    Copy link
    Contributor Author

    Previous issue should have been fixed by now.
    Closing.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    easy stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants