I've checked a band-aid fix for this (r56878). The band-aid works by pre-importing the latin-1 codec (and also the utf-8 codec, just to be sure) *before* setting sys.stdout and sys.stderr (this happens in site.py, in installnewio()).
This is a horrible hack though, and only works because, as long as sys.stderr isn't set, the call to PyFile_WriteString() in mywrite() (in sysmodule.c) returns a quick error, causing mywrite() to write directly to C's stderr. I've also checked in a change to PyFile_WriteString() to call PyUnicode_FromString() instead of PyString_FromString(), but that doesn't appear to make any difference (r56879). FWIW, I've attached an edited version of the traceback mailed by Neal; the email mangled the formatting too much. Maybe someone else has a bright idea. --Guido On 8/7/07, Neal Norwitz <[EMAIL PROTECTED]> wrote: > The wiki seems to be done, so sorry for the spam. > > python -v crashes due to infinite recursion (well, it tried to be > infinite until it got a stack overflow :-) The problem seems to be > that Lib/encodings/latin_1.py is loaded, but it tries to be converted > to latin_1, so it tries to load the module, and ... Or something like > that. See below for a call stack. > > Minimal version: > > PyFile_WriteString (s= "# Lib/encodings/latin_1.pyc matches > Lib/encodings/latin_1.py\n", f=) at Objects/fileobject.c:184 > mywrite (name= "stderr", fp=, format= "# %s matches %s\n", va=) at > Python/sysmodule.c:1350 > PySys_WriteStderr (format= "# %s matches %s\n") at Python/sysmodule.c:1380 > check_compiled_module (pathname= "Lib/encodings/latin_1.py", mtime=, > cpathname= "Lib/encodings/latin_1.pyc") at Python/import.c:755 > load_source_module (name= "encodings.latin_1", pathname= > "Lib/encodings/latin_1.py", fp=) at Python/import.c:938 > load_module (name= "encodings.latin_1", fp=,buf= > "Lib/encodings/latin_1.py", type=1, loader=) at Python/import.c:1733 > import_submodule (mod=, subname= "latin_1",fullname= > "encodings.latin_1") at Python/import.c:2418 > load_next (mod=,altmod=, p_name=,buf= "encodings.latin_1", p_buflen=) > at Python/import.c:2213 > import_module_level (name=, globals=, locals=, fromlist=, level=0) at > Python/import.c:1992 > PyImport_ImportModuleLevel (name= "encodings.latin_1", globals=, > locals=, fromlist=, level=0) at Python/import.c:2056 > builtin___import__ () at Python/bltinmodule.c:151 > [...] > _PyCodec_Lookup (encoding= "latin-1") at Python/codecs.c:147 > codec_getitem (encoding= "latin-1",index=0) at Python/codecs.c:211 > PyCodec_Encoder (encoding= "latin-1") at Python/codecs.c:275 > PyCodec_Encode (object=,encoding= "latin-1", errors=) at Python/codecs.c:322 > PyString_AsEncodedObject (str=,encoding= "latin-1", errors=) at > Objects/stringobject.c:459 > string_encode () at Objects/stringobject.c:3138 > [...] > PyFile_WriteObject (v=, f=, flags=1) at Objects/fileobject.c:159 > PyFile_WriteString (s= "# Lib/encodings/latin_1.pyc matches > Lib/encodings/latin_1.py\n",f=) at Objects/fileobject.c:184 > > == Stack trace for python -v recursion (argument values are mostly trimmed) == > > PyFile_WriteString (s= "# Lib/encodings/latin_1.pyc matches > Lib/encodings/latin_1.py\n", f=) at Objects/fileobject.c:184 > mywrite (name= "stderr", fp=, format= "# %s matches %s\n", va=) at > Python/sysmodule.c:1350 > PySys_WriteStderr (format= "# %s matches %s\n") at Python/sysmodule.c:1380 > check_compiled_module (pathname= "Lib/encodings/latin_1.py", mtime=, > cpathname= "Lib/encodings/latin_1.pyc") at Python/import.c:755 > load_source_module (name= "encodings.latin_1", pathname= > "Lib/encodings/latin_1.py", fp=) at Python/import.c:938 > load_module (name= "encodings.latin_1", fp=,buf= > "Lib/encodings/latin_1.py", type=1, loader=) at Python/import.c:1733 > import_submodule (mod=, subname= "latin_1",fullname= > "encodings.latin_1") at Python/import.c:2418 > load_next (mod=,altmod=, p_name=,buf= "encodings.latin_1", p_buflen=) > at Python/import.c:2213 > import_module_level (name=, globals=, locals=, fromlist=, level=0) at > Python/import.c:1992 > PyImport_ImportModuleLevel (name= "encodings.latin_1", globals=, > locals=, fromlist=, level=0) at Python/import.c:2056 > builtin___import__ () at Python/bltinmodule.c:151 > PyCFunction_Call () at Objects/methodobject.c:77 > PyObject_Call () at Objects/abstract.c:1736 > do_call () at Python/ceval.c:3764 > call_function (pp_stack=, oparg=513) at Python/ceval.c:3574 > PyEval_EvalFrameEx (f=, throwflag=0) at Python/ceval.c:2216 > PyEval_EvalCodeEx () at Python/ceval.c:2835 > function_call () at Objects/funcobject.c:634 > PyObject_Call () at Objects/abstract.c:1736 > PyEval_CallObjectWithKeywords () at Python/ceval.c:3431 > _PyCodec_Lookup (encoding= "latin-1") at Python/codecs.c:147 > codec_getitem (encoding= "latin-1",index=0) at Python/codecs.c:211 > PyCodec_Encoder (encoding= "latin-1") at Python/codecs.c:275 > PyCodec_Encode (object=,encoding= "latin-1", errors=) at Python/codecs.c:322 > PyString_AsEncodedObject (str=,encoding= "latin-1", errors=) at > Objects/stringobject.c:459 > string_encode () at Objects/stringobject.c:3138 > PyCFunction_Call () at Objects/methodobject.c:73 > call_function () at Python/ceval.c:3551 > PyEval_EvalFrameEx (f=, throwflag=0) at Python/ceval.c:2216 > PyEval_EvalCodeEx () at Python/ceval.c:2835 > function_call () at Objects/funcobject.c:634 > PyObject_Call () at Objects/abstract.c:1736 > method_call () at Objects/classobject.c:397 > PyObject_Call () at Objects/abstract.c:1736 > PyEval_CallObjectWithKeywords () at Python/ceval.c:3431 > PyFile_WriteObject (v=, f=, flags=1) at Objects/fileobject.c:159 > PyFile_WriteString (s= "# Lib/encodings/latin_1.pyc matches > Lib/encodings/latin_1.py\n",f=) at Objects/fileobject.c:184 > _______________________________________________ > Python-3000 mailing list > [email protected] > http://mail.python.org/mailman/listinfo/python-3000 > Unsubscribe: > http://mail.python.org/mailman/options/python-3000/guido%40python.org > -- --Guido van Rossum (home page: http://www.python.org/~guido/)
short: PyFile_WriteString (s="# Lib/encodings/latin_1.pyc matches Lib/encodings/latin_1.py\n", f=) at Objects/fileobject.c:184 mywrite (name="stderr", fp=, format="# %s matches %s\n", va=) at Python/sysmodule.c:1350 PySys_WriteStderr (format="# %s matches %s\n") at Python/sysmodule.c:1380 check_compiled_module (pathname="Lib/encodings/latin_1.py", mtime=, cpathname="Lib/encodings/latin_1.pyc") at Python/import.c:755 load_source_module (name="encodings.latin_1", pathname="Lib/encodings/latin_1.py", fp=) at Python/import.c:938 load_module (name="encodings.latin_1", fp=,buf="Lib/encodings/latin_1.py", type=1, loader=) at Python/import.c:1733 import_submodule (mod=, subname="latin_1",fullname="encodings.latin_1") at Python/import.c:2418 load_next (mod=,altmod=, p_name=,buf="encodings.latin_1", p_buflen=) at Python/import.c:2213 import_module_level (name=, globals=, locals=, fromlist=, level=0) at Python/import.c:1992 PyImport_ImportModuleLevel (name="encodings.latin_1", globals=, locals=, fromlist=, level=0) at Python/import.c:2056 builtin___import__ () at Python/bltinmodule.c:151 [...] _PyCodec_Lookup (encoding="latin-1") at Python/codecs.c:147 codec_getitem (encoding="latin-1",index=0) at Python/codecs.c:211 PyCodec_Encoder (encoding="latin-1") at Python/codecs.c:275 PyCodec_Encode (object=,encoding="latin-1", errors=) at Python/codecs.c:322 PyString_AsEncodedObject (str=,encoding="latin-1", errors=) at Objects/stringobject.c:459 string_encode () at Objects/stringobject.c:3138 [...] PyFile_WriteObject (v=, f=, flags=1) at Objects/fileobject.c:159 PyFile_WriteString (s="# Lib/encodings/latin_1.pyc matches Lib/encodings/latin_1.py\n",f=) at Objects/fileobject.c:184 long: PyFile_WriteString (s= "# Lib/encodings/latin_1.pyc matches Lib/encodings/latin_1.py\n", f=) at Objects/fileobject.c:184 mywrite (name= "stderr", fp=, format= "# %s matches %s\n", va=) at Python/sysmodule.c:1350 PySys_WriteStderr (format= "# %s matches %s\n") at Python/sysmodule.c:1380 check_compiled_module (pathname= "Lib/encodings/latin_1.py", mtime=, cpathname= "Lib/encodings/latin_1.pyc") at Python/import.c:755 load_source_module (name= "encodings.latin_1", pathname= "Lib/encodings/latin_1.py", fp=) at Python/import.c:938 load_module (name= "encodings.latin_1", fp=,buf= "Lib/encodings/latin_1.py", type=1, loader=) at Python/import.c:1733 import_submodule (mod=, subname= "latin_1",fullname= "encodings.latin_1") at Python/import.c:2418 load_next (mod=,altmod=, p_name=,buf= "encodings.latin_1", p_buflen=) at Python/import.c:2213 import_module_level (name=, globals=, locals=, fromlist=, level=0) at Python/import.c:1992 PyImport_ImportModuleLevel (name= "encodings.latin_1", globals=, locals=, fromlist=, level=0) at Python/import.c:2056 builtin___import__ () at Python/bltinmodule.c:151 PyCFunction_Call () at Objects/methodobject.c:77 PyObject_Call () at Objects/abstract.c:1736 do_call () at Python/ceval.c:3764 call_function (pp_stack=, oparg=513) at Python/ceval.c:3574 PyEval_EvalFrameEx (f=, throwflag=0) at Python/ceval.c:2216 PyEval_EvalCodeEx () at Python/ceval.c:2835 function_call () at Objects/funcobject.c:634 PyObject_Call () at Objects/abstract.c:1736 PyEval_CallObjectWithKeywords () at Python/ceval.c:3431 _PyCodec_Lookup (encoding= "latin-1") at Python/codecs.c:147 codec_getitem (encoding= "latin-1",index=0) at Python/codecs.c:211 PyCodec_Encoder (encoding= "latin-1") at Python/codecs.c:275 PyCodec_Encode (object=,encoding= "latin-1", errors=) at Python/codecs.c:322 PyString_AsEncodedObject (str=,encoding= "latin-1", errors=) at Objects/stringobject.c:459 string_encode () at Objects/stringobject.c:3138 PyCFunction_Call () at Objects/methodobject.c:73 call_function () at Python/ceval.c:3551 PyEval_EvalFrameEx (f=, throwflag=0) at Python/ceval.c:2216 PyEval_EvalCodeEx () at Python/ceval.c:2835 function_call () at Objects/funcobject.c:634 PyObject_Call () at Objects/abstract.c:1736 method_call () at Objects/classobject.c:397 PyObject_Call () at Objects/abstract.c:1736 PyEval_CallObjectWithKeywords () at Python/ceval.c:3431 PyFile_WriteObject (v=, f=, flags=1) at Objects/fileobject.c:159 PyFile_WriteString (s= "# Lib/encodings/latin_1.pyc matches Lib/encodings/latin_1.py\n",f=) at Objects/fileobject.c:184
_______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
