Skip to content

Incorrect division in [wave.py] #51930

Closed
Closed

Description

@alfps
mannequin
BPO 7681
Nosy @benjaminp, @briancurtin
Files
  • error.py
  • issue7681.diff: patch against release31-maint, r77454
  • 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 2010-01-13.03:50:27.961>
    created_at = <Date 2010-01-12.12:01:21.872>
    labels = ['type-bug', 'library']
    title = 'Incorrect division in [wave.py]'
    updated_at = <Date 2010-01-13.03:50:27.953>
    user = 'https://bugs.python.org/alfps'

    bugs.python.org fields:

    activity = <Date 2010-01-13.03:50:27.953>
    actor = 'benjamin.peterson'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-01-13.03:50:27.961>
    closer = 'benjamin.peterson'
    components = ['Library (Lib)']
    creation = <Date 2010-01-12.12:01:21.872>
    creator = 'alfps'
    dependencies = []
    files = ['15835', '15846']
    hgrepos = []
    issue_num = 7681
    keywords = ['patch', 'needs review']
    message_count = 6.0
    messages = ['97629', '97630', '97633', '97668', '97673', '97683']
    nosy_count = 3.0
    nosy_names = ['benjamin.peterson', 'brian.curtin', 'alfps']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'patch review'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue7681'
    versions = ['Python 3.1']

    Activity

    1. alfps commented on Jan 12, 2010

      alfpsmannequin
      MannequinAuthor

      CPython 3.1.1 in Windows XP.

      Traceback (most recent call last):
        File "C:\Documents and Settings\Alf\sound\error.py", line 6, in <module>
          writer.setframerate( framerate )
      NameError: name 'framerate' is not defined
      Exception wave.Error: Error('sampling rate not specified',) in <bound method Wave_write.__del__ of <wave.Wave_write obje
      ct at 0x00FE87F0>> ignored

      TO FIX:

      "/" needs to be changed to "//" in lines and 243 464 of [wave.py]

    2. added
      type-crashA hard crash of the interpreter, possibly with a core dump
      stdlibStandard Library Python modules in the Lib/ directory
      on Jan 12, 2010
    3. alfps commented on Jan 12, 2010

      alfpsmannequin
      MannequinAuthor

      Sorry, here's correct error message:

      Traceback (most recent call last):
        File "C:\Documents and Settings\Alf\sound\error.py", line 8, in <module>
          writer.writeframes( b"\0"*2*4 )
        File "C:\Program Files\cpython\python31\lib\wave.py", line 432, in writeframes
          self.writeframesraw(data)
        File "C:\Program Files\cpython\python31\lib\wave.py", line 416, in writeframesraw
          self._ensure_header_written(len(data))
        File "C:\Program Files\cpython\python31\lib\wave.py", line 459, in _ensure_header_written
          self._write_header(datasize)
        File "C:\Program Files\cpython\python31\lib\wave.py", line 472, in _write_header
          self._sampwidth * 8, 'data'))
      struct.error: required argument is not an integer
      Exception struct.error: 'required argument is not an integer' in <bound method Wave_write.__del__ of <wave.Wave_write ob
      ject at 0x00FE87F0>> ignored
    4. briancurtin commented on Jan 12, 2010

      @briancurtin
      Member

      In your example, the "n_frames" name does not exist, which is causing the problem. In your first comment, "framerate" also did not exist.

      I don't know what a proper frame rate value is, but I just put 10 in there and it worked fine. Can you confirm?

    5. removed
      type-crashA hard crash of the interpreter, possibly with a core dump
      on Jan 12, 2010
    6. alfps commented on Jan 12, 2010

      alfpsmannequin
      MannequinAuthor

      No, sorry, the bugs in [wave.py] have nothing to do with a name IN A COMMENT in the trivial code to exercise the bugs.

      To reproduce the crash, just run the supplied code with Python 3.1.1 in Windows XP.

      The cause of the crash is, as I pointed out, use of Python 2.x "/" division instead of Python 3.x "//" division. The author of [wave.py] had fixed that in some places. But he/she forgot two places.

      Cheers & hth.,

      • Alf
    7. briancurtin commented on Jan 13, 2010

      @briancurtin
      Member

      There is no crash, but I see what you are saying now.
      Patch to correct the two divisions and a test similar to your example.

    8. changed the title [-]Incorrect division in [wave.py] causing crash[/-] [+]Incorrect division in [wave.py][/+] on Jan 13, 2010
    9. benjaminp commented on Jan 13, 2010

      @benjaminp
      Contributor

      Thanks for the patch! Applied in r77459.

    10. transferred this issue fromon Apr 10, 2022
    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

      stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions