[Python-bugs-list] [ python-Bugs-775985 ] Solaris error doing a print

SourceForge.net noreply@sourceforge.net
Mon, 28 Jul 2003 21:35:13 -0700


Bugs item #775985, was opened at 2003-07-23 02:18
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=775985&group_id=5470

Category: Python Interpreter Core
Group: Python 2.3
Status: Open
Resolution: None
Priority: 7
Submitted By: Mark Hammond (mhammond)
Assigned to: Nobody/Anonymous (nobody)
Summary: Solaris error doing a print

Initial Comment:
As seen on Jeff Hobb's box.

print "Registering '%s' (%s)" % (reg_contractid, fname)
  File
"/usr/local/python-2.3/lib/python2.3/encodings/__init__.py",
line 84, in search_function
    globals(), locals(), _import_tail)
ValueError: Empty module name

It seems that this shell has an empty "LANG" var setup
- deleting this var seems to solve the problem.

Looking in sysmodule.c, I see:

	if(codeset && isatty(fileno(stdin))){
(and a similar one for stdout).  Should this be:
	if(codeset && *codeset && isatty(fileno(stdin))){

to prevent an empty name?  Or better, should we check
the encoding is actually installed?

I will mail Jeff and ask him to attach comments on the
version or anything else.

----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2003-07-29 06:35

Message:
Logged In: YES 
user_id=21627

This is not reproducable on Linux. nl_langinfo(CODESET) will
always give a non-empty string. If LANG is not set, the user
thereby requests the "POSIX" locale, and its codeset is
ANSI_X3.4-1968.

So it *is* a bug in that Solaris version that it returns an
empty string; the empty string is a valid return value only
if the argument to nl_langinfo was invalid. Since the system
does support querying the CODESET in principle, it should
not be possible to ever get an empty string.

----------------------------------------------------------------------

Comment By: Jeffrey Hobbs (hobbs)
Date: 2003-07-29 06:08

Message:
Logged In: YES 
user_id=72656

I think you have to unset LANG rather than set to "", but I'm 
not really understanding this one, so I defer to Mark.

----------------------------------------------------------------------

Comment By: Barry A. Warsaw (bwarsaw)
Date: 2003-07-29 05:15

Message:
Logged In: YES 
user_id=12800

Before I can comment on this for 2.3 (and time is very
quickly running out), can you provide:

1. a recipe to reproduce this on RH9 or other Linux?  I
tried in bash:

% export LANG=""
% ./python
>>> print "foo"
foo
>>>

i.e. nothing happened, so I'm sure I'm not doing this right.
 Also, any possibility of a test case?


----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2003-07-23 07:16

Message:
Logged In: YES 
user_id=21627

I'm tempted to declare this a platform bug: Both Linux and
later Solaris versions set the CODEPAGE to ASCII for an
empty LANG (i.e. assume this is the "C" locale).

Still, checking whether the encoding is present is probably
a good idea. Unfortunately, it cannot be done right there,
since loading of codecs does not work yet inside _PySys_Init.

So as a work-around for 2.3, we should check for non-empty
strings, and leave checking for supported encodings for 2.3.1.
Patch attached.

----------------------------------------------------------------------

Comment By: Jeffrey Hobbs (hobbs)
Date: 2003-07-23 02:26

Message:
Logged In: YES 
user_id=72656

python 2.3rc1, build --enable-shared.

Solaris uname -a:
SunOS knife 5.6 Generic_105181-05 sun4u sparc SUNW,Ultra-
250

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=775985&group_id=5470