invalid behavior of curses.newpad().refresh()

Bug #1021783 reported by bellbind
This bug affects 3 people
Affects Status Importance Assigned to Milestone
python3.2 (Ubuntu)
Fix Released
Barry Warsaw
Fix Released

Bug Description

[Precise SRU Justification]

Valid python programs using the refresh method with the optional arguments on a curses.newpad object will fail with a similar exception:

Traceback (most recent call last):
  File "", line 10, in <module>
    pad.refresh(0, 0, 0, 0, size[0] - 1, size[1] - 1)
TypeError: refresh() takes exactly 0 arguments (6 given)

This breaks at least one of the examples in the python documentation and I believe limits the usefulness of the pad object, since it allows one to only display a portion of the pad with the refresh method.


Updates the ncursesw-include.diff patch with the version in quantal, adding /usr/include/ncursesw/ to the search path in This allows the build scripts to find curses and builds the curses module with the correct number of arguments to refresh.

[Regression Potential]

The regression potential should be minor since it just enables a build option already enabled on the python2.7 package (as well as python3.2 and python3.3 in quantal).

[Test Case]

Running the following code with python3 will produce the above exception without the patch, and prompt to "press q" to quit the script with the patch.

import curses

    screen = curses.initscr()

    pad = curses.newpad(10, 10)
    pad.addstr(0, 0, "press q")
    size = screen.getmaxyx()
    pad.refresh(0, 0, 0, 0, size[0] - 1, size[1] - 1)
    while True:
        ch = pad.getch()
        if ch == ord("q"):


There is invalid behavior of builtin curses module in amd64 version python3.2.

From API spec, `refresh()` method of a window object returned by `curses.newpad(h,w)` should accept 6 arguments; `pad.refresh(pt, pl, st, sl, sb, sr)`.


But python3.2 package in amd64 ubuntu precise does not accept arguments.

The code is worked well on python2.7 pakcage and self compiled python3.2.3.
There may be a package build problem at python3.2 or ncurses.

ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: python3.2 3.2.3-0ubuntu3
ProcVersionSignature: Ubuntu 3.2.0-26.41-generic 3.2.19
Uname: Linux 3.2.0-26-generic x86_64
ApportVersion: 2.0.1-0ubuntu8
Architecture: amd64
Date: Sat Jul 7 00:09:05 2012
 PATH=(custom, user)
SourcePackage: python3.2
UpgradeStatus: Upgraded to precise on 2012-03-21 (106 days ago)

Revision history for this message
bellbind (bellbind) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in python3.2 (Ubuntu):
status: New → Confirmed
Revision history for this message
Jason Conti (jconti) wrote :

Affects the package in quantal as well. Part of the patch to enable linking to libncursesw5 seems to have been dropped between python2.7 and python3.2, so looking at the build log we see:

checking ncurses.h usability... no
checking ncurses.h presence... no
checking for ncurses.h... no

But in the python2.7 build log, those are all yes. If HAVE_NCURSES_H is not set, we do not get WINDOW_HAS_FLAGS, which is checked to determine if pad.refresh() has arguments or not. (In Modules/_cursesmodule.c:PyCursesWindow_Refresh)

Attaching a debdiff which adds back the part of debian/patches/ncursesw-include.diff against to add /usr/include/ncursesw/ to CPPFLAGS when looking for the headers/checking features. Rebuilding with the patch and your test case succeeds.

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "python3.2-fix-curses.debdiff" of this bug report has been identified as being a patch in the form of a debdiff. The ubuntu-sponsors team has been subscribed to the bug report so that they can review and hopefully sponsor the debdiff. In the event that this is in fact not a patch you can resolve this situation by removing the tag 'patch' from the bug report and editing the attachment so that it is not flagged as a patch. Additionally, if you are member of the ubuntu-sponsors team please also unsubscribe the team from this bug report.

[This is an automated message performed by a Launchpad user owned by Brian Murray. Please contact him regarding any issues with the action taken in this bug report.]

tags: added: patch
Michael Terry (mterry)
Changed in python3.2 (Ubuntu):
assignee: nobody → Matthias Klose (doko)
Revision history for this message
Barry Warsaw (barry) wrote :

From-source build of Python 3.2 mercurial does not crash. Since I'm patch piloting today, I'll take ownership of the issue and review the fix.

Changed in python3.2 (Ubuntu):
assignee: Matthias Klose (doko) → Barry Warsaw (barry)
milestone: none → quantal-alpha-3
Revision history for this message
Barry Warsaw (barry) wrote :

I'll also note that this only affects Python 3.2 in Quantal; Python 3.3 does not crash.

Revision history for this message
Jason Conti (jconti) wrote :

My debdiff shouldn't be necessary anymore. It is fixed in the debian branch above (slightly differently), and it was fixed in python3.3 in the recent quantal upload (with the same debian/patches/ncursesw-configure.diff change).

Sorry, I should have removed the patch tag when I noticed the fix the other day.

Revision history for this message
Barry Warsaw (barry) wrote :

Thanks Jason. AFAICT, it looks like we can just sync the unstable version of Python 3.2 to Quantal now, since all of the Precise-era Ubuntu-specific changes have been merged back into the Debian package. I'll do some testing on Quantal and if looks good, I'll do the sync.

Revision history for this message
Barry Warsaw (barry) wrote :

Is this important enough for an SRU in Precise?

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package python3.2 - 3.2.3-3

python3.2 (3.2.3-3) unstable; urgency=low

  * Update to 20120709 from the 3.2 branch. Fixes:
    - Issue #15020: The program name used to search for Python's path is now
      "python3" under Unix, not "python".
    - Issue #15033: Fix the exit status bug when modules invoked using -m
      switch, return the proper failure return value (1).
    - Issue #12268: File readline, readlines and read() or readall() methods
      no longer lose data when an underlying read system call is interrupted.
      IOError is no longer raised due to a read system call returning EINTR
      from within these methods.
    - Issue #15142: Fix reference leak when deallocating instances of types
      created using PyType_FromSpec().
    - Issue #10053: Don't close FDs when FileIO.__init__ fails.
    - Issue #14990: Correctly fail with SyntaxError on invalid encoding
    - Issue #15247: FileIO now raises an error when given a file descriptor
      pointing to a directory.
    - Issue #5346: Preserve permissions of mbox, MMDF and Babyl mailbox
      files on flush().
    - Issue #10571: Fix the "--sign" option of distutils' upload command.
    - Issue #9559: If messages were only added, a new file is no longer
      created and renamed over the old file when flush() is called on an
      mbox, MMDF or Babyl mailbox.
    - Issue #14653: email.utils.mktime_tz() no longer relies on system
      mktime() when timezone offest is supplied.
    - Fix GzipFile's handling of filenames given as bytes objects.
    - Issue #15101: Make pool finalizer avoid joining current thread.
    - Issue #15036: Mailbox no longer throws an error if a flush is done
      between operations when removing or changing multiple items in mbox,
      MMDF, or Babyl mailboxes.
    - test_nntplib now tolerates being run from behind NNTP gateways that add
      "X-Antivirus" headers to articles.
    - Issue #15043: test_gdb is now skipped entirely if gdb security settings
      block loading of the gdb hooks.
    - Issue #13557: Clarify effect of giving two different namespaces to exec
      or execfile().
    - Issue #15300: Ensure the temporary test working directories are in the same
      parent folder when running tests in multiprocess mode from a Python build.
  * Lookup extension modules with a multiarch suffix too.
  * Include /usr/include/ncursesw in CPPFLAGS for the curses configure
    checks. Closes: #681007. LP: #1021783.
  * Fix running the testsuite.
  * Backport issue #13150: sysconfig no longer parses the Makefile and config.h
    files when imported, instead doing it at build time. This makes importing
    sysconfig faster and reduces Python startup time by 20%.
  * Don't build the _hashlib and _ssl extensions as a builtin, but as
    extensions. Addresses: #680930.
  * python3.2: Add a break for python-virtualenv (<<
  * For lto builds, use -g instead of -g1; filter out lto flags in the
    installed Makefile. Addresses: #681348.
  * Don't run the test_gdb test on mips/mipsel, not even in debug mode.

 -- Matthias Klose <email address hidden> Fri, 13 Jul 2012 21:40:01 +0200

Changed in python3.2 (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
bellbind (bellbind) wrote :

I reported the bug because of it is wanted to fix "for Precise" (not for Quantal).

I found the bug when I tried the Python3 Official HOWTO doc:
It uses newpad function.

But I do not know any packages using curses.newpad() with Python3. There may be reasons:
- python3 is minor than python now
- curses module is minor than other standard modules: os, io, xml
- newpad function is minor than essential functions for using curses: initscr, cbreak

The bug is just raise error at calling the function. the fix changes from not working programs to working well.
So I want the patch will be backport to Precise.

Revision history for this message
Jason Conti (jconti) wrote :

Updated the fix from quantal for the version of python3.2 in precise.

Jason Conti (jconti)
description: updated
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in python3.2 (Ubuntu Precise):
status: New → Confirmed
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Uploaded into precise-proposed, now pending approval.
Unsubscribing ubuntu-sponsors.
Thank you for your contribution!

Revision history for this message
Adam Conrad (adconrad) wrote : Please test proposed package

Hello bellbind, or anyone else affected,

Accepted python3.2 into precise-proposed. The package will build now and be available at in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please change the bug tag from verification-needed to verification-done. If it does not, change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at . Thank you in advance!

Changed in python3.2 (Ubuntu Precise):
status: Confirmed → Fix Committed
tags: added: verification-needed
Revision history for this message
Martine Rossi (rossi-marteen77) wrote :

Sur mon ordinateur Ubuntu, j'essais d'installer "python deb" et autres 4 installations de "python".. mais je n'y parviens pas..! On me dit: "Vérifiez votre connexion à Internet".. Je ne comprends pas..

Revision history for this message
Bradley M. Froehle (brad-froehle) wrote :

I can confirm that the provided test case fails in the old version (3.2.3-0ubuntu3) and passes with the package in precise-proposed (3.2.3-0ubuntu3.1).

tags: added: verification-done
removed: verification-needed
Revision history for this message
Scott Kitterman (kitterman) wrote : Update Released

The verification of this Stable Release Update has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regresssions.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package python3.2 - 3.2.3-0ubuntu3.1

python3.2 (3.2.3-0ubuntu3.1) precise-proposed; urgency=low

  * debian/patches/ncursesw-include.diff:
    - Refresh from quantal to fix curses build (LP: #1021783)
 -- Jason Conti <email address hidden> Thu, 26 Jul 2012 13:22:26 -0400

Changed in python3.2 (Ubuntu Precise):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.