Pewarta Proxy

📋 Server Request & Proxy Logs

Loading active proxy settings...
Developed by Khairul Adha (adhexa.id)
Mengambil log server...

⚙️ Pengaturan Proxy Target

Skip to content

BZ2File objects do not have name attribute #68446

Closed as not planned
Closed as not planned

Description

@jojkosivek
BPO 24258
Nosy @stestagg, @hrik2001
Files
  • bz2file.tar: tar ball with test and example of bz2 behaviour
  • bz2.name.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 2015-05-21.09:16:55.969>
    labels = ['type-bug', '3.8', '3.9', '3.10', '3.11', 'library']
    title = 'BZ2File objects do not have name attribute'
    updated_at = <Date 2021-04-27.13:05:23.760>
    user = 'https://bugs.python.org/jojkosivek'

    bugs.python.org fields:

    activity = <Date 2021-04-27.13:05:23.760>
    actor = 'roysmith'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2015-05-21.09:16:55.969>
    creator = 'jojko.sivek'
    dependencies = []
    files = ['39452', '49991']
    hgrepos = ['311']
    issue_num = 24258
    keywords = ['patch']
    message_count = 7.0
    messages = ['243743', '244095', '244622', '244623', '392035', '392059', '392069']
    nosy_count = 7.0
    nosy_names = ['roysmith', 'nadeem.vawda', 'jcd', 'jojko.sivek', 'Hasan Diwan', 'stestagg', 'hrik2001']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue24258'
    versions = ['Python 3.8', 'Python 3.9', 'Python 3.10', 'Python 3.11']

    Activity

    1. jojkosivek commented on May 21, 2015

      jojkosivekmannequin
      MannequinAuthor

      Unlike GzipFile the BZ2File does not have defined name attribute. The reading of this attribute results in: "AttributeError: 'BZ2File' object has no attribute 'name'".

      This is truly missing feature and wrong behaviour, compare:
      https://hg.python.org/releasing/3.4.3/file/933c3041d548/Lib/gzip.py
      and
      https://hg.python.org/releasing/3.4.3/file/933c3041d548/Lib/bz2.py

      In addition to that the BZ2File did have name attribute in python 2.7.* .

      In attachment there is tar ball with example files, expected results in python 3 and results in python 2.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or error
      on May 21, 2015
    3. jcd commented on May 26, 2015

      jcdmannequin
      Mannequin

      I'd be happy to take a look at this one, if no one else is working on it.

    4. jcd commented on Jun 2, 2015

      jcdmannequin
      Mannequin

      I've got a fix for this now. In working on it, I've discovered that not all file-like objects have a .name attribute. io.BytesIO (which is used all over the test suite) does not. I've written a patch that always creates a .name attribute on BZ2File, but sets it to None if the associated file-like object has no .name.

      See the linked branch

    5. jcd commented on Jun 2, 2015

      jcdmannequin
      Mannequin

      It's probably too late for this to get into 3.5, since we're already in betas. Pushing back to 3.6.

    6. HasanDiwan commented on Apr 27, 2021

      HasanDiwanmannequin
      Mannequin

      Patch adds a bz2.BZ2File.name property corresponding to the filename passed in.

    7. stestagg commented on Apr 27, 2021

      stestaggmannequin
      Mannequin

      Please may you add a test that uses "io.BytesIO()" as the filename argument. BytesIO() objects do not have a 'name' attribute

    8. roysmith commented on Apr 27, 2021

      roysmithmannequin
      Mannequin

      The https://bitbucket.org/cliff/cpython#python24258 URL 404's

      Looking at the attached bz2.py diff, I would change:

               if isinstance(filename, (str, bytes, os.PathLike)):
                   self._fp = _builtin_open(filename, mode)
      +            self.filename = filename
                   self._closefp = True
                   self._mode = mode_code

      to special-case os.PathLike and do:

                  self.filename = str(filename)

      I would expect BZ2File.name to be a string. Returning a PathLike means lots of legitimate string methods will not work on it. Also, it should be "name" as an attribute, not "name()" as a method, to match other existing interfaces.

    9. transferred this issue fromon Apr 10, 2022
    10. serhiy-storchaka commented on Feb 26, 2024

      @serhiy-storchaka
      Member

      It is the part of more complex issue #115961.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.10 (EOL)end of life3.11only security fixes3.8 (EOL)end of life3.9 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

      Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions