Python2.5.4 curses.initscr() fails

Bug #369203 reported by Marko Mahnič
36
This bug affects 6 people
Affects Status Importance Assigned to Milestone
python2.5 (Ubuntu)
Fix Released
High
Scott Kitterman
Jaunty
Won't Fix
Undecided
Unassigned

Bug Description

Binary package hint: python2.5

IMPACT: debian/patches/curses_init.dpatch is a packport of a patch from Python 2.6, but it is incomplete. In curses.initscr(), it uses of _os and _sys without importing those modules. This causes curses.initscr to immediately raise an exception.

DEVELOPMENT: Fixed in Karmic using the same patch to curses_init.dpatch as is being suggested for Jaunty.

PATCH: http://launchpadlibrarian.net/30833073/python2.5_2.5.4-1ubuntu4.1.debdiff

REPRODUCE: python2.5 -c 'import curses; curses.initscr()'

REGRESSION: Minimal. This debdiff only affects one module, and it only adds imports for modules which were previously unimported.

============
Original bug description:

--------test.py----------
import curses
curses.initscr()
---------------------------
$>python2.5 test.py

Traceback (most recent call last):
  File "test.py", line 2, in <module>
    curses.initscr()
  File "/usr/lib/python2.5/curses/__init__.py", line 32, in initscr
    setupterm(term=_os.environ.get("TERM", "unknown"),
NameError: global name '_os' is not defined

FIX: add
import os as _os
import sys as _sys

to /usr/lib/python2.5/curses/__init__.py

ProblemType: Bug
Architecture: i386
DistroRelease: Ubuntu 9.04
Package: python2.5 2.5.4-1ubuntu4 [modified: usr/lib/python2.5/curses/__init__.py]
ProcEnviron:
 LC_TIME=sl_SI.utf8
 LANGUAGE=
 PATH=(custom, user)
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: python2.5
Uname: Linux 2.6.28-11-generic i686

Revision history for this message
Marko Mahnič (marko-mahnic) wrote :
Revision history for this message
chris emery (chrisemery) wrote :

I can confirm the bug and the fix (thanks for reporting mmarko).

This also affects ipython's 'magic' commands as they call curses.initscr() (e.g. ipython, from app import class, class? -> NameError: global name '_os' is not defined)

Revision history for this message
Matthew Brett (matthew-brett) wrote :

I also confirm bug and fix. The bug is introduced in the python2.5_2.5.4-1ubuntu4.diff patchset for the python2.4 package; it appears to be doing an incomplete backport of the 2.6 code.

Revision history for this message
Evan Broder (broder) wrote :
Changed in python2.5 (Ubuntu):
status: New → Confirmed
Revision history for this message
agent 8131 (agent-8131) wrote :

I can confirm that this patch fixes the behavior with pygrub that I reported in bug 395321. I think this fix should be an SRU for 9.04 as pygrub completely stopped working in 9.04 due to this bug but had worked on previous releases.

Revision history for this message
Alan Franzoni (alanfranz) wrote :

IPython stopped working as well. The root cause seems to be the application of curses-init.dpatch (which was allegedly created for python2.6) on python <= 2.5 interpreters in the latest 2.5.4-1ubuntu4 release (in Jaunty, not sure which release introduces such patch in other distro version).

If the additional patch provided by Evan Broder can't be applied for some reason, just prevent the curses-init.dpatch from being applied in 2.5! It seems pretty pointless to apply a patch which should improve functionality which screws up everything instead.

Revision history for this message
Scott Kitterman (kitterman) wrote :

[23:31:23] <ScottK> doko: What do you think about the proposed fix in 369203?
[11:54:37] <doko> ScottK: looks ok
[11:54:43] <ScottK> doko: Thanks.

I'm looking at sponsoring this.

Changed in python2.5 (Ubuntu):
assignee: nobody → Scott Kitterman (kitterman)
importance: Undecided → High
status: Confirmed → In Progress
Changed in python2.5 (Ubuntu):
status: In Progress → Won't Fix
status: Won't Fix → Fix Released
Revision history for this message
Evan Broder (broder) wrote :

Here's a patch for an SRU to Jaunty. I'll update the bug description in a moment.

I have builds with this patch in my PPA (https://launchpad.net/~broder/+archive/ubuntu-tests), and the patch seems to work on my Jaunty machine.

description: updated
summary: - Python2.5.4 curses.initscr() fails
+ [Jaunty SRU] Python2.5.4 curses.initscr() fails
Revision history for this message
Martin Pitt (pitti) wrote :

I don't think that this is very important, since 2.6 is the default Python in Jaunty. However, the patch looks fine, so please upload.

summary: - [Jaunty SRU] Python2.5.4 curses.initscr() fails
+ Python2.5.4 curses.initscr() fails
Revision history for this message
Martin Pitt (pitti) wrote :

Jaunty is non-LTS, this is fixed in Karmic, and 2.5 is not even the default Python in Jaunty, so I don't think we need to bother with this still

Changed in python2.5 (Ubuntu Jaunty):
status: New → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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