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

gzip guessing of mode is ambiguous #72473

Closed
serhiy-storchaka opened this issue Sep 27, 2016 · 6 comments
Closed

gzip guessing of mode is ambiguous #72473

serhiy-storchaka opened this issue Sep 27, 2016 · 6 comments
Labels
3.9 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

BPO 28286
Nosy @serhiy-storchaka, @wm75
PRs
  • bpo-28286: Add tests for the mode argument of GzipFile. #4074
  • [3.6] bpo-28286: Add tests for the mode argument of GzipFile. (GH-4074) #4076
  • [2.7] bpo-28286: Add tests for the mode argument of GzipFile. (GH-4074). #4077
  • bpo-28286: Deprecate opening GzipFile for writing implicitly. #16417
  • Files
  • gzip_deprecate_implicit_write.patch
  • gzip_deprecate_implicit_write2.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 = <Date 2019-11-16.17:22:24.243>
    created_at = <Date 2016-09-27.14:01:44.838>
    labels = ['type-feature', 'library', '3.9']
    title = 'gzip guessing of mode is ambiguous'
    updated_at = <Date 2019-11-16.17:22:24.238>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2019-11-16.17:22:24.238>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-11-16.17:22:24.243>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2016-09-27.14:01:44.838>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['44843', '44939']
    hgrepos = []
    issue_num = 28286
    keywords = ['patch']
    message_count = 6.0
    messages = ['277515', '277907', '304739', '304743', '304744', '356756']
    nosy_count = 3.0
    nosy_names = ['nadeem.vawda', 'serhiy.storchaka', 'wolma']
    pr_nums = ['4074', '4076', '4077', '16417']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue28286'
    versions = ['Python 3.9']

    @serhiy-storchaka
    Copy link
    Member Author

    gzip.GzipFile can be open in two modes: reading and writing. The mode is specified by the mode parameter, but if it is not specified or is None, the mode is determined by the mode of passed file object. The problem is that the file object can support reading and writing. If the file object is opened with mode "rb", "rb+" or "wb+" (see also bpo-25341), GzipFile will be opened for reading. If the file object is opened with mode "wb", "ab", "ab+", "xb", or "xb+", GzipFile will be opened for writing. Modes "rb+", "wb+", "ab+" and "xb+" support reading and writing, and GzipFile's choose looks arbitrary.

    bz2 and lzma are free from this arbitrariness. The default value of the mode parameter is "r", and they never use file's mode as a guess.

    This feature of the gzip module is not tested. Changing the default value of mode to "r" doesn't break gzip tests. But for certainty we should first deprecate this feature before dropping it.

    @serhiy-storchaka serhiy-storchaka added 3.7 (EOL) end of life stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Sep 27, 2016
    @serhiy-storchaka
    Copy link
    Member Author

    Or maybe FutureWarning is better than DeprecationWarning.

    @jimjjewett jimjjewett mannequin changed the title gzip guessing of mode is ambiguilous gzip guessing of mode is ambiguous Oct 3, 2016
    @serhiy-storchaka
    Copy link
    Member Author

    New changeset bcbdd2f by Serhiy Storchaka in branch 'master':
    bpo-28286: Add tests for the mode argument of GzipFile. (bpo-4074)
    bcbdd2f

    @serhiy-storchaka
    Copy link
    Member Author

    New changeset 251de30 by Serhiy Storchaka (Miss Islington (bot)) in branch '3.6':
    bpo-28286: Add tests for the mode argument of GzipFile. (GH-4074) (bpo-4076)
    251de30

    @serhiy-storchaka
    Copy link
    Member Author

    New changeset f7d19b0 by Serhiy Storchaka in branch '2.7':
    [2.7] bpo-28286: Add tests for the mode argument of GzipFile. (GH-4074). (bpo-4077)
    f7d19b0

    @serhiy-storchaka
    Copy link
    Member Author

    New changeset a065232 by Serhiy Storchaka in branch 'master':
    bpo-28286: Deprecate opening GzipFile for writing implicitly. (GH-16417)
    a065232

    @serhiy-storchaka serhiy-storchaka added 3.9 only security fixes and removed 3.7 (EOL) end of life labels Nov 16, 2019
    @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
    3.9 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant