This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Incorrect division in []
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.1
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: alfps, benjamin.peterson, brian.curtin
Priority: normal Keywords: needs review, patch

Created on 2010-01-12 12:01 by alfps, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit alfps, 2010-01-12 12:04
issue7681.diff brian.curtin, 2010-01-13 00:19 patch against release31-maint, r77454
Messages (6)
msg97629 - (view) Author: Alf P. Steinbach (alfps) Date: 2010-01-12 12:01
CPython 3.1.1 in Windows XP.

Traceback (most recent call last):
  File "C:\Documents and Settings\Alf\sound\", 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


"/" needs to be changed to "//" in lines and 243 464 of []
msg97630 - (view) Author: Alf P. Steinbach (alfps) Date: 2010-01-12 12:04
Sorry, here's correct error message:

Traceback (most recent call last):
  File "C:\Documents and Settings\Alf\sound\", line 8, in <module>
    writer.writeframes( b"\0"*2*4 )
  File "C:\Program Files\cpython\python31\lib\", line 432, in writeframes
  File "C:\Program Files\cpython\python31\lib\", line 416, in writeframesraw
  File "C:\Program Files\cpython\python31\lib\", line 459, in _ensure_header_written
  File "C:\Program Files\cpython\python31\lib\", 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
msg97633 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-01-12 15:05
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?
msg97668 - (view) Author: Alf P. Steinbach (alfps) Date: 2010-01-12 22:31
No, sorry, the bugs in [] 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 [] had fixed that in some places. But he/she forgot two places.

Cheers & hth.,

- Alf
msg97673 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-01-13 00:19
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.
msg97683 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2010-01-13 03:50
Thanks for the patch! Applied in r77459.
Date User Action Args
2022-04-11 14:56:56adminsetgithub: 51930
2010-01-13 03:50:27benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg97683

resolution: fixed
2010-01-13 00:19:44brian.curtinsetfiles: + issue7681.diff
title: Incorrect division in [] causing crash -> Incorrect division in []
messages: + msg97673

keywords: + patch, needs review
type: behavior
stage: needs patch -> patch review
2010-01-12 22:31:16alfpssetmessages: + msg97668
2010-01-12 15:05:14brian.curtinsetpriority: normal

nosy: + brian.curtin
messages: + msg97633

type: crash -> (no value)
stage: needs patch
2010-01-12 12:04:02alfpssetfiles: +

messages: + msg97630
2010-01-12 12:01:59alfpssetfiles: -
2010-01-12 12:01:21alfpscreate