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.

classification
Title: Calling tparm from extension lib fails in Python 2.5
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 2.6
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: ajaksu2, loewis, nnorwitz, richyk
Priority: low Keywords:

Created on 2007-02-13 17:27 by richyk, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
testlib.cc richyk, 2007-02-13 17:27
Messages (10)
msg31256 - (view) Author: Richard B. Kreckel (richyk) Date: 2007-02-13 17:27
Attached is a little C++ module that fetches the terminal capability string for turning off all attributes and runs it through tparm(). (All this is done in a static Ctor of a class without init function, but never mind.)

Compile with:
g++ -c testlib.cc
g++ testlib.o -o testlib.so -shared -Wl,-soname,testlib.so -lncurses

On SuSE Linux 10.1 (and older), I get the expected behavior:

Python 2.4.2 (#1, Oct 13 2006, 17:11:24) 
[GCC 4.1.0 (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import testlib
Terminal is "xterm"
Dump of sgr0: 1b 5b 30 6d
Dump of instance: 1b 5b 30 6d
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: dynamic module does not define init function (inittestlib)
>>> 

However, on SuSE Linux 10.2, tparm creates a NULL pointer:
Python 2.5 (r25:51908, Jan  9 2007, 16:59:32) 
[GCC 4.1.2 20061115 (prerelease) (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import testlib
Terminal is "xterm"
Dump of sgr0: 1b 5b 30 6d
Rats! tparm made a NULL pointer!
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dynamic module does not define init function (inittestlib)
>>> 

Why, oh why?
msg31257 - (view) Author: Richard B. Kreckel (richyk) Date: 2007-02-14 08:52
I suspect that this is a duplicate of Bug [1548092].
Note that, there it is asserted that tparm returns NULL on certain invalid strings.
That does not seem to be true. It returns NULL for valid trivial strings, too.
msg31258 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2007-02-14 21:24
I fail to see the bug. The exception precisely describes the error in your code

ImportError: dynamic module does not define init function (inittestlib)

Why do you expect any meaningful behavior in the presence of this error? Your shared library isn't an extension module.

If you think it is related to #1548092, please try out the subversion trunk, which has fixed this bug.
msg31259 - (view) Author: Richard B. Kreckel (richyk) Date: 2007-02-22 12:25
The error message about the undefined init function is a red herring. The example is actually a stripped-down testcase from a much larger Boost.Python module, which of course does have an init function. The point here is the NULL pointer returned by tparm.
msg31260 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2007-02-25 22:16
Can you test with 2.5 from SVN and confirm your program works in the complete context?
msg31261 - (view) Author: Richard B. Kreckel (richyk) Date: 2007-03-12 11:30
Sorry, I cannot do that test anytime soon.
(I've not enough time and my company doesn't let me access your SVN.)
msg31262 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2007-03-13 04:53
I can't help with the time factor, but I can with the access to svn.  You can download a snapshot here:

http://svn.python.org/snapshots/python25.tar.bz2

There are snapshots for the trunk as well as the active release branch.

So if you can get a little free time, it would be great if you could download the tarball and test.  Thanks.
msg84652 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2009-03-30 21:25
I'll close this unless someone can confirm for 2.6.
msg84762 - (view) Author: Richard B. Kreckel (richyk) Date: 2009-03-31 08:26
I just tried Python 2.6 (r26:66714, Feb 21 2009, 05:33:00) from SUSE
Linux Enterprise Server 11 (i586) and it didn't fail. This appears to
have been fixed, somehow.
msg84971 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2009-04-01 03:22
Thanks, Richard!

If someone confirms it, please reopen.
History
Date User Action Args
2022-04-11 14:56:22adminsetgithub: 44578
2009-04-01 03:22:29ajaksu2setstatus: pending -> closed
resolution: out of date
messages: + msg84971

stage: test needed -> resolved
2009-03-31 08:26:36richyksetmessages: + msg84762
2009-03-30 21:25:04ajaksu2setstatus: open -> pending
priority: normal -> low
type: behavior

versions: + Python 2.6
nosy: + ajaksu2

messages: + msg84652
stage: test needed
2007-02-13 17:27:43richykcreate