summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2000-08-14 15:47:03 (GMT)
committerFred Drake <fdrake@acm.org>2000-08-14 15:47:03 (GMT)
commit099325e01b9c244bdaf96e072829195243caced9 (patch)
treeb1dbe4b3bcd0d23ecadb253a1c18756d40b714ca /Python
parent107b9679c482e99af11f5867d8267809764a1b48 (diff)
downloadcpython-099325e01b9c244bdaf96e072829195243caced9.zip
cpython-099325e01b9c244bdaf96e072829195243caced9.tar.gz
cpython-099325e01b9c244bdaf96e072829195243caced9.tar.bz2
Add a byte_order value to the sys module. The value is "big" for
big-endian machines and "little" for little-endian machines.
Diffstat (limited to 'Python')
-rw-r--r--Python/sysmodule.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 8883ba1..2ae6d20 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -456,6 +456,19 @@ _PySys_Init(void)
PyDict_SetItemString(sysdict, "builtin_module_names",
v = list_builtin_module_names());
Py_XDECREF(v);
+ {
+ /* Assumes that longs are at least 2 bytes long.
+ Should be safe! */
+ unsigned long number = 1;
+
+ s = (char *) &number;
+ if (s[0] == 0)
+ PyDict_SetItemString(sysdict, "byte_order",
+ PyString_FromString("big"));
+ else
+ PyDict_SetItemString(sysdict, "byte_order",
+ PyString_FromString("little"));
+ }
#ifdef MS_COREDLL
PyDict_SetItemString(sysdict, "dllhandle",
v = PyLong_FromVoidPtr(PyWin_DLLhModule));