Mercurial > cpython-lru_cache-weakref
comparison Python/sysmodule.c @ 44674:1154158a199f
Merged revisions 59933-59951 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59935 | raymond.hettinger | 2008-01-13 07:15:15 +0100 (Sun, 13 Jan 2008) | 1 line
Named tuple is a concept, not a specific type.
........
r59936 | raymond.hettinger | 2008-01-13 07:18:07 +0100 (Sun, 13 Jan 2008) | 1 line
Fix spelling.
........
r59937 | georg.brandl | 2008-01-13 10:36:18 +0100 (Sun, 13 Jan 2008) | 2 lines
Clarify the effect of text mode.
........
r59938 | thomas.heller | 2008-01-13 12:19:43 +0100 (Sun, 13 Jan 2008) | 1 line
Make Modules/socketobject.c compile for Windows again.
........
r59939 | ka-ping.yee | 2008-01-13 12:25:13 +0100 (Sun, 13 Jan 2008) | 9 lines
Check in the patch proposed by Ben Hayden (benjhayden) for issue
#1550: help('modules') broken by several 3rd party libraries.
Tested with Python build: trunk:54235:59936M -- the reported error
occurs with Django installed (or with any __init__.py present on
the path that raises an exception), and such errors indeed go away
when this change is applied.
........
r59940 | georg.brandl | 2008-01-13 16:04:05 +0100 (Sun, 13 Jan 2008) | 2 lines
Back out r59931 - test_ctypes fails with it.
........
r59943 | amaury.forgeotdarc | 2008-01-14 01:22:44 +0100 (Mon, 14 Jan 2008) | 6 lines
As discussed in issue 1700288:
ctypes takes some liberties when creating python types: it modifies the types'
__dict__ directly, bypassing all the machinery of type objects which deal with
special methods. And this broke recent optimisations of method lookup.
Now we try to modify the type with more "official" functions.
........
r59944 | amaury.forgeotdarc | 2008-01-14 01:29:41 +0100 (Mon, 14 Jan 2008) | 5 lines
Re-apply patch #1700288 (first applied in r59931, rolled back in r59940)
now that ctypes uses a more supported method to create types:
Method cache optimization, by Armin Rigo, ported to 2.6 by Kevin Jacobs.
........
r59946 | amaury.forgeotdarc | 2008-01-14 02:07:27 +0100 (Mon, 14 Jan 2008) | 4 lines
?Why did my tests not notice this before?
Slots inheritance is very different from OO inheritance.
This code lead to infinite recursion on classes derived from StructType.
........
r59947 | christian.heimes | 2008-01-14 04:33:52 +0100 (Mon, 14 Jan 2008) | 1 line
Added new an better structseq representation. E.g. repr(time.gmtime(0)) now returns 'time.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=1, tm_isdst=0)' instead of '(1970, 1, 1, 0, 0, 0, 3, 1, 0)'. The feature is part of #1816: sys.flags
........
r59948 | christian.heimes | 2008-01-14 04:35:38 +0100 (Mon, 14 Jan 2008) | 1 line
I missed the most important file
........
r59949 | christian.heimes | 2008-01-14 04:42:48 +0100 (Mon, 14 Jan 2008) | 1 line
Applied patch #1816: sys.flags patch
........
r59950 | christian.heimes | 2008-01-14 05:13:37 +0100 (Mon, 14 Jan 2008) | 2 lines
Now that I've learnt about structseq objects I felt like converting sys.float_info to a structseq. It's
readonly and help(sys.float_info) explains the attributes nicely.
........
r59951 | christian.heimes | 2008-01-14 07:06:19 +0100 (Mon, 14 Jan 2008) | 1 line
Added more comments to the new structseq repr code and implemented several of Neal's suggestions.
........
| author | Christian Heimes <christian@cheimes.de> |
|---|---|
| date | Mon, 14 Jan 2008 18:49:24 +0000 |
| parents | fb5a6330f71b |
| children | 6f049ca55e06 |
comparison
equal
deleted
inserted
replaced
| 44665:91928d99ebb0 | 44674:1154158a199f |
|---|---|
| 13 - argv: script arguments (list of strings) | 13 - argv: script arguments (list of strings) |
| 14 - ps1, ps2: optional primary and secondary prompts (strings) | 14 - ps1, ps2: optional primary and secondary prompts (strings) |
| 15 */ | 15 */ |
| 16 | 16 |
| 17 #include "Python.h" | 17 #include "Python.h" |
| 18 #include "structseq.h" | |
| 18 #include "code.h" | 19 #include "code.h" |
| 19 #include "frameobject.h" | 20 #include "frameobject.h" |
| 20 #include "eval.h" | 21 #include "eval.h" |
| 21 | 22 |
| 22 #include "osdefs.h" | 23 #include "osdefs.h" |
| 1000 { | 1001 { |
| 1001 svnversion_init(); | 1002 svnversion_init(); |
| 1002 return shortbranch; | 1003 return shortbranch; |
| 1003 } | 1004 } |
| 1004 | 1005 |
| 1006 | |
| 1007 PyDoc_STRVAR(flags__doc__, | |
| 1008 "sys.flags\n\ | |
| 1009 \n\ | |
| 1010 Flags provided through command line arguments or environment vars."); | |
| 1011 | |
| 1012 static PyTypeObject FlagsType; | |
| 1013 | |
| 1014 static PyStructSequence_Field flags_fields[] = { | |
| 1015 {"debug", "-d"}, | |
| 1016 {"division_warning", "-Q"}, | |
| 1017 {"inspect", "-i"}, | |
| 1018 {"interactive", "-i"}, | |
| 1019 {"optimize", "-O or -OO"}, | |
| 1020 {"dont_write_bytecode", "-B"}, | |
| 1021 /* {"no_user_site", "-s"}, */ | |
| 1022 {"no_site", "-S"}, | |
| 1023 {"ingnore_environment", "-E"}, | |
| 1024 {"tabcheck", "-t or -tt"}, | |
| 1025 {"verbose", "-v"}, | |
| 1026 #ifdef RISCOS | |
| 1027 {"ricos_wimp", "???"}, | |
| 1028 #endif | |
| 1029 /* {"unbuffered", "-u"}, */ | |
| 1030 /* {"skip_first", "-x"}, */ | |
| 1031 {0} | |
| 1032 }; | |
| 1033 | |
| 1034 static PyStructSequence_Desc flags_desc = { | |
| 1035 "sys.flags", /* name */ | |
| 1036 flags__doc__, /* doc */ | |
| 1037 flags_fields, /* fields */ | |
| 1038 #ifdef RISCOS | |
| 1039 11 | |
| 1040 #else | |
| 1041 10 | |
| 1042 #endif | |
| 1043 }; | |
| 1044 | |
| 1045 static PyObject* | |
| 1046 make_flags(void) | |
| 1047 { | |
| 1048 int pos = 0; | |
| 1049 PyObject *seq; | |
| 1050 | |
| 1051 seq = PyStructSequence_New(&FlagsType); | |
| 1052 if (seq == NULL) | |
| 1053 return NULL; | |
| 1054 | |
| 1055 #define SetFlag(flag) \ | |
| 1056 PyStructSequence_SET_ITEM(seq, pos++, PyLong_FromLong(flag)) | |
| 1057 | |
| 1058 SetFlag(Py_DebugFlag); | |
| 1059 SetFlag(Py_DivisionWarningFlag); | |
| 1060 SetFlag(Py_InspectFlag); | |
| 1061 SetFlag(Py_InteractiveFlag); | |
| 1062 SetFlag(Py_OptimizeFlag); | |
| 1063 SetFlag(Py_DontWriteBytecodeFlag); | |
| 1064 /* SetFlag(Py_NoUserSiteDirectory); */ | |
| 1065 SetFlag(Py_NoSiteFlag); | |
| 1066 SetFlag(Py_IgnoreEnvironmentFlag); | |
| 1067 SetFlag(Py_TabcheckFlag); | |
| 1068 SetFlag(Py_VerboseFlag); | |
| 1069 #ifdef RISCOS | |
| 1070 SetFlag(Py_RISCOSWimpFlag); | |
| 1071 #endif | |
| 1072 /* SetFlag(saw_unbuffered_flag); */ | |
| 1073 /* SetFlag(skipfirstline); */ | |
| 1074 #undef SetFlag | |
| 1075 | |
| 1076 if (PyErr_Occurred()) { | |
| 1077 return NULL; | |
| 1078 } | |
| 1079 | |
| 1080 Py_INCREF(seq); | |
| 1081 return seq; | |
| 1082 } | |
| 1083 | |
| 1005 PyObject * | 1084 PyObject * |
| 1006 _PySys_Init(void) | 1085 _PySys_Init(void) |
| 1007 { | 1086 { |
| 1008 PyObject *m, *v, *sysdict; | 1087 PyObject *m, *v, *sysdict; |
| 1009 char *s; | 1088 char *s; |
| 1039 Py_XDECREF(v); | 1118 Py_XDECREF(v); |
| 1040 svnversion_init(); | 1119 svnversion_init(); |
| 1041 v = Py_BuildValue("(UUU)", "CPython", branch, svn_revision); | 1120 v = Py_BuildValue("(UUU)", "CPython", branch, svn_revision); |
| 1042 PyDict_SetItemString(sysdict, "subversion", v); | 1121 PyDict_SetItemString(sysdict, "subversion", v); |
| 1043 Py_XDECREF(v); | 1122 Py_XDECREF(v); |
| 1044 PyDict_SetItemString(sysdict, "dont_write_bytecode", | 1123 PyDict_SetItemString(sysdict, "dont_write_bytecode", |
| 1045 v = PyBool_FromLong(Py_DontWriteBytecodeFlag)); | 1124 v = PyBool_FromLong(Py_DontWriteBytecodeFlag)); |
| 1046 Py_XDECREF(v); | 1125 Py_XDECREF(v); |
| 1047 /* | 1126 /* |
| 1048 * These release level checks are mutually exclusive and cover | 1127 * These release level checks are mutually exclusive and cover |
| 1049 * the field, so don't get too fancy with the pre-processor! | 1128 * the field, so don't get too fancy with the pre-processor! |
| 1050 */ | 1129 */ |
| 1051 #if PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_ALPHA | 1130 #if PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_ALPHA |
| 1118 Py_INCREF(warnoptions); | 1197 Py_INCREF(warnoptions); |
| 1119 } | 1198 } |
| 1120 if (warnoptions != NULL) { | 1199 if (warnoptions != NULL) { |
| 1121 PyDict_SetItemString(sysdict, "warnoptions", warnoptions); | 1200 PyDict_SetItemString(sysdict, "warnoptions", warnoptions); |
| 1122 } | 1201 } |
| 1202 | |
| 1203 PyStructSequence_InitType(&FlagsType, &flags_desc); | |
| 1204 PyDict_SetItemString(sysdict, "flags", make_flags()); | |
| 1205 /* prevent user from creating new instances */ | |
| 1206 FlagsType.tp_init = NULL; | |
| 1207 FlagsType.tp_new = NULL; | |
| 1123 | 1208 |
| 1124 if (PyErr_Occurred()) | 1209 if (PyErr_Occurred()) |
| 1125 return NULL; | 1210 return NULL; |
| 1126 return m; | 1211 return m; |
| 1127 } | 1212 } |
