Mercurial > cpython-lru_cache-weakref
diff Python/sysmodule.c @ 79803:d2127cdec10e
Issue #16166: Add PY_LITTLE_ENDIAN and PY_BIG_ENDIAN macros and unified
endianess detection and handling.
| author | Christian Heimes <christian@cheimes.de> |
|---|---|
| date | Wed, 17 Oct 2012 23:52:17 +0200 |
| parents | ee01fd98b5b0 |
| children | ceb0184c7f44 |
line wrap: on
line diff
--- a/Python/sysmodule.c Wed Oct 17 17:33:26 2012 +0300 +++ b/Python/sysmodule.c Wed Oct 17 23:52:17 2012 +0200 @@ -1561,7 +1561,6 @@ _PySys_Init(void) { PyObject *m, *v, *sysdict, *version_info; - char *s; m = PyModule_Create(&sysmodule); if (m == NULL) @@ -1638,20 +1637,14 @@ 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; +#if PY_BIG_ENDIAN + SET_SYS_FROM_STRING("byteorder", + PyUnicode_FromString("big")); +#else + SET_SYS_FROM_STRING("byteorder", + PyUnicode_FromString("little")); +#endif - s = (char *) &number; - if (s[0] == 0) - value = "big"; - else - value = "little"; - SET_SYS_FROM_STRING("byteorder", - PyUnicode_FromString(value)); - } #ifdef MS_COREDLL SET_SYS_FROM_STRING("dllhandle", PyLong_FromVoidPtr(PyWin_DLLhModule));
