diff options
author | Christian Heimes <christian@cheimes.de> | 2012-10-17 23:52:17 +0200 |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2012-10-17 23:52:17 +0200 |
commit | 114c42641335bdc26cbf61c18c82b0f5c8a6d4f8 (patch) | |
tree | 2b1730bb73e98cc0198ee1ea35c4afd8ba8287d7 /Python/sysmodule.c | |
parent | 79ca8edc5b262cea550f10b231ab8eba90b267f3 (diff) | |
download | cpython-114c42641335bdc26cbf61c18c82b0f5c8a6d4f8.tar.gz |
Issue #16166: Add PY_LITTLE_ENDIAN and PY_BIG_ENDIAN macros and unified
endianess detection and handling.
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r-- | Python/sysmodule.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 20bfa555b3..cafbb58667 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -1561,7 +1561,6 @@ PyObject * _PySys_Init(void) { PyObject *m, *v, *sysdict, *version_info; - char *s; m = PyModule_Create(&sysmodule); if (m == NULL) @@ -1638,20 +1637,14 @@ _PySys_Init(void) PyLong_FromLong(0x10FFFF)); SET_SYS_FROM_STRING("builtin_module_names", list_builtin_module_names()); - { - /* Assumes that longs are at least 2 bytes long. - Should be safe! */ - unsigned long number = 1; - char *value; - - s = (char *) &number; - if (s[0] == 0) - value = "big"; - else - value = "little"; - SET_SYS_FROM_STRING("byteorder", - PyUnicode_FromString(value)); - } +#if PY_BIG_ENDIAN + SET_SYS_FROM_STRING("byteorder", + PyUnicode_FromString("big")); +#else + SET_SYS_FROM_STRING("byteorder", + PyUnicode_FromString("little")); +#endif + #ifdef MS_COREDLL SET_SYS_FROM_STRING("dllhandle", PyLong_FromVoidPtr(PyWin_DLLhModule)); |