You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

262 lines
8.8 KiB

Mass checkin (more to follow for other directories). Introduce truly separate (sub)interpreter objects. For now, these must be used by separate threads, created from C. See Demo/pysvr for an example of how to use this. This also rationalizes Python's initialization and finalization behavior: Py_Initialize() -- initialize the whole interpreter Py_Finalize() -- finalize the whole interpreter tstate = Py_NewInterpreter() -- create a new (sub)interpreter Py_EndInterpreter(tstate) -- delete a new (sub)interpreter There are also new interfaces relating to threads and the interpreter lock, which can be used to create new threads, and sometimes have to be used to manipulate the interpreter lock when creating or deleting sub-interpreters. These are only defined when WITH_THREAD is defined: PyEval_AcquireLock() -- acquire the interpreter lock PyEval_ReleaseLock() -- release the interpreter lock PyEval_AcquireThread(tstate) -- acquire the lock and make the thread current PyEval_ReleaseThread(tstate) -- release the lock and make NULL current Other administrative changes: - The header file bltinmodule.h is deleted. - The init functions for Import, Sys and Builtin are now internal and declared in pythonrun.h. - Py_Setup() and Py_Cleanup() are no longer declared. - The interpreter state and thread state structures are now linked together in a chain (the chain of interpreters is a static variable in pythonrun.c). - Some members of the interpreter and thread structures have new, shorter, more consistent, names. - Added declarations for _PyImport_{Find,Fixup}Extension() to import.h.
29 years ago
Mass checkin (more to follow for other directories). Introduce truly separate (sub)interpreter objects. For now, these must be used by separate threads, created from C. See Demo/pysvr for an example of how to use this. This also rationalizes Python's initialization and finalization behavior: Py_Initialize() -- initialize the whole interpreter Py_Finalize() -- finalize the whole interpreter tstate = Py_NewInterpreter() -- create a new (sub)interpreter Py_EndInterpreter(tstate) -- delete a new (sub)interpreter There are also new interfaces relating to threads and the interpreter lock, which can be used to create new threads, and sometimes have to be used to manipulate the interpreter lock when creating or deleting sub-interpreters. These are only defined when WITH_THREAD is defined: PyEval_AcquireLock() -- acquire the interpreter lock PyEval_ReleaseLock() -- release the interpreter lock PyEval_AcquireThread(tstate) -- acquire the lock and make the thread current PyEval_ReleaseThread(tstate) -- release the lock and make NULL current Other administrative changes: - The header file bltinmodule.h is deleted. - The init functions for Import, Sys and Builtin are now internal and declared in pythonrun.h. - Py_Setup() and Py_Cleanup() are no longer declared. - The interpreter state and thread state structures are now linked together in a chain (the chain of interpreters is a static variable in pythonrun.c). - Some members of the interpreter and thread structures have new, shorter, more consistent, names. - Added declarations for _PyImport_{Find,Fixup}Extension() to import.h.
29 years ago
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617-60678 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r60618 | walter.doerwald | 2008-02-06 15:31:55 +0100 (Wed, 06 Feb 2008) | 6 lines Remove month parameter from Calendar.yeardatescalendar(), Calendar.yeardays2calendar() and Calendar.yeardayscalendar() as the methods don't have such a parameter. Fixes issue #2017. Rewrap content to 80 chars. ........ r60622 | facundo.batista | 2008-02-06 20:28:49 +0100 (Wed, 06 Feb 2008) | 4 lines Fixes issue 1959. Converted tests to unittest. Thanks Giampaolo Rodola. ........ r60626 | thomas.heller | 2008-02-06 21:29:17 +0100 (Wed, 06 Feb 2008) | 3 lines Fixed refcounts and error handling. Should not be merged to py3k branch. ........ r60630 | mark.dickinson | 2008-02-06 23:10:50 +0100 (Wed, 06 Feb 2008) | 4 lines Issue 1979: Make Decimal comparisons (other than !=, ==) involving NaN raise InvalidOperation (and return False if InvalidOperation is trapped). ........ r60632 | mark.dickinson | 2008-02-06 23:25:16 +0100 (Wed, 06 Feb 2008) | 2 lines Remove incorrect usage of :const: in documentation. ........ r60634 | georg.brandl | 2008-02-07 00:45:51 +0100 (Thu, 07 Feb 2008) | 2 lines Revert accidental changes to test_queue in r60605. ........ r60636 | raymond.hettinger | 2008-02-07 01:54:20 +0100 (Thu, 07 Feb 2008) | 1 line Issue 2025: Add tuple.count() and tuple.index() to follow the ABC in collections.Sequence. ........ r60637 | mark.dickinson | 2008-02-07 02:14:23 +0100 (Thu, 07 Feb 2008) | 2 lines Fix broken link in decimal documentation. ........ r60638 | mark.dickinson | 2008-02-07 02:42:06 +0100 (Thu, 07 Feb 2008) | 3 lines IEEE 754 should be IEEE 854; give precise reference for comparisons involving NaNs. ........ r60639 | raymond.hettinger | 2008-02-07 03:12:52 +0100 (Thu, 07 Feb 2008) | 1 line Return ints instead of longs for tuple.count() and tuple.index(). ........ r60640 | raymond.hettinger | 2008-02-07 04:10:33 +0100 (Thu, 07 Feb 2008) | 1 line Merge 60627. ........ r60641 | raymond.hettinger | 2008-02-07 04:25:46 +0100 (Thu, 07 Feb 2008) | 1 line Merge r60628, r60631, and r60633. Register UserList and UserString will the appropriate ABCs. ........ r60642 | brett.cannon | 2008-02-07 08:47:31 +0100 (Thu, 07 Feb 2008) | 3 lines Cast a struct to a void pointer so as to do a type-safe pointer comparison (mistmatch found by clang). ........ r60643 | brett.cannon | 2008-02-07 09:04:07 +0100 (Thu, 07 Feb 2008) | 2 lines Remove unnecessary curly braces around an int literal. ........ r60644 | andrew.kuchling | 2008-02-07 12:43:47 +0100 (Thu, 07 Feb 2008) | 1 line Update URL ........ r60645 | facundo.batista | 2008-02-07 17:16:29 +0100 (Thu, 07 Feb 2008) | 4 lines Fixes issue 2026. Tests converted to unittest. Thanks Giampaolo Rodola. ........ r60646 | christian.heimes | 2008-02-07 18:15:30 +0100 (Thu, 07 Feb 2008) | 1 line Added some statistics code to dict and list object code. I wanted to test how a larger freelist affects the reusage of freed objects. Contrary to my gut feelings 80 objects is more than fine for small apps. I haven't profiled a large app yet. ........ r60648 | facundo.batista | 2008-02-07 20:06:52 +0100 (Thu, 07 Feb 2008) | 6 lines Fixes Issue 1401. When redirected, a possible POST get converted to GET, so it loses its payload. So, it also must lose the headers related to the payload (if it has no content any more, it shouldn't indicate content length and type). ........ r60649 | walter.doerwald | 2008-02-07 20:30:22 +0100 (Thu, 07 Feb 2008) | 3 lines Clarify that the output of TextCalendar.formatmonth() and TextCalendar.formatyear() for custom instances won't be influenced by calls to the module global setfirstweekday() function. Fixes #2018. ........ r60651 | walter.doerwald | 2008-02-07 20:48:34 +0100 (Thu, 07 Feb 2008) | 3 lines Fix documentation for Calendar.iterweekdays(): firstweekday is a property. Fixes second part of #2018. ........ r60653 | walter.doerwald | 2008-02-07 20:57:32 +0100 (Thu, 07 Feb 2008) | 2 lines Fix typo in docstring for Calendar.itermonthdays(). ........ r60655 | raymond.hettinger | 2008-02-07 21:04:37 +0100 (Thu, 07 Feb 2008) | 1 line The float conversion recipe is simpler in Py2.6 ........ r60657 | raymond.hettinger | 2008-02-07 21:10:49 +0100 (Thu, 07 Feb 2008) | 1 line Fix typo ........ r60660 | brett.cannon | 2008-02-07 23:27:10 +0100 (Thu, 07 Feb 2008) | 3 lines Make sure a switch statement does not have repetitive case statements. Error found through LLVM post-2.1 svn. ........ r60661 | christian.heimes | 2008-02-08 01:11:31 +0100 (Fri, 08 Feb 2008) | 1 line Deallocate content of the dict free list on interpreter shutdown ........ r60662 | christian.heimes | 2008-02-08 01:14:34 +0100 (Fri, 08 Feb 2008) | 1 line Use prefix decrement ........ r60663 | amaury.forgeotdarc | 2008-02-08 01:56:02 +0100 (Fri, 08 Feb 2008) | 5 lines issue 2045: Infinite recursion when printing a subclass of defaultdict, if default_factory is set to a bound method. Will backport. ........ r60667 | jeffrey.yasskin | 2008-02-08 07:45:40 +0100 (Fri, 08 Feb 2008) | 2 lines Oops! 2.6's Rational.__ne__ didn't work. ........ r60671 | hyeshik.chang | 2008-02-08 18:10:20 +0100 (Fri, 08 Feb 2008) | 2 lines Update big5hkscs codec to conform to the HKSCS:2004 revision. ........ r60673 | raymond.hettinger | 2008-02-08 23:30:04 +0100 (Fri, 08 Feb 2008) | 4 lines Remove unnecessary modulo division. The preceding test guarantees that 0 <= i < len. ........ r60674 | raymond.hettinger | 2008-02-09 00:02:27 +0100 (Sat, 09 Feb 2008) | 1 line Speed-up __iter__() mixin method. ........ r60675 | raymond.hettinger | 2008-02-09 00:34:21 +0100 (Sat, 09 Feb 2008) | 1 line Fill-in missing Set comparisons ........ r60677 | raymond.hettinger | 2008-02-09 00:57:06 +0100 (Sat, 09 Feb 2008) | 1 line Add advice on choosing between DictMixin and MutableMapping ........
18 years ago
  1. /* Interfaces to parse and execute pieces of python code */
  2. #ifndef Py_PYTHONRUN_H
  3. #define Py_PYTHONRUN_H
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. #define PyCF_MASK (CO_FUTURE_DIVISION | CO_FUTURE_ABSOLUTE_IMPORT | \
  8. CO_FUTURE_WITH_STATEMENT | CO_FUTURE_PRINT_FUNCTION | \
  9. CO_FUTURE_UNICODE_LITERALS | CO_FUTURE_BARRY_AS_BDFL)
  10. #define PyCF_MASK_OBSOLETE (CO_NESTED)
  11. #define PyCF_SOURCE_IS_UTF8 0x0100
  12. #define PyCF_DONT_IMPLY_DEDENT 0x0200
  13. #define PyCF_ONLY_AST 0x0400
  14. #define PyCF_IGNORE_COOKIE 0x0800
  15. #ifndef Py_LIMITED_API
  16. typedef struct {
  17. int cf_flags; /* bitmask of CO_xxx flags relevant to future */
  18. } PyCompilerFlags;
  19. #endif
  20. PyAPI_FUNC(void) Py_SetProgramName(wchar_t *);
  21. PyAPI_FUNC(wchar_t *) Py_GetProgramName(void);
  22. PyAPI_FUNC(void) Py_SetPythonHome(wchar_t *);
  23. PyAPI_FUNC(wchar_t *) Py_GetPythonHome(void);
  24. PyAPI_FUNC(void) Py_Initialize(void);
  25. PyAPI_FUNC(void) Py_InitializeEx(int);
  26. #ifndef Py_LIMITED_API
  27. PyAPI_FUNC(void) _Py_InitializeEx_Private(int, int);
  28. #endif
  29. PyAPI_FUNC(void) Py_Finalize(void);
  30. PyAPI_FUNC(int) Py_IsInitialized(void);
  31. PyAPI_FUNC(PyThreadState *) Py_NewInterpreter(void);
  32. PyAPI_FUNC(void) Py_EndInterpreter(PyThreadState *);
  33. #ifndef Py_LIMITED_API
  34. PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *);
  35. PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *);
  36. PyAPI_FUNC(int) PyRun_AnyFileExFlags(
  37. FILE *fp,
  38. const char *filename, /* decoded from the filesystem encoding */
  39. int closeit,
  40. PyCompilerFlags *flags);
  41. PyAPI_FUNC(int) PyRun_SimpleFileExFlags(
  42. FILE *fp,
  43. const char *filename, /* decoded from the filesystem encoding */
  44. int closeit,
  45. PyCompilerFlags *flags);
  46. PyAPI_FUNC(int) PyRun_InteractiveOneFlags(
  47. FILE *fp,
  48. const char *filename, /* decoded from the filesystem encoding */
  49. PyCompilerFlags *flags);
  50. PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(
  51. FILE *fp,
  52. const char *filename, /* decoded from the filesystem encoding */
  53. PyCompilerFlags *flags);
  54. PyAPI_FUNC(struct _mod *) PyParser_ASTFromString(
  55. const char *s,
  56. const char *filename, /* decoded from the filesystem encoding */
  57. int start,
  58. PyCompilerFlags *flags,
  59. PyArena *arena);
  60. PyAPI_FUNC(struct _mod *) PyParser_ASTFromFile(
  61. FILE *fp,
  62. const char *filename, /* decoded from the filesystem encoding */
  63. const char* enc,
  64. int start,
  65. char *ps1,
  66. char *ps2,
  67. PyCompilerFlags *flags,
  68. int *errcode,
  69. PyArena *arena);
  70. #endif
  71. #ifndef PyParser_SimpleParseString
  72. #define PyParser_SimpleParseString(S, B) \
  73. PyParser_SimpleParseStringFlags(S, B, 0)
  74. #define PyParser_SimpleParseFile(FP, S, B) \
  75. PyParser_SimpleParseFileFlags(FP, S, B, 0)
  76. #endif
  77. PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlags(const char *, int,
  78. int);
  79. PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlagsFilename(const char *,
  80. const char *,
  81. int, int);
  82. PyAPI_FUNC(struct _node *) PyParser_SimpleParseFileFlags(FILE *, const char *,
  83. int, int);
  84. #ifndef Py_LIMITED_API
  85. PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *,
  86. PyObject *, PyCompilerFlags *);
  87. PyAPI_FUNC(PyObject *) PyRun_FileExFlags(
  88. FILE *fp,
  89. const char *filename, /* decoded from the filesystem encoding */
  90. int start,
  91. PyObject *globals,
  92. PyObject *locals,
  93. int closeit,
  94. PyCompilerFlags *flags);
  95. #endif
  96. #ifdef Py_LIMITED_API
  97. PyAPI_FUNC(PyObject *) Py_CompileString(const char *, const char *, int);
  98. #else
  99. #define Py_CompileString(str, p, s) Py_CompileStringExFlags(str, p, s, NULL, -1)
  100. #define Py_CompileStringFlags(str, p, s, f) Py_CompileStringExFlags(str, p, s, f, -1)
  101. PyAPI_FUNC(PyObject *) Py_CompileStringExFlags(
  102. const char *str,
  103. const char *filename, /* decoded from the filesystem encoding */
  104. int start,
  105. PyCompilerFlags *flags,
  106. int optimize);
  107. #endif
  108. PyAPI_FUNC(struct symtable *) Py_SymtableString(
  109. const char *str,
  110. const char *filename, /* decoded from the filesystem encoding */
  111. int start);
  112. PyAPI_FUNC(void) PyErr_Print(void);
  113. PyAPI_FUNC(void) PyErr_PrintEx(int);
  114. PyAPI_FUNC(void) PyErr_Display(PyObject *, PyObject *, PyObject *);
  115. /* Py_PyAtExit is for the atexit module, Py_AtExit is for low-level
  116. * exit functions.
  117. */
  118. #ifndef Py_LIMITED_API
  119. PyAPI_FUNC(void) _Py_PyAtExit(void (*func)(void));
  120. #endif
  121. PyAPI_FUNC(int) Py_AtExit(void (*func)(void));
  122. PyAPI_FUNC(void) Py_Exit(int);
  123. /* Restore signals that the interpreter has called SIG_IGN on to SIG_DFL. */
  124. #ifndef Py_LIMITED_API
  125. PyAPI_FUNC(void) _Py_RestoreSignals(void);
  126. PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *);
  127. #endif
  128. /* Bootstrap */
  129. PyAPI_FUNC(int) Py_Main(int argc, wchar_t **argv);
  130. #ifndef Py_LIMITED_API
  131. /* Use macros for a bunch of old variants */
  132. #define PyRun_String(str, s, g, l) PyRun_StringFlags(str, s, g, l, NULL)
  133. #define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags(fp, name, 0, NULL)
  134. #define PyRun_AnyFileEx(fp, name, closeit) \
  135. PyRun_AnyFileExFlags(fp, name, closeit, NULL)
  136. #define PyRun_AnyFileFlags(fp, name, flags) \
  137. PyRun_AnyFileExFlags(fp, name, 0, flags)
  138. #define PyRun_SimpleString(s) PyRun_SimpleStringFlags(s, NULL)
  139. #define PyRun_SimpleFile(f, p) PyRun_SimpleFileExFlags(f, p, 0, NULL)
  140. #define PyRun_SimpleFileEx(f, p, c) PyRun_SimpleFileExFlags(f, p, c, NULL)
  141. #define PyRun_InteractiveOne(f, p) PyRun_InteractiveOneFlags(f, p, NULL)
  142. #define PyRun_InteractiveLoop(f, p) PyRun_InteractiveLoopFlags(f, p, NULL)
  143. #define PyRun_File(fp, p, s, g, l) \
  144. PyRun_FileExFlags(fp, p, s, g, l, 0, NULL)
  145. #define PyRun_FileEx(fp, p, s, g, l, c) \
  146. PyRun_FileExFlags(fp, p, s, g, l, c, NULL)
  147. #define PyRun_FileFlags(fp, p, s, g, l, flags) \
  148. PyRun_FileExFlags(fp, p, s, g, l, 0, flags)
  149. #endif
  150. /* In getpath.c */
  151. PyAPI_FUNC(wchar_t *) Py_GetProgramFullPath(void);
  152. PyAPI_FUNC(wchar_t *) Py_GetPrefix(void);
  153. PyAPI_FUNC(wchar_t *) Py_GetExecPrefix(void);
  154. PyAPI_FUNC(wchar_t *) Py_GetPath(void);
  155. PyAPI_FUNC(void) Py_SetPath(const wchar_t *);
  156. #ifdef MS_WINDOWS
  157. int _Py_CheckPython3();
  158. #endif
  159. /* In their own files */
  160. PyAPI_FUNC(const char *) Py_GetVersion(void);
  161. PyAPI_FUNC(const char *) Py_GetPlatform(void);
  162. PyAPI_FUNC(const char *) Py_GetCopyright(void);
  163. PyAPI_FUNC(const char *) Py_GetCompiler(void);
  164. PyAPI_FUNC(const char *) Py_GetBuildInfo(void);
  165. #ifndef Py_LIMITED_API
  166. PyAPI_FUNC(const char *) _Py_hgidentifier(void);
  167. PyAPI_FUNC(const char *) _Py_hgversion(void);
  168. #endif
  169. /* Internal -- various one-time initializations */
  170. #ifndef Py_LIMITED_API
  171. PyAPI_FUNC(PyObject *) _PyBuiltin_Init(void);
  172. PyAPI_FUNC(PyObject *) _PySys_Init(void);
  173. PyAPI_FUNC(void) _PyImport_Init(void);
  174. PyAPI_FUNC(void) _PyExc_Init(PyObject * bltinmod);
  175. PyAPI_FUNC(void) _PyImportHooks_Init(void);
  176. PyAPI_FUNC(int) _PyFrame_Init(void);
  177. PyAPI_FUNC(void) _PyFloat_Init(void);
  178. PyAPI_FUNC(int) PyByteArray_Init(void);
  179. PyAPI_FUNC(void) _PyRandom_Init(void);
  180. #endif
  181. /* Various internal finalizers */
  182. #ifndef Py_LIMITED_API
  183. PyAPI_FUNC(void) _PyExc_Fini(void);
  184. PyAPI_FUNC(void) _PyImport_Fini(void);
  185. PyAPI_FUNC(void) PyMethod_Fini(void);
  186. PyAPI_FUNC(void) PyFrame_Fini(void);
  187. PyAPI_FUNC(void) PyCFunction_Fini(void);
  188. PyAPI_FUNC(void) PyDict_Fini(void);
  189. PyAPI_FUNC(void) PyTuple_Fini(void);
  190. PyAPI_FUNC(void) PyList_Fini(void);
  191. PyAPI_FUNC(void) PySet_Fini(void);
  192. PyAPI_FUNC(void) PyBytes_Fini(void);
  193. PyAPI_FUNC(void) PyByteArray_Fini(void);
  194. PyAPI_FUNC(void) PyFloat_Fini(void);
  195. PyAPI_FUNC(void) PyOS_FiniInterrupts(void);
  196. PyAPI_FUNC(void) _PyGC_Fini(void);
  197. PyAPI_FUNC(void) PySlice_Fini(void);
  198. PyAPI_DATA(PyThreadState *) _Py_Finalizing;
  199. #endif
  200. /* Stuff with no proper home (yet) */
  201. #ifndef Py_LIMITED_API
  202. PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, char *);
  203. #endif
  204. PyAPI_DATA(int) (*PyOS_InputHook)(void);
  205. PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, char *);
  206. #ifndef Py_LIMITED_API
  207. PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState;
  208. #endif
  209. /* Stack size, in "pointers" (so we get extra safety margins
  210. on 64-bit platforms). On a 32-bit platform, this translates
  211. to a 8k margin. */
  212. #define PYOS_STACK_MARGIN 2048
  213. #if defined(WIN32) && !defined(MS_WIN64) && defined(_MSC_VER) && _MSC_VER >= 1300
  214. /* Enable stack checking under Microsoft C */
  215. #define USE_STACKCHECK
  216. #endif
  217. #ifdef USE_STACKCHECK
  218. /* Check that we aren't overflowing our stack */
  219. PyAPI_FUNC(int) PyOS_CheckStack(void);
  220. #endif
  221. /* Signals */
  222. typedef void (*PyOS_sighandler_t)(int);
  223. PyAPI_FUNC(PyOS_sighandler_t) PyOS_getsig(int);
  224. PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int, PyOS_sighandler_t);
  225. /* Random */
  226. PyAPI_FUNC(int) _PyOS_URandom (void *buffer, Py_ssize_t size);
  227. #ifdef __cplusplus
  228. }
  229. #endif
  230. #endif /* !Py_PYTHONRUN_H */