comparison Python/pythonrun.c @ 62231:72f774903772

Issue #8965: initfsencoding() doesn't change the encoding on Mac OS X File system encoding have to be hardcoded to "utf-8" on Mac OS X. r81190 introduced a regression: the encoding was changed depending on the locale.
author Victor Stinner <victor.stinner@haypocalc.com>
date Fri, 11 Jun 2010 00:36:33 +0000
parents a25ad9c4ace0
children 907f564476be
comparison
equal deleted inserted replaced
62227:5fe4ad5b5ab9 62231:72f774903772
701 { 701 {
702 PyObject *codec; 702 PyObject *codec;
703 #if defined(HAVE_LANGINFO_H) && defined(CODESET) 703 #if defined(HAVE_LANGINFO_H) && defined(CODESET)
704 char *codeset; 704 char *codeset;
705 705
706 /* On Unix, set the file system encoding according to the 706 if (Py_FileSystemDefaultEncoding == NULL) {
707 user's preference, if the CODESET names a well-known 707 /* On Unix, set the file system encoding according to the
708 Python codec, and Py_FileSystemDefaultEncoding isn't 708 user's preference, if the CODESET names a well-known
709 initialized by other means. Also set the encoding of 709 Python codec, and Py_FileSystemDefaultEncoding isn't
710 stdin and stdout if these are terminals. */ 710 initialized by other means. Also set the encoding of
711 codeset = get_codeset(); 711 stdin and stdout if these are terminals. */
712 if (codeset != NULL) { 712 codeset = get_codeset();
713 Py_FileSystemDefaultEncoding = codeset; 713 if (codeset != NULL) {
714 Py_HasFileSystemDefaultEncoding = 0; 714 Py_FileSystemDefaultEncoding = codeset;
715 return; 715 Py_HasFileSystemDefaultEncoding = 0;
716 } 716 return;
717 717 }
718 PyErr_Clear(); 718
719 fprintf(stderr, 719 PyErr_Clear();
720 "Unable to get the locale encoding: " 720 fprintf(stderr,
721 "fallback to utf-8\n"); 721 "Unable to get the locale encoding: "
722 Py_FileSystemDefaultEncoding = "utf-8"; 722 "fallback to utf-8\n");
723 Py_HasFileSystemDefaultEncoding = 1; 723 Py_FileSystemDefaultEncoding = "utf-8";
724 Py_HasFileSystemDefaultEncoding = 1;
725 }
724 #endif 726 #endif
725 727
726 /* the encoding is mbcs, utf-8 or ascii */ 728 /* the encoding is mbcs, utf-8 or ascii */
727 codec = _PyCodec_Lookup(Py_FileSystemDefaultEncoding); 729 codec = _PyCodec_Lookup(Py_FileSystemDefaultEncoding);
728 if (!codec) { 730 if (!codec) {