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

Add ZipInfo.mode property #91356

Open
dignissimus mannequin opened this issue Apr 2, 2022 · 2 comments
Open

Add ZipInfo.mode property #91356

dignissimus mannequin opened this issue Apr 2, 2022 · 2 comments
Labels
3.11 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@dignissimus
Copy link
Mannequin

dignissimus mannequin commented Apr 2, 2022

BPO 47200
Nosy @Yhg1s, @ethanfurman, @serhiy-storchaka, @dignissimus
PRs
  • gh-91356: Add ZipInfo.mode attribute #32252
  • Files
  • sam_ezeh.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 = None
    closed_at = None
    created_at = <Date 2022-04-02.12:21:15.631>
    labels = ['type-feature', 'library', '3.11']
    title = 'Add ZipInfo.mode property'
    updated_at = <Date 2022-04-02.21:29:27.246>
    user = 'https://github.com/dignissimus'

    bugs.python.org fields:

    activity = <Date 2022-04-02.21:29:27.246>
    actor = 'ethan.furman'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2022-04-02.12:21:15.631>
    creator = 'sam_ezeh'
    dependencies = []
    files = ['50715']
    hgrepos = []
    issue_num = 47200
    keywords = ['patch']
    message_count = 1.0
    messages = ['416550']
    nosy_count = 5.0
    nosy_names = ['twouters', 'alanmcintyre', 'ethan.furman', 'serhiy.storchaka', 'sam_ezeh']
    pr_nums = ['32252']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue47200'
    versions = ['Python 3.11']

    @dignissimus
    Copy link
    Mannequin Author

    dignissimus mannequin commented Apr 2, 2022

    Initially, I was looking at bpo-18262 and saw the following Stack Overflow thread that was linked.

    https://stackoverflow.com/questions/434641/how-do-i-set-permissions-attributes-on-a-file-in-a-zip-file-using-pythons-zip/6297838

    I've attached a patch that gives ZipInfo objects a ZipInfo.mode property getter and setter to get and set the file mode.

    I considered adding ZipFile.chmod but I didn't know how it would work given that archives can contain duplicate files.

    As an aside, I wondered if there's a way to update file attributes inside zip archives without deleting and rewriting them and if not, whether it would be worthwhile to add one.

    @dignissimus dignissimus mannequin added 3.11 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Apr 2, 2022
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @gpshead
    Copy link
    Member

    gpshead commented Dec 21, 2023

    While the supplied patch adding a property for mode makes sense, I think it'd need to go a little further and handle things like the 0o40000 bit for Directory and whatever other potential bits zip files are able to represent. not just the base 9-bit posix mode values.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    Status: No status
    Development

    No branches or pull requests

    1 participant