Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 26cffde

Browse files
committed
Fix the Py_FileSystemDefaultEncoding checkin - declare the variable in a fileobject.h, and initialize it in bltinmodule.
1 parent 834f4dd commit 26cffde

3 files changed

Lines changed: 13 additions & 11 deletions

File tree

Include/fileobject.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ extern DL_IMPORT(int) PyFile_SoftSpace(PyObject *, int);
2323
extern DL_IMPORT(int) PyFile_WriteString(char *, PyObject *);
2424
extern DL_IMPORT(int) PyObject_AsFileDescriptor(PyObject *);
2525

26+
/* The default encoding used by the platform file system APIs
27+
If non-NULL, this is different than the default encoding for strings
28+
*/
29+
extern DL_IMPORT(const char *) Py_FileSystemDefaultEncoding;
30+
2631
#ifdef __cplusplus
2732
}
2833
#endif

Modules/posixmodule.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -233,16 +233,6 @@ extern int lstat(const char *, struct stat *);
233233
#endif /* MS_WIN32 */
234234
#endif /* _MSC_VER */
235235

236-
/* The default encoding used by the platform file system APIs
237-
If non-NULL, this is almost certainly different than the default
238-
encoding for strings (otherwise it can remain NULL!)
239-
*/
240-
#ifdef MS_WIN32
241-
const char *Py_FileSystemDefaultEncoding = "mbcs";
242-
#else
243-
const char *Py_FileSystemDefaultEncoding = NULL; /* use default */
244-
#endif
245-
246236
#if defined(PYCC_VACPP) && defined(PYOS_OS2)
247237
#include <io.h>
248238
#endif /* OS2 */

Python/bltinmodule.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@
1313
#include <unistd.h>
1414
#endif
1515

16-
extern const char *Py_FileSystemDefaultEncoding;
16+
/* The default encoding used by the platform file system APIs
17+
Can remain NULL for all platforms that don't have such a concept
18+
*/
19+
#ifdef MS_WIN32
20+
const char *Py_FileSystemDefaultEncoding = "mbcs";
21+
#else
22+
const char *Py_FileSystemDefaultEncoding = NULL; /* use default */
23+
#endif
1724

1825
/* Forward */
1926
static PyObject *filterstring(PyObject *, PyObject *);

0 commit comments

Comments
 (0)