Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add name and mode attributes to compressed file-like objects #115961

Closed
Assignees
serhiy-storchaka
Labels
type-featureA feature request or enhancement
@serhiy-storchaka

Description

@serhiy-storchaka

Feature or enhancement

Regular file objects returned by theopen() building havename andname andmode attributes. Some code may use these optional attributes for different purposes, for example to distinguish readable files from writable files, binary files from text files, or just for formatting the repr or error messages. For example:

There are several file-like objects in compressing modulesgzip,bz2 andlama and archiving moduleszipfile andtarfile. They usually implement the raw or buffered file protocols fromio, but not always havename andmode attributes, and when they have, they not always have common semantic.

GzipFile, unlike toBZ2File andLZMAFile, hasname andmode attributes, butmode is an integer, that confusestarfile (see#62775).

ZipExtFile has themode attribute which is always'r'. It is a legacy from Python 2, when it could also be'U' or'rU' for files with universal newlines. But this mode was removed long time ago, and since it is a binary file, its mode should be'rb'.

See also#68446,#91373,#91374. I opened this issue because consider it all the parts of larger image.

Linked PRs

Metadata

Metadata

Labels

type-featureA feature request or enhancement

Projects

Status

Done

Status

Done

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp