Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(28)

Unified Diff: Python/pythonrun.c

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Python/Python-ast.c ('k') | Python/symtable.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Python/pythonrun.c Tue Jul 26 09:37:46 2011 +0300
+++ b/Python/pythonrun.c Mon Jul 25 09:47:18 2011 -0400
@@ -168,25 +168,18 @@
return NULL;
}
+#if defined(HAVE_LANGINFO_H) && defined(CODESET)
static char*
-get_locale_encoding(void)
+get_codeset(void)
{
-#ifdef MS_WINDOWS
- char codepage[100];
- PyOS_snprintf(codepage, sizeof(codepage), "cp%d", GetACP());
- return get_codec_name(codepage);
-#elif defined(HAVE_LANGINFO_H) && defined(CODESET)
char* codeset = nl_langinfo(CODESET);
if (!codeset || codeset[0] == '\0') {
PyErr_SetString(PyExc_ValueError, "CODESET is not set or empty");
return NULL;
}
return get_codec_name(codeset);
-#else
- PyErr_SetNone(PyExc_NotImplementedError);
- return NULL;
+}
#endif
-}
void
Py_InitializeEx(int install_sigs)
@@ -753,17 +746,24 @@
initfsencoding(PyInterpreterState *interp)
{
PyObject *codec;
+#if defined(HAVE_LANGINFO_H) && defined(CODESET)
+ char *codeset = NULL;
- if (Py_FileSystemDefaultEncoding == NULL)
- {
- Py_FileSystemDefaultEncoding = get_locale_encoding();
- if (Py_FileSystemDefaultEncoding == NULL)
+ if (Py_FileSystemDefaultEncoding == NULL) {
+ /* On Unix, set the file system encoding according to the
+ user's preference, if the CODESET names a well-known
+ Python codec, and Py_FileSystemDefaultEncoding isn't
+ initialized by other means. */
+ codeset = get_codeset();
+ if (codeset == NULL)
Py_FatalError("Py_Initialize: Unable to get the locale encoding");
+ Py_FileSystemDefaultEncoding = codeset;
Py_HasFileSystemDefaultEncoding = 0;
interp->fscodec_initialized = 1;
return 0;
}
+#endif
/* the encoding is mbcs, utf-8 or ascii */
codec = _PyCodec_Lookup(Py_FileSystemDefaultEncoding);
« no previous file with comments | « Python/Python-ast.c ('k') | Python/symtable.c » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+