Undiamond Python headers

This change gets the Python codebase into a state where it conforms to
the conventions of this codebase. It's now possible to include headers
from Python, without worrying about ordering. Python has traditionally
solved that problem by "diamonding" everything in Python.h, but that's
problematic since it means any change to any Python header invalidates
all the build artifacts. Lastly it makes tooling not work. Since it is
hard to explain to Emacs when I press C-c C-h to add an import line it
shouldn't add the header that actually defines the symbol, and instead
do follow the nonstandard Python convention.

Progress has been made on letting Python load source code from the zip
executable structure via the standard C library APIs. System calss now
recognizes zip!FILENAME alternative URIs as equivalent to zip:FILENAME
since Python uses colon as its delimiter.

Some progress has been made on embedding the notice license terms into
the Python object code. This is easier said than done since Python has
an extremely complicated ownership story.

- Some termios APIs have been added
- Implement rewinddir() dirstream API
- GetCpuCount() API added to Cosmopolitan Libc
- More bugs in Cosmopolitan Libc have been fixed
- zipobj.com now has flags for mangling the path
- Fixed bug a priori with sendfile() on certain BSDs
- Polyfill F_DUPFD and F_DUPFD_CLOEXEC across platforms
- FIOCLEX / FIONCLEX now polyfilled for fast O_CLOEXEC changes
- APE now supports a hybrid solution to no-self-modify for builds
- Many BSD-only magnums added, e.g. O_SEARCH, O_SHLOCK, SF_NODISKIO
This commit is contained in:
Justine Tunney 2021-08-12 00:42:14 -07:00
parent 20bb8db9f8
commit b420ed8248
762 changed files with 18410 additions and 53772 deletions

View file

@ -1,8 +1,19 @@
/* clang-format off */
/* File automatically generated by Parser/asdl_c.py. */
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/Python-ast.h"
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/boolobject.h"
#include "third_party/python/Include/descrobject.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/listobject.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/object.h"
#include "third_party/python/Include/objimpl.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pythonrun.h"
#include "third_party/python/Include/tupleobject.h"
/* clang-format off */
/* File automatically generated by Parser/asdl_c.py. */
static PyTypeObject AST_type;
static PyTypeObject *mod_type;

View file

@ -1,6 +1,23 @@
/* clang-format off */
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/boolobject.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/fileobject.h"
#include "third_party/python/Include/frameobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/listobject.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/object.h"
#include "third_party/python/Include/pyctype.h"
#include "third_party/python/Include/pydebug.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pylifecycle.h"
#include "third_party/python/Include/pymacro.h"
#include "third_party/python/Include/sysmodule.h"
#include "third_party/python/Include/traceback.h"
#include "third_party/python/Include/tupleobject.h"
#include "third_party/python/Include/unicodeobject.h"
/* clang-format off */
#define MODULE_NAME "_warnings"
@ -1030,7 +1047,7 @@ PyErr_WarnEx(PyObject *category, const char *text, Py_ssize_t stack_level)
#undef PyErr_Warn
PyAPI_FUNC(int)
int
PyErr_Warn(PyObject *category, const char *text)
{
return PyErr_WarnEx(category, text, 1);

View file

@ -1,7 +1,6 @@
/* clang-format off */
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/asdl.h"
#include "third_party/python/Include/pyerrors.h"
/* clang-format off */
asdl_seq *
_Py_asdl_seq_new(Py_ssize_t size, PyArena *arena)
@ -29,7 +28,7 @@ _Py_asdl_seq_new(Py_ssize_t size, PyArena *arena)
PyErr_NoMemory();
return NULL;
}
memset(seq, 0, n);
bzero(seq, n);
seq->size = size;
return seq;
}
@ -60,7 +59,7 @@ _Py_asdl_int_seq_new(Py_ssize_t size, PyArena *arena)
PyErr_NoMemory();
return NULL;
}
memset(seq, 0, n);
bzero(seq, n);
seq->size = size;
return seq;
}

View file

@ -1,13 +1,29 @@
#include "libc/assert.h"
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/node.h"
#include "third_party/python/Include/pyport.h"
#include "third_party/python/Include/pythonrun.h"
#include "third_party/python/Include/token.h"
/**/
#include "libc/errno.h"
#include "libc/fmt/fmt.h"
#include "third_party/python/Include/Python-ast.h"
/**/
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/ast.h"
#include "third_party/python/Include/boolobject.h"
#include "third_party/python/Include/compile.h"
#include "third_party/python/Include/complexobject.h"
#include "third_party/python/Include/floatobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/node.h"
#include "third_party/python/Include/pyctype.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pymacro.h"
#include "third_party/python/Include/pymem.h"
#include "third_party/python/Include/pyport.h"
#include "third_party/python/Include/pystrtod.h"
#include "third_party/python/Include/pythonrun.h"
#include "third_party/python/Include/setobject.h"
#include "third_party/python/Include/sliceobject.h"
#include "third_party/python/Include/token.h"
#include "third_party/python/Include/tupleobject.h"
#include "third_party/python/Include/warnings.h"
/* clang-format off */
static int validate_stmts(asdl_seq *);

View file

@ -1,14 +1,48 @@
#include "libc/calls/calls.h"
#include "third_party/python/Include/Python-ast.h"
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/asdl.h"
#include "third_party/python/Include/ast.h"
#include "third_party/python/Include/bltinmodule.h"
#include "third_party/python/Include/boolobject.h"
#include "third_party/python/Include/bytearrayobject.h"
#include "third_party/python/Include/bytesobject.h"
#include "third_party/python/Include/cellobject.h"
#include "third_party/python/Include/ceval.h"
#include "third_party/python/Include/code.h"
#include "third_party/python/Include/compile.h"
#include "third_party/python/Include/complexobject.h"
#include "third_party/python/Include/descrobject.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/enumobject.h"
#include "third_party/python/Include/eval.h"
#include "third_party/python/Include/fileobject.h"
#include "third_party/python/Include/floatobject.h"
#include "third_party/python/Include/funcobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/iterobject.h"
#include "third_party/python/Include/listobject.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/memoryobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/node.h"
#include "third_party/python/Include/object.h"
#include "third_party/python/Include/objimpl.h"
#include "third_party/python/Include/pydebug.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pyfpe.h"
#include "third_party/python/Include/pymacro.h"
#include "third_party/python/Include/rangeobject.h"
#include "third_party/python/Include/setobject.h"
#include "third_party/python/Include/sliceobject.h"
#include "third_party/python/Include/sysmodule.h"
#include "third_party/python/Include/tupleobject.h"
#include "third_party/python/Include/unicodeobject.h"
#include "third_party/python/Include/warnings.h"
/* clang-format off */
/* Built-in functions */
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/Python-ast.h"
#include "third_party/python/Include/node.h"
#include "third_party/python/Include/code.h"
#include "third_party/python/Include/asdl.h"
#include "third_party/python/Include/ast.h"
/* The default encoding used by the platform file system APIs
Can remain NULL for all platforms that don't have such a concept

View file

@ -1,3 +1,30 @@
#define PY_LOCAL_AGGRESSIVE
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/boolobject.h"
#include "third_party/python/Include/bytesobject.h"
#include "third_party/python/Include/cellobject.h"
#include "third_party/python/Include/ceval.h"
#include "third_party/python/Include/classobject.h"
#include "third_party/python/Include/code.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/eval.h"
#include "third_party/python/Include/frameobject.h"
#include "third_party/python/Include/funcobject.h"
#include "third_party/python/Include/genobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/object.h"
#include "third_party/python/Include/opcode.h"
#include "third_party/python/Include/pydtrace.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pymacro.h"
#include "third_party/python/Include/setobject.h"
#include "third_party/python/Include/sliceobject.h"
#include "third_party/python/Include/structmember.h"
#include "third_party/python/Include/sysmodule.h"
#include "third_party/python/Include/traceback.h"
#include "third_party/python/Include/tupleobject.h"
#include "third_party/python/Include/warnings.h"
/* clang-format off */
/* Execute compiled code */
@ -7,18 +34,6 @@
XXX document it!
*/
/* enable more aggressive intra-module optimizations, where available */
#define PY_LOCAL_AGGRESSIVE
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/code.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/frameobject.h"
#include "third_party/python/Include/opcode.h"
#include "third_party/python/Include/pydtrace.h"
#include "third_party/python/Include/setobject.h"
#include "third_party/python/Include/structmember.h"
/* Turn this on if your compiler chokes on the big switch: */
/* #define CASE_TOO_BIG 1 */
@ -216,7 +231,7 @@ static long main_thread = 0;
/* Request for dropping the GIL */
static _Py_atomic_int gil_drop_request = {0};
#include "third_party/python/Include/ceval_gil.inc"
#include "third_party/python/Python/ceval_gil.inc"
int
PyEval_ThreadsInitialized(void)

View file

@ -1,4 +1,4 @@
#include "third_party/python/Include/condvar.h"
#include "third_party/python/Python/condvar.h"
/* clang-format off */
/*

View file

@ -1,6 +1,8 @@
/* clang-format off */
/*[clinic input]
preserve
[clinic start generated code]*/
#include "third_party/python/Include/unicodeobject.h"
PyDoc_STRVAR(builtin_abs__doc__,
"abs($module, x, /)\n"

View file

@ -1,364 +1,341 @@
#include "third_party/python/Include/pymacro.h"
/*[clinic input]
preserve
[clinic start generated code]*/
PyDoc_STRVAR(_imp_lock_held__doc__,
"lock_held($module, /)\n"
"--\n"
"\n"
"Return True if the import lock is currently held, else False.\n"
"\n"
"On platforms without threads, return False.");
"lock_held($module, /)\n"
"--\n"
"\n"
"Return True if the import lock is currently held, else False.\n"
"\n"
"On platforms without threads, return False.");
#define _IMP_LOCK_HELD_METHODDEF \
{"lock_held", (PyCFunction)_imp_lock_held, METH_NOARGS, _imp_lock_held__doc__},
#define _IMP_LOCK_HELD_METHODDEF \
{"lock_held", (PyCFunction)_imp_lock_held, METH_NOARGS, \
_imp_lock_held__doc__},
static PyObject *
_imp_lock_held_impl(PyObject *module);
static PyObject *_imp_lock_held_impl(PyObject *module);
static PyObject *
_imp_lock_held(PyObject *module, PyObject *Py_UNUSED(ignored))
{
return _imp_lock_held_impl(module);
static PyObject *_imp_lock_held(PyObject *module,
PyObject *Py_UNUSED(ignored)) {
return _imp_lock_held_impl(module);
}
PyDoc_STRVAR(_imp_acquire_lock__doc__,
"acquire_lock($module, /)\n"
"--\n"
"\n"
"Acquires the interpreter\'s import lock for the current thread.\n"
"\n"
"This lock should be used by import hooks to ensure thread-safety when importing\n"
"modules. On platforms without threads, this function does nothing.");
PyDoc_STRVAR(
_imp_acquire_lock__doc__,
"acquire_lock($module, /)\n"
"--\n"
"\n"
"Acquires the interpreter\'s import lock for the current thread.\n"
"\n"
"This lock should be used by import hooks to ensure thread-safety when "
"importing\n"
"modules. On platforms without threads, this function does nothing.");
#define _IMP_ACQUIRE_LOCK_METHODDEF \
{"acquire_lock", (PyCFunction)_imp_acquire_lock, METH_NOARGS, _imp_acquire_lock__doc__},
#define _IMP_ACQUIRE_LOCK_METHODDEF \
{"acquire_lock", (PyCFunction)_imp_acquire_lock, METH_NOARGS, \
_imp_acquire_lock__doc__},
static PyObject *
_imp_acquire_lock_impl(PyObject *module);
static PyObject *_imp_acquire_lock_impl(PyObject *module);
static PyObject *
_imp_acquire_lock(PyObject *module, PyObject *Py_UNUSED(ignored))
{
return _imp_acquire_lock_impl(module);
static PyObject *_imp_acquire_lock(PyObject *module,
PyObject *Py_UNUSED(ignored)) {
return _imp_acquire_lock_impl(module);
}
PyDoc_STRVAR(_imp_release_lock__doc__,
"release_lock($module, /)\n"
"--\n"
"\n"
"Release the interpreter\'s import lock.\n"
"\n"
"On platforms without threads, this function does nothing.");
"release_lock($module, /)\n"
"--\n"
"\n"
"Release the interpreter\'s import lock.\n"
"\n"
"On platforms without threads, this function does nothing.");
#define _IMP_RELEASE_LOCK_METHODDEF \
{"release_lock", (PyCFunction)_imp_release_lock, METH_NOARGS, _imp_release_lock__doc__},
#define _IMP_RELEASE_LOCK_METHODDEF \
{"release_lock", (PyCFunction)_imp_release_lock, METH_NOARGS, \
_imp_release_lock__doc__},
static PyObject *
_imp_release_lock_impl(PyObject *module);
static PyObject *_imp_release_lock_impl(PyObject *module);
static PyObject *
_imp_release_lock(PyObject *module, PyObject *Py_UNUSED(ignored))
{
return _imp_release_lock_impl(module);
static PyObject *_imp_release_lock(PyObject *module,
PyObject *Py_UNUSED(ignored)) {
return _imp_release_lock_impl(module);
}
PyDoc_STRVAR(_imp__fix_co_filename__doc__,
"_fix_co_filename($module, code, path, /)\n"
"--\n"
"\n"
"Changes code.co_filename to specify the passed-in file path.\n"
"\n"
" code\n"
" Code object to change.\n"
" path\n"
" File path to use.");
"_fix_co_filename($module, code, path, /)\n"
"--\n"
"\n"
"Changes code.co_filename to specify the passed-in file path.\n"
"\n"
" code\n"
" Code object to change.\n"
" path\n"
" File path to use.");
#define _IMP__FIX_CO_FILENAME_METHODDEF \
{"_fix_co_filename", (PyCFunction)_imp__fix_co_filename, METH_VARARGS, _imp__fix_co_filename__doc__},
#define _IMP__FIX_CO_FILENAME_METHODDEF \
{"_fix_co_filename", (PyCFunction)_imp__fix_co_filename, METH_VARARGS, \
_imp__fix_co_filename__doc__},
static PyObject *
_imp__fix_co_filename_impl(PyObject *module, PyCodeObject *code,
PyObject *path);
static PyObject *_imp__fix_co_filename_impl(PyObject *module,
PyCodeObject *code, PyObject *path);
static PyObject *
_imp__fix_co_filename(PyObject *module, PyObject *args)
{
PyObject *return_value = NULL;
PyCodeObject *code;
PyObject *path;
static PyObject *_imp__fix_co_filename(PyObject *module, PyObject *args) {
PyObject *return_value = NULL;
PyCodeObject *code;
PyObject *path;
if (!PyArg_ParseTuple(args, "O!U:_fix_co_filename",
&PyCode_Type, &code, &path)) {
goto exit;
}
return_value = _imp__fix_co_filename_impl(module, code, path);
if (!PyArg_ParseTuple(args, "O!U:_fix_co_filename", &PyCode_Type, &code,
&path)) {
goto exit;
}
return_value = _imp__fix_co_filename_impl(module, code, path);
exit:
return return_value;
return return_value;
}
PyDoc_STRVAR(_imp_create_builtin__doc__,
"create_builtin($module, spec, /)\n"
"--\n"
"\n"
"Create an extension module.");
PyDoc_STRVAR(_imp_create_builtin__doc__, "create_builtin($module, spec, /)\n"
"--\n"
"\n"
"Create an extension module.");
#define _IMP_CREATE_BUILTIN_METHODDEF \
{"create_builtin", (PyCFunction)_imp_create_builtin, METH_O, _imp_create_builtin__doc__},
#define _IMP_CREATE_BUILTIN_METHODDEF \
{"create_builtin", (PyCFunction)_imp_create_builtin, METH_O, \
_imp_create_builtin__doc__},
PyDoc_STRVAR(_imp_extension_suffixes__doc__,
"extension_suffixes($module, /)\n"
"--\n"
"\n"
"Returns the list of file suffixes used to identify extension modules.");
PyDoc_STRVAR(
_imp_extension_suffixes__doc__,
"extension_suffixes($module, /)\n"
"--\n"
"\n"
"Returns the list of file suffixes used to identify extension modules.");
#define _IMP_EXTENSION_SUFFIXES_METHODDEF \
{"extension_suffixes", (PyCFunction)_imp_extension_suffixes, METH_NOARGS, _imp_extension_suffixes__doc__},
#define _IMP_EXTENSION_SUFFIXES_METHODDEF \
{"extension_suffixes", (PyCFunction)_imp_extension_suffixes, METH_NOARGS, \
_imp_extension_suffixes__doc__},
static PyObject *
_imp_extension_suffixes_impl(PyObject *module);
static PyObject *_imp_extension_suffixes_impl(PyObject *module);
static PyObject *
_imp_extension_suffixes(PyObject *module, PyObject *Py_UNUSED(ignored))
{
return _imp_extension_suffixes_impl(module);
static PyObject *_imp_extension_suffixes(PyObject *module,
PyObject *Py_UNUSED(ignored)) {
return _imp_extension_suffixes_impl(module);
}
PyDoc_STRVAR(_imp_init_frozen__doc__,
"init_frozen($module, name, /)\n"
"--\n"
"\n"
"Initializes a frozen module.");
PyDoc_STRVAR(_imp_init_frozen__doc__, "init_frozen($module, name, /)\n"
"--\n"
"\n"
"Initializes a frozen module.");
#define _IMP_INIT_FROZEN_METHODDEF \
{"init_frozen", (PyCFunction)_imp_init_frozen, METH_O, _imp_init_frozen__doc__},
#define _IMP_INIT_FROZEN_METHODDEF \
{"init_frozen", (PyCFunction)_imp_init_frozen, METH_O, \
_imp_init_frozen__doc__},
static PyObject *
_imp_init_frozen_impl(PyObject *module, PyObject *name);
static PyObject *_imp_init_frozen_impl(PyObject *module, PyObject *name);
static PyObject *
_imp_init_frozen(PyObject *module, PyObject *arg)
{
PyObject *return_value = NULL;
PyObject *name;
static PyObject *_imp_init_frozen(PyObject *module, PyObject *arg) {
PyObject *return_value = NULL;
PyObject *name;
if (!PyArg_Parse(arg, "U:init_frozen", &name)) {
goto exit;
}
return_value = _imp_init_frozen_impl(module, name);
if (!PyArg_Parse(arg, "U:init_frozen", &name)) {
goto exit;
}
return_value = _imp_init_frozen_impl(module, name);
exit:
return return_value;
return return_value;
}
PyDoc_STRVAR(_imp_get_frozen_object__doc__,
"get_frozen_object($module, name, /)\n"
"--\n"
"\n"
"Create a code object for a frozen module.");
"get_frozen_object($module, name, /)\n"
"--\n"
"\n"
"Create a code object for a frozen module.");
#define _IMP_GET_FROZEN_OBJECT_METHODDEF \
{"get_frozen_object", (PyCFunction)_imp_get_frozen_object, METH_O, _imp_get_frozen_object__doc__},
#define _IMP_GET_FROZEN_OBJECT_METHODDEF \
{"get_frozen_object", (PyCFunction)_imp_get_frozen_object, METH_O, \
_imp_get_frozen_object__doc__},
static PyObject *
_imp_get_frozen_object_impl(PyObject *module, PyObject *name);
static PyObject *_imp_get_frozen_object_impl(PyObject *module, PyObject *name);
static PyObject *
_imp_get_frozen_object(PyObject *module, PyObject *arg)
{
PyObject *return_value = NULL;
PyObject *name;
static PyObject *_imp_get_frozen_object(PyObject *module, PyObject *arg) {
PyObject *return_value = NULL;
PyObject *name;
if (!PyArg_Parse(arg, "U:get_frozen_object", &name)) {
goto exit;
}
return_value = _imp_get_frozen_object_impl(module, name);
if (!PyArg_Parse(arg, "U:get_frozen_object", &name)) {
goto exit;
}
return_value = _imp_get_frozen_object_impl(module, name);
exit:
return return_value;
return return_value;
}
PyDoc_STRVAR(_imp_is_frozen_package__doc__,
"is_frozen_package($module, name, /)\n"
"--\n"
"\n"
"Returns True if the module name is of a frozen package.");
"is_frozen_package($module, name, /)\n"
"--\n"
"\n"
"Returns True if the module name is of a frozen package.");
#define _IMP_IS_FROZEN_PACKAGE_METHODDEF \
{"is_frozen_package", (PyCFunction)_imp_is_frozen_package, METH_O, _imp_is_frozen_package__doc__},
#define _IMP_IS_FROZEN_PACKAGE_METHODDEF \
{"is_frozen_package", (PyCFunction)_imp_is_frozen_package, METH_O, \
_imp_is_frozen_package__doc__},
static PyObject *
_imp_is_frozen_package_impl(PyObject *module, PyObject *name);
static PyObject *_imp_is_frozen_package_impl(PyObject *module, PyObject *name);
static PyObject *
_imp_is_frozen_package(PyObject *module, PyObject *arg)
{
PyObject *return_value = NULL;
PyObject *name;
static PyObject *_imp_is_frozen_package(PyObject *module, PyObject *arg) {
PyObject *return_value = NULL;
PyObject *name;
if (!PyArg_Parse(arg, "U:is_frozen_package", &name)) {
goto exit;
}
return_value = _imp_is_frozen_package_impl(module, name);
if (!PyArg_Parse(arg, "U:is_frozen_package", &name)) {
goto exit;
}
return_value = _imp_is_frozen_package_impl(module, name);
exit:
return return_value;
return return_value;
}
PyDoc_STRVAR(_imp_is_builtin__doc__,
"is_builtin($module, name, /)\n"
"--\n"
"\n"
"Returns True if the module name corresponds to a built-in module.");
PyDoc_STRVAR(
_imp_is_builtin__doc__,
"is_builtin($module, name, /)\n"
"--\n"
"\n"
"Returns True if the module name corresponds to a built-in module.");
#define _IMP_IS_BUILTIN_METHODDEF \
{"is_builtin", (PyCFunction)_imp_is_builtin, METH_O, _imp_is_builtin__doc__},
#define _IMP_IS_BUILTIN_METHODDEF \
{"is_builtin", (PyCFunction)_imp_is_builtin, METH_O, _imp_is_builtin__doc__},
static PyObject *
_imp_is_builtin_impl(PyObject *module, PyObject *name);
static PyObject *_imp_is_builtin_impl(PyObject *module, PyObject *name);
static PyObject *
_imp_is_builtin(PyObject *module, PyObject *arg)
{
PyObject *return_value = NULL;
PyObject *name;
static PyObject *_imp_is_builtin(PyObject *module, PyObject *arg) {
PyObject *return_value = NULL;
PyObject *name;
if (!PyArg_Parse(arg, "U:is_builtin", &name)) {
goto exit;
}
return_value = _imp_is_builtin_impl(module, name);
if (!PyArg_Parse(arg, "U:is_builtin", &name)) {
goto exit;
}
return_value = _imp_is_builtin_impl(module, name);
exit:
return return_value;
return return_value;
}
PyDoc_STRVAR(_imp_is_frozen__doc__,
"is_frozen($module, name, /)\n"
"--\n"
"\n"
"Returns True if the module name corresponds to a frozen module.");
"is_frozen($module, name, /)\n"
"--\n"
"\n"
"Returns True if the module name corresponds to a frozen module.");
#define _IMP_IS_FROZEN_METHODDEF \
{"is_frozen", (PyCFunction)_imp_is_frozen, METH_O, _imp_is_frozen__doc__},
#define _IMP_IS_FROZEN_METHODDEF \
{"is_frozen", (PyCFunction)_imp_is_frozen, METH_O, _imp_is_frozen__doc__},
static PyObject *
_imp_is_frozen_impl(PyObject *module, PyObject *name);
static PyObject *_imp_is_frozen_impl(PyObject *module, PyObject *name);
static PyObject *
_imp_is_frozen(PyObject *module, PyObject *arg)
{
PyObject *return_value = NULL;
PyObject *name;
static PyObject *_imp_is_frozen(PyObject *module, PyObject *arg) {
PyObject *return_value = NULL;
PyObject *name;
if (!PyArg_Parse(arg, "U:is_frozen", &name)) {
goto exit;
}
return_value = _imp_is_frozen_impl(module, name);
if (!PyArg_Parse(arg, "U:is_frozen", &name)) {
goto exit;
}
return_value = _imp_is_frozen_impl(module, name);
exit:
return return_value;
return return_value;
}
#if defined(HAVE_DYNAMIC_LOADING)
PyDoc_STRVAR(_imp_create_dynamic__doc__,
"create_dynamic($module, spec, file=None, /)\n"
"--\n"
"\n"
"Create an extension module.");
"create_dynamic($module, spec, file=None, /)\n"
"--\n"
"\n"
"Create an extension module.");
#define _IMP_CREATE_DYNAMIC_METHODDEF \
{"create_dynamic", (PyCFunction)_imp_create_dynamic, METH_VARARGS, _imp_create_dynamic__doc__},
#define _IMP_CREATE_DYNAMIC_METHODDEF \
{"create_dynamic", (PyCFunction)_imp_create_dynamic, METH_VARARGS, \
_imp_create_dynamic__doc__},
static PyObject *
_imp_create_dynamic_impl(PyObject *module, PyObject *spec, PyObject *file);
static PyObject *_imp_create_dynamic_impl(PyObject *module, PyObject *spec,
PyObject *file);
static PyObject *
_imp_create_dynamic(PyObject *module, PyObject *args)
{
PyObject *return_value = NULL;
PyObject *spec;
PyObject *file = NULL;
static PyObject *_imp_create_dynamic(PyObject *module, PyObject *args) {
PyObject *return_value = NULL;
PyObject *spec;
PyObject *file = NULL;
if (!PyArg_UnpackTuple(args, "create_dynamic",
1, 2,
&spec, &file)) {
goto exit;
}
return_value = _imp_create_dynamic_impl(module, spec, file);
if (!PyArg_UnpackTuple(args, "create_dynamic", 1, 2, &spec, &file)) {
goto exit;
}
return_value = _imp_create_dynamic_impl(module, spec, file);
exit:
return return_value;
return return_value;
}
#endif /* defined(HAVE_DYNAMIC_LOADING) */
#if defined(HAVE_DYNAMIC_LOADING)
PyDoc_STRVAR(_imp_exec_dynamic__doc__,
"exec_dynamic($module, mod, /)\n"
"--\n"
"\n"
"Initialize an extension module.");
PyDoc_STRVAR(_imp_exec_dynamic__doc__, "exec_dynamic($module, mod, /)\n"
"--\n"
"\n"
"Initialize an extension module.");
#define _IMP_EXEC_DYNAMIC_METHODDEF \
{"exec_dynamic", (PyCFunction)_imp_exec_dynamic, METH_O, _imp_exec_dynamic__doc__},
#define _IMP_EXEC_DYNAMIC_METHODDEF \
{"exec_dynamic", (PyCFunction)_imp_exec_dynamic, METH_O, \
_imp_exec_dynamic__doc__},
static int
_imp_exec_dynamic_impl(PyObject *module, PyObject *mod);
static int _imp_exec_dynamic_impl(PyObject *module, PyObject *mod);
static PyObject *
_imp_exec_dynamic(PyObject *module, PyObject *mod)
{
PyObject *return_value = NULL;
int _return_value;
static PyObject *_imp_exec_dynamic(PyObject *module, PyObject *mod) {
PyObject *return_value = NULL;
int _return_value;
_return_value = _imp_exec_dynamic_impl(module, mod);
if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
}
return_value = PyLong_FromLong((long)_return_value);
_return_value = _imp_exec_dynamic_impl(module, mod);
if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
}
return_value = PyLong_FromLong((long)_return_value);
exit:
return return_value;
return return_value;
}
#endif /* defined(HAVE_DYNAMIC_LOADING) */
PyDoc_STRVAR(_imp_exec_builtin__doc__,
"exec_builtin($module, mod, /)\n"
"--\n"
"\n"
"Initialize a built-in module.");
PyDoc_STRVAR(_imp_exec_builtin__doc__, "exec_builtin($module, mod, /)\n"
"--\n"
"\n"
"Initialize a built-in module.");
#define _IMP_EXEC_BUILTIN_METHODDEF \
{"exec_builtin", (PyCFunction)_imp_exec_builtin, METH_O, _imp_exec_builtin__doc__},
#define _IMP_EXEC_BUILTIN_METHODDEF \
{"exec_builtin", (PyCFunction)_imp_exec_builtin, METH_O, \
_imp_exec_builtin__doc__},
static int
_imp_exec_builtin_impl(PyObject *module, PyObject *mod);
static int _imp_exec_builtin_impl(PyObject *module, PyObject *mod);
static PyObject *
_imp_exec_builtin(PyObject *module, PyObject *mod)
{
PyObject *return_value = NULL;
int _return_value;
static PyObject *_imp_exec_builtin(PyObject *module, PyObject *mod) {
PyObject *return_value = NULL;
int _return_value;
_return_value = _imp_exec_builtin_impl(module, mod);
if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
}
return_value = PyLong_FromLong((long)_return_value);
_return_value = _imp_exec_builtin_impl(module, mod);
if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
}
return_value = PyLong_FromLong((long)_return_value);
exit:
return return_value;
return return_value;
}
#ifndef _IMP_CREATE_DYNAMIC_METHODDEF
#define _IMP_CREATE_DYNAMIC_METHODDEF
#define _IMP_CREATE_DYNAMIC_METHODDEF
#endif /* !defined(_IMP_CREATE_DYNAMIC_METHODDEF) */
#ifndef _IMP_EXEC_DYNAMIC_METHODDEF
#define _IMP_EXEC_DYNAMIC_METHODDEF
#define _IMP_EXEC_DYNAMIC_METHODDEF
#endif /* !defined(_IMP_EXEC_DYNAMIC_METHODDEF) */
/*[clinic end generated code: output=d24d7f73702a907f input=a9049054013a1b77]*/

View file

@ -1,3 +1,18 @@
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/bytesobject.h"
#include "third_party/python/Include/ceval.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/listobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/pycapsule.h"
#include "third_party/python/Include/pyctype.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pymacro.h"
#include "third_party/python/Include/pymem.h"
#include "third_party/python/Include/pystate.h"
#include "third_party/python/Include/tupleobject.h"
#include "third_party/python/Include/ucnhash.h"
/* clang-format off */
/* ------------------------------------------------------------------------
@ -10,9 +25,6 @@ Copyright (c) Corporation for National Research Initiatives.
------------------------------------------------------------------------ */
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/ucnhash.h"
const char *Py_hexdigits = "0123456789abcdef";
/* --- Codec Registry ----------------------------------------------------- */
@ -73,7 +85,7 @@ PyObject *normalizestring(const char *string)
if (ch == ' ')
ch = '-';
else
ch = Py_TOLOWER(Py_CHARMASK(ch));
ch = Py_TOLOWER(ch);
p[i] = ch;
}
p[i] = '\0';

View file

@ -1,3 +1,24 @@
#include "third_party/python/Include/Python-ast.h"
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/ast.h"
#include "third_party/python/Include/boolobject.h"
#include "third_party/python/Include/ceval.h"
#include "third_party/python/Include/code.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/listobject.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/node.h"
#include "third_party/python/Include/objimpl.h"
#include "third_party/python/Include/opcode.h"
#include "third_party/python/Include/pycapsule.h"
#include "third_party/python/Include/pydebug.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/sliceobject.h"
#include "third_party/python/Include/symtable.h"
#include "third_party/python/Include/unicodeobject.h"
#include "third_party/python/Include/warnings.h"
#include "third_party/python/Python/wordcode_helpers.inc"
/* clang-format off */
/*
@ -23,16 +44,6 @@
* objects.
*/
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/Python-ast.h"
#include "third_party/python/Include/node.h"
#include "third_party/python/Include/ast.h"
#include "third_party/python/Include/code.h"
#include "third_party/python/Include/symtable.h"
#include "third_party/python/Include/opcode.h"
#include "third_party/python/Python/wordcode_helpers.h"
#define DEFAULT_BLOCK_SIZE 16
#define DEFAULT_BLOCKS 8
#define DEFAULT_CODE_SIZE 128
@ -290,7 +301,7 @@ _Py_Mangle(PyObject *privateobj, PyObject *ident)
static int
compiler_init(struct compiler *c)
{
memset(c, 0, sizeof(struct compiler));
bzero(c, sizeof(struct compiler));
c->c_stack = PyList_New(0);
if (!c->c_stack)
@ -543,7 +554,7 @@ compiler_enter_scope(struct compiler *c, identifier name,
PyErr_NoMemory();
return 0;
}
memset(u, 0, sizeof(struct compiler_unit));
bzero(u, sizeof(struct compiler_unit));
u->u_scope_type = scope_type;
u->u_argcount = 0;
u->u_kwonlyargcount = 0;
@ -764,7 +775,7 @@ compiler_new_block(struct compiler *c)
PyErr_NoMemory();
return NULL;
}
memset((void *)b, 0, sizeof(basicblock));
bzero((void *)b, sizeof(basicblock));
/* Extend the singly linked list of blocks with new block. */
b->b_list = u->u_blocks;
u->u_blocks = b;
@ -808,8 +819,7 @@ compiler_next_instr(struct compiler *c, basicblock *b)
return -1;
}
b->b_ialloc = DEFAULT_BLOCK_SIZE;
memset((char *)b->b_instr, 0,
sizeof(struct instr) * DEFAULT_BLOCK_SIZE);
bzero((char *)b->b_instr, sizeof(struct instr) * DEFAULT_BLOCK_SIZE);
}
else if (b->b_iused == b->b_ialloc) {
struct instr *tmp;
@ -834,7 +844,7 @@ compiler_next_instr(struct compiler *c, basicblock *b)
return -1;
}
b->b_instr = tmp;
memset((char *)b->b_instr + oldsize, 0, newsize - oldsize);
bzero((char *)b->b_instr + oldsize, newsize - oldsize);
}
return b->b_iused++;
}
@ -4871,7 +4881,7 @@ stackdepth(struct compiler *c)
static int
assemble_init(struct assembler *a, int nblocks, int firstlineno)
{
memset(a, 0, sizeof(struct assembler));
bzero(a, sizeof(struct assembler));
a->a_lineno = firstlineno;
a->a_bytecode = PyBytes_FromStringAndSize(NULL, DEFAULT_CODE_SIZE);
if (!a->a_bytecode)
@ -5324,7 +5334,7 @@ assemble(struct compiler *c, int addNone)
}
#undef PyAST_Compile
PyAPI_FUNC(PyCodeObject *)
PyCodeObject *
PyAST_Compile(mod_ty mod, const char *filename, PyCompilerFlags *flags,
PyArena *arena)
{

View file

@ -1,6 +1,6 @@
#ifndef _CONDVAR_H_
#define _CONDVAR_H_
#include "third_party/python/Include/Python.h"
#include "libc/time/time.h"
/* clang-format off */
/*

View file

@ -1,3 +1,8 @@
#include "libc/assert.h"
#include "libc/errno.h"
#include "libc/math.h"
#include "third_party/python/Include/pymem.h"
#include "third_party/python/Include/pyport.h"
/* clang-format off */
/****************************************************************
@ -116,9 +121,6 @@
/* Linking of Python's #defines to Gay's #defines starts here. */
#include "third_party/python/Include/Python.h"
#include "libc/math.h"
/* if PY_NO_SHORT_FLOAT_REPR is defined, then don't even try to compile
the following code */
#ifndef PY_NO_SHORT_FLOAT_REPR

View file

@ -1,11 +1,9 @@
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Python/importdl.h"
/* clang-format off */
/* Support for dynamic loading of extension modules */
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/importdl.h"
extern char *Py_GetProgramName(void);
const char *_PyImport_DynLoadFiletab[] = {".o", NULL};

View file

@ -1,5 +1,9 @@
#include "libc/calls/weirdtypes.h"
#include "libc/runtime/dlfcn.h"
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/fileutils.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pystate.h"
#include "third_party/python/Python/importdl.h"
/* clang-format off */

View file

@ -1,5 +1,4 @@
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/importdl.h"
#include "third_party/python/Python/importdl.h"
/* clang-format off */
/* This module provides the necessary stubs for when dynamic loading is

View file

@ -1,6 +1,5 @@
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/importdl.h"
#include "third_party/python/Include/patchlevel.h"
#include "third_party/python/Python/importdl.h"
/* clang-format off */
// "activation context" magic - see dl_nt.c...

View file

@ -1,14 +1,21 @@
#include "third_party/python/Include/Python.h"
#include "libc/errno.h"
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/fileobject.h"
#include "third_party/python/Include/fileutils.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/object.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pystate.h"
#include "third_party/python/Include/sysmodule.h"
#include "third_party/python/Include/traceback.h"
#include "third_party/python/Include/tupleobject.h"
/* clang-format off */
#ifdef __cplusplus
extern "C" {
#endif
_Py_IDENTIFIER(builtins);
_Py_IDENTIFIER(stderr);
void
PyErr_Restore(PyObject *type, PyObject *value, PyObject *traceback)
{
@ -1176,7 +1183,3 @@ PyErr_ProgramTextObject(PyObject *filename, int lineno)
}
return err_programtext(fp, lineno);
}
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,12 +1,24 @@
#include "libc/math.h"
#include "libc/unicode/locale.h"
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/complexobject.h"
#include "third_party/python/Include/fileutils.h"
#include "third_party/python/Include/floatobject.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/object.h"
#include "third_party/python/Include/pyctype.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pymacro.h"
#include "third_party/python/Include/pymem.h"
#include "third_party/python/Include/pyport.h"
#include "third_party/python/Include/pystrtod.h"
#include "third_party/python/Include/unicodeobject.h"
/* clang-format off */
/* implements the unicode (as opposed to string) version of the
built-in formatters for string, int, float. that is, the versions
of int.__float__, etc., that take and return unicode objects */
#include "third_party/python/Include/Python.h"
#include "libc/unicode/locale.h"
/* Raises an exception about an unknown presentation type for this
* type. */

View file

@ -1,9 +1,9 @@
/* clang-format off */
/* Dummy frozen modules initializer */
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Python/importlib.inc"
#include "third_party/python/Python/importlib_external.inc"
/* clang-format off */
/* Dummy frozen modules initializer */
/* In order to test the support for frozen modules, by default we
define a single frozen module, __hello__. Loading it will print

View file

@ -1,8 +1,15 @@
/* clang-format off */
/* Python interpreter main program for frozen scripts */
#include "third_party/python/Include/Python.h"
#include "libc/calls/calls.h"
#include "libc/stdio/stdio.h"
#include "libc/unicode/locale.h"
#include "third_party/python/Include/fileutils.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/pydebug.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pylifecycle.h"
#include "third_party/python/Include/pymem.h"
#include "third_party/python/Include/pythonrun.h"
#include "third_party/python/Include/sysmodule.h"
/* clang-format off */
#ifdef MS_WINDOWS
extern void PyWinFreeze_ExeInit(void);
@ -10,8 +17,6 @@ extern void PyWinFreeze_ExeTerm(void);
extern int PyInitFrozenExtensions(void);
#endif
/* Main program */
int
Py_FrozenMain(int argc, char **argv)
{

View file

@ -1,12 +1,13 @@
/* clang-format off */
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/Python-ast.h"
#include "third_party/python/Include/node.h"
#include "third_party/python/Include/token.h"
#include "third_party/python/Include/graminit.h"
#include "third_party/python/Include/code.h"
#include "third_party/python/Include/graminit.h"
#include "third_party/python/Include/node.h"
#include "third_party/python/Include/objimpl.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/symtable.h"
#include "third_party/python/Include/token.h"
#include "third_party/python/Include/unicodeobject.h"
/* clang-format off */
#define UNDEFINED_FUTURE_FEATURE "future feature %.100s is not defined"
#define ERR_LATE_FUTURE \

View file

@ -1,11 +1,21 @@
#include "libc/assert.h"
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/bytearrayobject.h"
#include "third_party/python/Include/bytesobject.h"
#include "third_party/python/Include/complexobject.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/floatobject.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/object.h"
#include "third_party/python/Include/pyctype.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pymacro.h"
#include "third_party/python/Include/pymem.h"
/* clang-format off */
/* New getargs implementation */
#include "third_party/python/Include/Python.h"
#ifdef __cplusplus
extern "C" {
#endif
int PyArg_Parse(PyObject *, const char *, ...);
int PyArg_ParseTuple(PyObject *, const char *, ...);
int PyArg_VaParse(PyObject *, const char *, va_list);
@ -22,20 +32,20 @@ int _PyArg_VaParseTupleAndKeywordsFast(PyObject *, PyObject *,
#ifdef HAVE_DECLSPEC_DLL
/* Export functions */
PyAPI_FUNC(int) _PyArg_Parse_SizeT(PyObject *, const char *, ...);
PyAPI_FUNC(int) _PyArg_ParseStack_SizeT(PyObject **args, Py_ssize_t nargs, PyObject *kwnames,
struct _PyArg_Parser *parser, ...);
PyAPI_FUNC(int) _PyArg_ParseTuple_SizeT(PyObject *, const char *, ...);
PyAPI_FUNC(int) _PyArg_ParseTupleAndKeywords_SizeT(PyObject *, PyObject *,
int _PyArg_Parse_SizeT(PyObject *, const char *, ...);
int _PyArg_ParseStack_SizeT(PyObject **, Py_ssize_t , PyObject *,
struct _PyArg_Parser *, ...);
int _PyArg_ParseTuple_SizeT(PyObject *, const char *, ...);
int _PyArg_ParseTupleAndKeywords_SizeT(PyObject *, PyObject *,
const char *, char **, ...);
PyAPI_FUNC(PyObject *) _Py_BuildValue_SizeT(const char *, ...);
PyAPI_FUNC(int) _PyArg_VaParse_SizeT(PyObject *, const char *, va_list);
PyAPI_FUNC(int) _PyArg_VaParseTupleAndKeywords_SizeT(PyObject *, PyObject *,
PyObject * _Py_BuildValue_SizeT(const char *, ...);
int _PyArg_VaParse_SizeT(PyObject *, const char *, va_list);
int _PyArg_VaParseTupleAndKeywords_SizeT(PyObject *, PyObject *,
const char *, char **, va_list);
PyAPI_FUNC(int) _PyArg_ParseTupleAndKeywordsFast_SizeT(PyObject *, PyObject *,
int _PyArg_ParseTupleAndKeywordsFast_SizeT(PyObject *, PyObject *,
struct _PyArg_Parser *, ...);
PyAPI_FUNC(int) _PyArg_VaParseTupleAndKeywordsFast_SizeT(PyObject *, PyObject *,
int _PyArg_VaParseTupleAndKeywordsFast_SizeT(PyObject *, PyObject *,
struct _PyArg_Parser *, va_list);
#endif
@ -275,7 +285,7 @@ vgetargs1(PyObject *args, const char *format, va_list *p_va, int flags)
break;
default:
if (level == 0) {
if (Py_ISALPHA(Py_CHARMASK(c)))
if (Py_ISALPHA(c))
if (c != 'e') /* skip encoded */
max++;
}
@ -368,7 +378,7 @@ vgetargs1(PyObject *args, const char *format, va_list *p_va, int flags)
}
}
if (*format != '\0' && !Py_ISALPHA(Py_CHARMASK(*format)) &&
if (*format != '\0' && !Py_ISALPHA(*format) &&
*format != '(' &&
*format != '|' && *format != ':' && *format != ';') {
PyErr_Format(PyExc_SystemError,
@ -467,7 +477,7 @@ converttuple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
}
else if (c == ':' || c == ';' || c == '\0')
break;
else if (level == 0 && Py_ISALPHA(Py_CHARMASK(c)))
else if (level == 0 && Py_ISALPHA(c))
n++;
}
@ -2453,7 +2463,3 @@ _PyArg_Fini(void)
}
static_arg_parsers = NULL;
}
#ifdef __cplusplus
};
#endif

View file

@ -1,9 +1,8 @@
#include "third_party/python/Include/pylifecycle.h"
/* clang-format off */
/* Return the compiler identification, if possible. */
#include "third_party/python/Include/Python.h"
#ifndef COMPILER
#ifdef __GNUC__

View file

@ -1,9 +1,8 @@
#include "third_party/python/Include/pylifecycle.h"
/* clang-format off */
/* Return the copyright string. This is updated manually. */
#include "third_party/python/Include/Python.h"
static const char cprt[] =
"\
Copyright (c) 2001-2021 Python Software Foundation.\n\

View file

@ -1,3 +1,6 @@
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "third_party/python/Include/pygetopt.h"
/* clang-format off */
/*---------------------------------------------------------------------------*
* <RCS keywords>
@ -28,13 +31,6 @@
/* Modified to support --help and --version, as well as /? on Windows
* by Georg Brandl. */
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/pygetopt.h"
#ifdef __cplusplus
extern "C" {
#endif
int _PyOS_opterr = 1; /* generate error messages */
int _PyOS_optind = 1; /* index into argv array */
wchar_t *_PyOS_optarg = NULL; /* optional argument */
@ -123,7 +119,3 @@ int _PyOS_GetOpt(int argc, wchar_t **argv, wchar_t *optstring)
return option;
}
#ifdef __cplusplus
}
#endif

View file

@ -1,5 +1,4 @@
/* clang-format off */
#include "third_party/python/Include/Python.h"
#ifndef PLATFORM
#define PLATFORM "unknown"

View file

@ -1,7 +1,9 @@
/* clang-format off */
/* Return the full version string. */
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/patchlevel.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pylifecycle.h"
/* clang-format off */
/* Return the full version string. */
const char *
Py_GetVersion(void)

View file

@ -2,7 +2,7 @@
/* Generated by Parser/pgen */
#include "third_party/python/Include/pgenheaders.h"
#include "third_party/python/Include/grammar.h"
PyAPI_DATA(grammar) _PyParser_Grammar;
extern grammar _PyParser_Grammar;
static arc arcs_0_0[3] = {
{2, 1},
{3, 1},

View file

@ -1,12 +1,31 @@
#include "third_party/python/Include/Python.h"
/**/
#include "third_party/python/Include/Python-ast.h"
#undef Yield /* undefine macro conflicting with winbase.h */
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/boolobject.h"
#include "third_party/python/Include/ceval.h"
#include "third_party/python/Include/code.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/errcode.h"
#include "third_party/python/Include/eval.h"
#include "third_party/python/Include/fileutils.h"
#include "third_party/python/Include/frameobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/listobject.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/marshal.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/objimpl.h"
#include "third_party/python/Include/osdefs.h"
#include "third_party/python/Include/pgenheaders.h"
#include "third_party/python/Include/pydebug.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pylifecycle.h"
#include "third_party/python/Include/pymacro.h"
#include "third_party/python/Include/pythonrun.h"
#include "third_party/python/Include/sysmodule.h"
#include "third_party/python/Include/traceback.h"
#include "third_party/python/Include/tupleobject.h"
#include "third_party/python/Include/warnings.h"
#include "third_party/python/Include/weakrefobject.h"
#include "third_party/python/Python/importdl.h"
/* clang-format off */
@ -1008,7 +1027,7 @@ get_path_importer(PyObject *path_importer_cache, PyObject *path_hooks,
return importer;
}
PyAPI_FUNC(PyObject *)
PyObject *
PyImport_GetImporter(PyObject *path) {
PyObject *importer=NULL, *path_importer_cache=NULL, *path_hooks=NULL;

View file

@ -1,6 +1,14 @@
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/bytesobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/moduleobject.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/unicodeobject.h"
#include "third_party/python/Python/importdl.h"
/* clang-format off */
/* Support for dynamic loading of extension modules */
#include "third_party/python/Include/Python.h"
/* ./configure sets HAVE_DYNAMIC_LOADING if dynamic loading of modules is
supported on this platform. configure will then compile and link in one
@ -9,8 +17,6 @@
*/
#ifdef HAVE_DYNAMIC_LOADING
#include "third_party/python/Python/importdl.h"
#ifdef MS_WINDOWS
extern dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix,
const char *shortname,

View file

@ -1,9 +1,7 @@
#ifndef Py_IMPORTDL_H
#define Py_IMPORTDL_H
#ifdef __cplusplus
extern "C" {
#endif
#include "third_party/python/Include/object.h"
COSMOPOLITAN_C_START_
extern const char *_PyImport_DynLoadFiletab[];
@ -14,7 +12,5 @@ extern PyObject *_PyImport_LoadDynamicModuleWithSpec(PyObject *spec, FILE *);
typedef void (*dl_funcptr)(void);
#ifdef __cplusplus
}
#endif
COSMOPOLITAN_C_END_
#endif /* !Py_IMPORTDL_H */

View file

@ -1,6 +1,30 @@
#define PY_SSIZE_T_CLEAN
#include "dsp/mpeg/video.h"
#include "libc/calls/calls.h"
#include "libc/calls/weirdtypes.h"
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/boolobject.h"
#include "third_party/python/Include/code.h"
#include "third_party/python/Include/complexobject.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/fileutils.h"
#include "third_party/python/Include/floatobject.h"
#include "third_party/python/Include/listobject.h"
#include "third_party/python/Include/longintrepr.h"
#include "third_party/python/Include/marshal.h"
#include "third_party/python/Include/memoryobject.h"
#include "third_party/python/Include/methodobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pymacro.h"
#include "third_party/python/Include/pymem.h"
#include "third_party/python/Include/pystrtod.h"
#include "third_party/python/Include/setobject.h"
#include "third_party/python/Include/sliceobject.h"
#include "third_party/python/Include/tupleobject.h"
#include "third_party/python/Modules/hashtable.h"
/* clang-format off */
/* Write Python objects to files and read them back.
This is primarily intended for writing and reading compiled Python code,
even though dicts, lists, sets and frozensets, not commonly seen in
@ -8,14 +32,6 @@
Version 3 of this protocol properly supports circular links
and sharing. */
#define PY_SSIZE_T_CLEAN
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/longintrepr.h"
#include "third_party/python/Include/code.h"
#include "third_party/python/Include/marshal.h"
#include "third_party/python/Modules/hashtable.h"
/* High water mark to determine when the marshalled object is dangerously deep
* and risks coring the interpreter. When the object stack gets this deep,
* raise an exception instead of continuing.
@ -613,7 +629,7 @@ PyMarshal_WriteLongToFile(long x, FILE *fp, int version)
{
char buf[4];
WFILE wf;
memset(&wf, 0, sizeof(wf));
bzero(&wf, sizeof(wf));
wf.fp = fp;
wf.ptr = wf.buf = buf;
wf.end = wf.ptr + sizeof(buf);
@ -628,7 +644,7 @@ PyMarshal_WriteObjectToFile(PyObject *x, FILE *fp, int version)
{
char buf[BUFSIZ];
WFILE wf;
memset(&wf, 0, sizeof(wf));
bzero(&wf, sizeof(wf));
wf.fp = fp;
wf.ptr = wf.buf = buf;
wf.end = wf.ptr + sizeof(buf);
@ -1620,7 +1636,7 @@ PyMarshal_WriteObjectToString(PyObject *x, int version)
{
WFILE wf;
memset(&wf, 0, sizeof(wf));
bzero(&wf, sizeof(wf));
wf.str = PyBytes_FromStringAndSize((char *)NULL, 50);
if (wf.str == NULL)
return NULL;

View file

@ -1,6 +1,16 @@
#include "libc/assert.h"
#include "third_party/python/Include/ceval.h"
#include "third_party/python/Include/complexobject.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/floatobject.h"
#include "third_party/python/Include/listobject.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/object.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/tupleobject.h"
/* clang-format off */
/* Module support implementation */
#include "third_party/python/Include/Python.h"
#define FLAG_SIZE_T 1
typedef double va_double;

View file

@ -1,7 +1,8 @@
#include "libc/assert.h"
#include "libc/fmt/fmt.h"
#include "third_party/python/Include/pyerrors.h"
/* clang-format off */
#include "third_party/python/Include/Python.h"
/* snprintf() wrappers. If the platform has vsnprintf, we use it, else we
emulate it in a half-hearted way. Even if the platform has it, we wrap
it because platforms differ in what vsnprintf does in case the buffer

View file

@ -1,9 +1,10 @@
#include "libc/errno.h"
#include "libc/limits.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/pyctype.h"
#include "third_party/python/Include/pymacro.h"
#include "third_party/python/pyconfig.h"
/* clang-format off */
#include "third_party/python/Include/Python.h"
#if defined(__sgi) && defined(WITH_THREAD) && !defined(_SGI_MP_SOURCE)
#define _SGI_MP_SOURCE
#endif
/* Static overflow check values for bases 2 through 36.
* smallmax[base] is the largest unsigned long i such that

View file

@ -1,13 +1,23 @@
/* clang-format off */
/* Peephole optimizations for bytecode compiler. */
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/Python-ast.h"
#include "third_party/python/Include/node.h"
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/ast.h"
#include "third_party/python/Include/bytesobject.h"
#include "third_party/python/Include/code.h"
#include "third_party/python/Include/symtable.h"
#include "third_party/python/Include/listobject.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/node.h"
#include "third_party/python/Include/opcode.h"
#include "third_party/python/Python/wordcode_helpers.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pymem.h"
#include "third_party/python/Include/setobject.h"
#include "third_party/python/Include/symtable.h"
#include "third_party/python/Include/tupleobject.h"
#include "third_party/python/Include/unicodeobject.h"
#include "third_party/python/Python/wordcode_helpers.inc"
#include "third_party/quickjs/internal.h"
/* clang-format off */
/* Peephole optimizations for bytecode compiler. */
#define UNCONDITIONAL_JUMP(op) (op==JUMP_ABSOLUTE || op==JUMP_FORWARD)
#define CONDITIONAL_JUMP(op) (op==POP_JUMP_IF_FALSE || op==POP_JUMP_IF_TRUE \
@ -490,7 +500,7 @@ markblocks(_Py_CODEUNIT *code, Py_ssize_t len)
PyErr_NoMemory();
return NULL;
}
memset(blocks, 0, len*sizeof(int));
bzero(blocks, len*sizeof(int));
/* Mark labels in the first pass */
for (i = 0; i < len; i++) {

View file

@ -1,5 +1,12 @@
#include "libc/assert.h"
#include "libc/mem/mem.h"
#include "third_party/python/Include/listobject.h"
#include "third_party/python/Include/object.h"
#include "third_party/python/Include/pyarena.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pymacro.h"
#include "third_party/python/Include/pymem.h"
/* clang-format off */
#include "third_party/python/Include/Python.h"
/* A simple arena block structure.

View file

@ -1,215 +0,0 @@
/* clang-format off */
#include "third_party/python/Include/Python.h"
/* Our own locale-independent ctype.h-like macros */
const unsigned int _Py_ctype_table[256] = {
0, /* 0x0 '\x00' */
0, /* 0x1 '\x01' */
0, /* 0x2 '\x02' */
0, /* 0x3 '\x03' */
0, /* 0x4 '\x04' */
0, /* 0x5 '\x05' */
0, /* 0x6 '\x06' */
0, /* 0x7 '\x07' */
0, /* 0x8 '\x08' */
PY_CTF_SPACE, /* 0x9 '\t' */
PY_CTF_SPACE, /* 0xa '\n' */
PY_CTF_SPACE, /* 0xb '\v' */
PY_CTF_SPACE, /* 0xc '\f' */
PY_CTF_SPACE, /* 0xd '\r' */
0, /* 0xe '\x0e' */
0, /* 0xf '\x0f' */
0, /* 0x10 '\x10' */
0, /* 0x11 '\x11' */
0, /* 0x12 '\x12' */
0, /* 0x13 '\x13' */
0, /* 0x14 '\x14' */
0, /* 0x15 '\x15' */
0, /* 0x16 '\x16' */
0, /* 0x17 '\x17' */
0, /* 0x18 '\x18' */
0, /* 0x19 '\x19' */
0, /* 0x1a '\x1a' */
0, /* 0x1b '\x1b' */
0, /* 0x1c '\x1c' */
0, /* 0x1d '\x1d' */
0, /* 0x1e '\x1e' */
0, /* 0x1f '\x1f' */
PY_CTF_SPACE, /* 0x20 ' ' */
0, /* 0x21 '!' */
0, /* 0x22 '"' */
0, /* 0x23 '#' */
0, /* 0x24 '$' */
0, /* 0x25 '%' */
0, /* 0x26 '&' */
0, /* 0x27 "'" */
0, /* 0x28 '(' */
0, /* 0x29 ')' */
0, /* 0x2a '*' */
0, /* 0x2b '+' */
0, /* 0x2c ',' */
0, /* 0x2d '-' */
0, /* 0x2e '.' */
0, /* 0x2f '/' */
PY_CTF_DIGIT|PY_CTF_XDIGIT, /* 0x30 '0' */
PY_CTF_DIGIT|PY_CTF_XDIGIT, /* 0x31 '1' */
PY_CTF_DIGIT|PY_CTF_XDIGIT, /* 0x32 '2' */
PY_CTF_DIGIT|PY_CTF_XDIGIT, /* 0x33 '3' */
PY_CTF_DIGIT|PY_CTF_XDIGIT, /* 0x34 '4' */
PY_CTF_DIGIT|PY_CTF_XDIGIT, /* 0x35 '5' */
PY_CTF_DIGIT|PY_CTF_XDIGIT, /* 0x36 '6' */
PY_CTF_DIGIT|PY_CTF_XDIGIT, /* 0x37 '7' */
PY_CTF_DIGIT|PY_CTF_XDIGIT, /* 0x38 '8' */
PY_CTF_DIGIT|PY_CTF_XDIGIT, /* 0x39 '9' */
0, /* 0x3a ':' */
0, /* 0x3b ';' */
0, /* 0x3c '<' */
0, /* 0x3d '=' */
0, /* 0x3e '>' */
0, /* 0x3f '?' */
0, /* 0x40 '@' */
PY_CTF_UPPER|PY_CTF_XDIGIT, /* 0x41 'A' */
PY_CTF_UPPER|PY_CTF_XDIGIT, /* 0x42 'B' */
PY_CTF_UPPER|PY_CTF_XDIGIT, /* 0x43 'C' */
PY_CTF_UPPER|PY_CTF_XDIGIT, /* 0x44 'D' */
PY_CTF_UPPER|PY_CTF_XDIGIT, /* 0x45 'E' */
PY_CTF_UPPER|PY_CTF_XDIGIT, /* 0x46 'F' */
PY_CTF_UPPER, /* 0x47 'G' */
PY_CTF_UPPER, /* 0x48 'H' */
PY_CTF_UPPER, /* 0x49 'I' */
PY_CTF_UPPER, /* 0x4a 'J' */
PY_CTF_UPPER, /* 0x4b 'K' */
PY_CTF_UPPER, /* 0x4c 'L' */
PY_CTF_UPPER, /* 0x4d 'M' */
PY_CTF_UPPER, /* 0x4e 'N' */
PY_CTF_UPPER, /* 0x4f 'O' */
PY_CTF_UPPER, /* 0x50 'P' */
PY_CTF_UPPER, /* 0x51 'Q' */
PY_CTF_UPPER, /* 0x52 'R' */
PY_CTF_UPPER, /* 0x53 'S' */
PY_CTF_UPPER, /* 0x54 'T' */
PY_CTF_UPPER, /* 0x55 'U' */
PY_CTF_UPPER, /* 0x56 'V' */
PY_CTF_UPPER, /* 0x57 'W' */
PY_CTF_UPPER, /* 0x58 'X' */
PY_CTF_UPPER, /* 0x59 'Y' */
PY_CTF_UPPER, /* 0x5a 'Z' */
0, /* 0x5b '[' */
0, /* 0x5c '\\' */
0, /* 0x5d ']' */
0, /* 0x5e '^' */
0, /* 0x5f '_' */
0, /* 0x60 '`' */
PY_CTF_LOWER|PY_CTF_XDIGIT, /* 0x61 'a' */
PY_CTF_LOWER|PY_CTF_XDIGIT, /* 0x62 'b' */
PY_CTF_LOWER|PY_CTF_XDIGIT, /* 0x63 'c' */
PY_CTF_LOWER|PY_CTF_XDIGIT, /* 0x64 'd' */
PY_CTF_LOWER|PY_CTF_XDIGIT, /* 0x65 'e' */
PY_CTF_LOWER|PY_CTF_XDIGIT, /* 0x66 'f' */
PY_CTF_LOWER, /* 0x67 'g' */
PY_CTF_LOWER, /* 0x68 'h' */
PY_CTF_LOWER, /* 0x69 'i' */
PY_CTF_LOWER, /* 0x6a 'j' */
PY_CTF_LOWER, /* 0x6b 'k' */
PY_CTF_LOWER, /* 0x6c 'l' */
PY_CTF_LOWER, /* 0x6d 'm' */
PY_CTF_LOWER, /* 0x6e 'n' */
PY_CTF_LOWER, /* 0x6f 'o' */
PY_CTF_LOWER, /* 0x70 'p' */
PY_CTF_LOWER, /* 0x71 'q' */
PY_CTF_LOWER, /* 0x72 'r' */
PY_CTF_LOWER, /* 0x73 's' */
PY_CTF_LOWER, /* 0x74 't' */
PY_CTF_LOWER, /* 0x75 'u' */
PY_CTF_LOWER, /* 0x76 'v' */
PY_CTF_LOWER, /* 0x77 'w' */
PY_CTF_LOWER, /* 0x78 'x' */
PY_CTF_LOWER, /* 0x79 'y' */
PY_CTF_LOWER, /* 0x7a 'z' */
0, /* 0x7b '{' */
0, /* 0x7c '|' */
0, /* 0x7d '}' */
0, /* 0x7e '~' */
0, /* 0x7f '\x7f' */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
const unsigned char _Py_ctype_tolower[256] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
};
const unsigned char _Py_ctype_toupper[256] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
};

View file

@ -1,13 +1,10 @@
#include "third_party/python/Include/pyhash.h"
/* clang-format off */
/* Set of hash utility functions to help maintaining the invariant that
if a==b then hash(a)==hash(b)
All the utility functions (_Py_Hash*()) return "-1" to signify an error.
*/
#include "third_party/python/Include/Python.h"
#ifdef __cplusplus
extern "C" {
#endif
_Py_HashSecret_t _Py_HashSecret;
@ -410,7 +407,3 @@ siphash24(const void *src, Py_ssize_t src_sz) {
static PyHash_FuncDef PyHash_Func = {siphash24, "siphash24", 64, 128};
#endif /* Py_HASH_ALGORITHM == Py_HASH_SIPHASH24 */
#ifdef __cplusplus
}
#endif

View file

@ -1,20 +1,53 @@
/* clang-format off */
/* Python interpreter top-level routines, including init/exit */
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/Python-ast.h"
#undef Yield /* undefine macro conflicting with winbase.h */
#include "third_party/python/Include/grammar.h"
#include "third_party/python/Include/node.h"
#include "third_party/python/Include/token.h"
#include "third_party/python/Include/parsetok.h"
#include "third_party/python/Include/errcode.h"
#include "third_party/python/Include/code.h"
#include "third_party/python/Include/symtable.h"
#include "third_party/python/Include/ast.h"
#include "third_party/python/Include/marshal.h"
#include "third_party/python/Include/osdefs.h"
#include "libc/unicode/locale.h"
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8 -*-│
vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi
Python 3
https://docs.python.org/3/license.html │
*/
#include "libc/assert.h"
#include "libc/calls/calls.h"
#include "libc/calls/internal.h"
#include "libc/calls/sigbits.h"
#include "libc/dce.h"
#include "libc/fmt/conv.h"
#include "libc/log/check.h"
#include "libc/log/log.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
#include "libc/unicode/locale.h"
#include "third_party/python/Include/Python-ast.h"
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/ast.h"
#include "third_party/python/Include/boolobject.h"
#include "third_party/python/Include/code.h"
#include "third_party/python/Include/codecs.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/errcode.h"
#include "third_party/python/Include/fileobject.h"
#include "third_party/python/Include/grammar.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/intrcheck.h"
#include "third_party/python/Include/marshal.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/node.h"
#include "third_party/python/Include/objimpl.h"
#include "third_party/python/Include/osdefs.h"
#include "third_party/python/Include/parsetok.h"
#include "third_party/python/Include/pydebug.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pylifecycle.h"
#include "third_party/python/Include/pymem.h"
#include "third_party/python/Include/pystrcmp.h"
#include "third_party/python/Include/pytime.h"
#include "third_party/python/Include/symtable.h"
#include "third_party/python/Include/sysmodule.h"
#include "third_party/python/Include/token.h"
#include "third_party/python/Include/traceback.h"
#include "third_party/python/Include/unicodeobject.h"
#include "third_party/python/Include/warnings.h"
/* clang-format off */
/* Python interpreter top-level routines, including init/exit */
_Py_IDENTIFIER(flush);
_Py_IDENTIFIER(name);
@ -22,8 +55,6 @@ _Py_IDENTIFIER(stdin);
_Py_IDENTIFIER(stdout);
_Py_IDENTIFIER(stderr);
extern wchar_t *Py_GetPath(void);
extern grammar _PyParser_Grammar; /* From graminit.c */
/* Forward */
@ -212,7 +243,7 @@ get_locale_encoding(void)
return NULL;
}
return get_codec_name(codeset);
#elif 1 || defined(__ANDROID__)
#elif defined(__ANDROID__) || defined(__COSMOPOLITAN__)
return get_codec_name("UTF-8");
#else
PyErr_SetNone(PyExc_NotImplementedError);
@ -422,9 +453,10 @@ _Py_InitializeEx_Private(int install_sigs, int install_importlib)
Py_FatalError("Py_Initialize: can't initialize tracemalloc");
initmain(interp); /* Module __main__ */
if (initstdio() < 0)
if (initstdio() < 0) {
Py_FatalError(
"Py_Initialize: can't initialize sys standard streams");
}
/* Initialize warnings. */
if (PySys_HasWarnOptions()) {
@ -976,7 +1008,6 @@ initfsencoding(PyInterpreterState *interp)
Py_FileSystemDefaultEncoding = get_locale_encoding();
if (Py_FileSystemDefaultEncoding == NULL)
Py_FatalError("Py_Initialize: Unable to get the locale encoding");
Py_HasFileSystemDefaultEncoding = 0;
interp->fscodec_initialized = 1;
return 0;
@ -1019,14 +1050,17 @@ initsite(void)
static int
is_valid_fd(int fd)
{
#ifdef __APPLE__
/* bpo-30225: On macOS Tiger, when stdout is redirected to a pipe
and the other side of the pipe is closed, dup(1) succeed, whereas
fstat(1, &st) fails with EBADF. Prefer fstat() over dup() to detect
such error. */
struct stat st;
return (fstat(fd, &st) == 0);
#else
if (IsWindows()) {
return __isfdopen(fd);
}
if (IsXnu()) {
/* bpo-30225: On macOS Tiger, when stdout is redirected to a pipe
and the other side of the pipe is closed, dup(1) succeed, whereas
fstat(1, &st) fails with EBADF. Prefer fstat() over dup() to detect
such error. */
struct stat st;
return (fstat(fd, &st) == 0);
}
int fd2;
if (fd < 0)
return 0;
@ -1039,7 +1073,6 @@ is_valid_fd(int fd)
close(fd2);
_Py_END_SUPPRESS_IPH
return fd2 >= 0;
#endif
}
/* returns Py_None if the fd is not valid */
@ -1454,7 +1487,7 @@ exit:
#if defined(MS_WINDOWS) && defined(_DEBUG)
DebugBreak();
#endif
abort();
__die();
}
/* Clean up and exit */

View file

@ -1,5 +1,5 @@
#include "third_party/python/pyconfig.h"
/* clang-format off */
#include "third_party/python/Include/Python.h"
#ifdef X87_DOUBLE_ROUNDING
/* On x86 platforms using an x87 FPU, this function is called from the
@ -28,4 +28,6 @@ unsigned short _Py_get_387controlword(void) {
void _Py_set_387controlword(unsigned short cw) {
__asm__ __volatile__ ("fldcw %0" : : "m" (cw));
}
#else
#error wut
#endif

View file

@ -1,7 +1,16 @@
#include "libc/bits/pushpop.h"
#include "libc/runtime/dlfcn.h"
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/ceval.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/listobject.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/pyatomic.h"
#include "third_party/python/Include/pydebug.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pymem.h"
#include "third_party/python/Include/pystate.h"
/* clang-format off */
/* Thread and interpreter state structures and their interfaces */
#define ZERO(x) x = (typeof(x))pushpop(0L)

View file

@ -1,28 +1,27 @@
#include "third_party/python/Include/object.h"
#include "third_party/python/Include/pyctype.h"
/* clang-format off */
/* Cross platform case insensitive string compare functions
*/
#include "third_party/python/Include/Python.h"
int
PyOS_mystrnicmp(const char *s1, const char *s2, Py_ssize_t size)
{
if (size == 0)
return 0;
while ((--size > 0) &&
(tolower((unsigned)*s1) == tolower((unsigned)*s2))) {
(Py_TOLOWER(*s1) == Py_TOLOWER(*s2))) {
if (!*s1++ || !*s2++)
break;
}
return tolower((unsigned)*s1) - tolower((unsigned)*s2);
return Py_TOLOWER(*s1) - Py_TOLOWER(*s2);
}
int
PyOS_mystricmp(const char *s1, const char *s2)
{
while (*s1 && (tolower((unsigned)*s1++) == tolower((unsigned)*s2++))) {
;
while (*s1 && (Py_TOLOWER((unsigned)*s1++) == Py_TOLOWER((unsigned)*s2++))) {
}
return (tolower((unsigned)*s1) - tolower((unsigned)*s2));
return (Py_TOLOWER((unsigned)*s1) - Py_TOLOWER((unsigned)*s2));
}

View file

@ -1,6 +1,13 @@
#include "libc/assert.h"
#include "third_party/python/Include/bytesobject.h"
#include "third_party/python/Include/codecs.h"
#include "third_party/python/Include/object.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pymem.h"
#include "third_party/python/Include/unicodeobject.h"
/* clang-format off */
/* bytes to hex implementation */
#include "third_party/python/Include/Python.h"
static PyObject *_Py_strhex_impl(const char* argbuf, const Py_ssize_t arglen,
int return_bytes)
@ -48,14 +55,14 @@ static PyObject *_Py_strhex_impl(const char* argbuf, const Py_ssize_t arglen,
return retval;
}
PyAPI_FUNC(PyObject *) _Py_strhex(const char* argbuf, const Py_ssize_t arglen)
PyObject * _Py_strhex(const char* argbuf, const Py_ssize_t arglen)
{
return _Py_strhex_impl(argbuf, arglen, 0);
}
/* Same as above but returns a bytes() instead of str() to avoid the
* need to decode the str() when bytes are needed. */
PyAPI_FUNC(PyObject *) _Py_strhex_bytes(const char* argbuf, const Py_ssize_t arglen)
PyObject * _Py_strhex_bytes(const char* argbuf, const Py_ssize_t arglen)
{
return _Py_strhex_impl(argbuf, arglen, 1);
}

View file

@ -1,7 +1,16 @@
/* clang-format off */
/* -*- Mode: C; c-file-style: "python" -*- */
#include "third_party/python/Include/Python.h"
#include "libc/assert.h"
#include "libc/errno.h"
#include "libc/fmt/fmt.h"
#include "libc/unicode/locale.h"
#include "third_party/python/Include/dtoa.h"
#include "third_party/python/Include/object.h"
#include "third_party/python/Include/pyctype.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pyfpe.h"
#include "third_party/python/Include/pymem.h"
#include "third_party/python/Include/pyport.h"
#include "third_party/python/Include/pystrtod.h"
/* clang-format off */
/* Case-insensitive string match used for nan and inf detection; t should be
lower-case. Returns 1 for a successful match, 0 otherwise. */
@ -793,7 +802,7 @@ _PyOS_ascii_formatd(char *buffer,
/* The fallback code to use if _Py_dg_dtoa is not available. */
PyAPI_FUNC(char *) PyOS_double_to_string(double val,
char * PyOS_double_to_string(double val,
char format_code,
int precision,
int flags,
@ -1240,7 +1249,7 @@ format_float_short(double d, char format_code,
}
PyAPI_FUNC(char *) PyOS_double_to_string(double val,
char * PyOS_double_to_string(double val,
char format_code,
int precision,
int flags,

View file

@ -1,19 +1,34 @@
/* clang-format off */
/* Python interpreter top-level routines, including init/exit */
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/Python-ast.h"
#undef Yield /* undefine macro conflicting with winbase.h */
#include "third_party/python/Include/grammar.h"
#include "third_party/python/Include/node.h"
#include "third_party/python/Include/token.h"
#include "third_party/python/Include/parsetok.h"
#include "third_party/python/Include/errcode.h"
#include "third_party/python/Include/code.h"
#include "third_party/python/Include/symtable.h"
#include "third_party/python/Include/ast.h"
#include "third_party/python/Include/marshal.h"
#include "third_party/python/Include/osdefs.h"
#include "libc/unicode/locale.h"
#include "third_party/python/Include/Python-ast.h"
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/ast.h"
#include "third_party/python/Include/code.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/errcode.h"
#include "third_party/python/Include/eval.h"
#include "third_party/python/Include/fileobject.h"
#include "third_party/python/Include/fileutils.h"
#include "third_party/python/Include/grammar.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/marshal.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/node.h"
#include "third_party/python/Include/objimpl.h"
#include "third_party/python/Include/osdefs.h"
#include "third_party/python/Include/parsetok.h"
#include "third_party/python/Include/pydebug.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pylifecycle.h"
#include "third_party/python/Include/setobject.h"
#include "third_party/python/Include/symtable.h"
#include "third_party/python/Include/sysmodule.h"
#include "third_party/python/Include/token.h"
#include "third_party/python/Include/traceback.h"
#include "third_party/python/Include/unicodeobject.h"
/* clang-format off */
/* Python interpreter top-level routines, including init/exit */
_Py_IDENTIFIER(builtins);
_Py_IDENTIFIER(excepthook);
@ -1459,56 +1474,56 @@ PyOS_CheckStack(void)
/* Deprecated C API functions still provided for binary compatibility */
#undef PyParser_SimpleParseFile
PyAPI_FUNC(node *)
node *
PyParser_SimpleParseFile(FILE *fp, const char *filename, int start)
{
return PyParser_SimpleParseFileFlags(fp, filename, start, 0);
}
#undef PyParser_SimpleParseString
PyAPI_FUNC(node *)
node *
PyParser_SimpleParseString(const char *str, int start)
{
return PyParser_SimpleParseStringFlags(str, start, 0);
}
#undef PyRun_AnyFile
PyAPI_FUNC(int)
int
PyRun_AnyFile(FILE *fp, const char *name)
{
return PyRun_AnyFileExFlags(fp, name, 0, NULL);
}
#undef PyRun_AnyFileEx
PyAPI_FUNC(int)
int
PyRun_AnyFileEx(FILE *fp, const char *name, int closeit)
{
return PyRun_AnyFileExFlags(fp, name, closeit, NULL);
}
#undef PyRun_AnyFileFlags
PyAPI_FUNC(int)
int
PyRun_AnyFileFlags(FILE *fp, const char *name, PyCompilerFlags *flags)
{
return PyRun_AnyFileExFlags(fp, name, 0, flags);
}
#undef PyRun_File
PyAPI_FUNC(PyObject *)
PyObject *
PyRun_File(FILE *fp, const char *p, int s, PyObject *g, PyObject *l)
{
return PyRun_FileExFlags(fp, p, s, g, l, 0, NULL);
}
#undef PyRun_FileEx
PyAPI_FUNC(PyObject *)
PyObject *
PyRun_FileEx(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, int c)
{
return PyRun_FileExFlags(fp, p, s, g, l, c, NULL);
}
#undef PyRun_FileFlags
PyAPI_FUNC(PyObject *)
PyObject *
PyRun_FileFlags(FILE *fp, const char *p, int s, PyObject *g, PyObject *l,
PyCompilerFlags *flags)
{
@ -1516,14 +1531,14 @@ PyRun_FileFlags(FILE *fp, const char *p, int s, PyObject *g, PyObject *l,
}
#undef PyRun_SimpleFile
PyAPI_FUNC(int)
int
PyRun_SimpleFile(FILE *f, const char *p)
{
return PyRun_SimpleFileExFlags(f, p, 0, NULL);
}
#undef PyRun_SimpleFileEx
PyAPI_FUNC(int)
int
PyRun_SimpleFileEx(FILE *f, const char *p, int c)
{
return PyRun_SimpleFileExFlags(f, p, c, NULL);
@ -1531,28 +1546,28 @@ PyRun_SimpleFileEx(FILE *f, const char *p, int c)
#undef PyRun_String
PyAPI_FUNC(PyObject *)
PyObject *
PyRun_String(const char *str, int s, PyObject *g, PyObject *l)
{
return PyRun_StringFlags(str, s, g, l, NULL);
}
#undef PyRun_SimpleString
PyAPI_FUNC(int)
int
PyRun_SimpleString(const char *s)
{
return PyRun_SimpleStringFlags(s, NULL);
}
#undef Py_CompileString
PyAPI_FUNC(PyObject *)
PyObject *
Py_CompileString(const char *str, const char *p, int s)
{
return Py_CompileStringExFlags(str, p, s, NULL, -1);
}
#undef Py_CompileStringFlags
PyAPI_FUNC(PyObject *)
PyObject *
Py_CompileStringFlags(const char *str, const char *p, int s,
PyCompilerFlags *flags)
{
@ -1560,14 +1575,14 @@ Py_CompileStringFlags(const char *str, const char *p, int s,
}
#undef PyRun_InteractiveOne
PyAPI_FUNC(int)
int
PyRun_InteractiveOne(FILE *f, const char *p)
{
return PyRun_InteractiveOneFlags(f, p, NULL);
}
#undef PyRun_InteractiveLoop
PyAPI_FUNC(int)
int
PyRun_InteractiveLoop(FILE *f, const char *p)
{
return PyRun_InteractiveLoopFlags(f, p, NULL);

View file

@ -1,5 +1,15 @@
#include "libc/calls/weirdtypes.h"
#include "libc/math.h"
#include "libc/sysv/consts/clock.h"
#include "libc/time/time.h"
#include "third_party/python/Include/floatobject.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/object.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pymacro.h"
#include "third_party/python/Include/pymath.h"
#include "third_party/python/Include/pytime.h"
/* clang-format off */
#include "third_party/python/Include/Python.h"
#define _PyTime_check_mul_overflow(a, b) \
(assert(b > 0), \

View file

@ -1,6 +1,19 @@
/* clang-format off */
#include "libc/calls/calls.h"
#include "libc/calls/weirdtypes.h"
#include "libc/errno.h"
#include "libc/fmt/conv.h"
#include "libc/rand/rand.h"
#include "libc/sysv/consts/grnd.h"
#include "third_party/python/Include/Python.h"
#include "libc/sysv/consts/o.h"
#include "third_party/python/Include/ceval.h"
#include "third_party/python/Include/fileutils.h"
#include "third_party/python/Include/object.h"
#include "third_party/python/Include/pydebug.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pyhash.h"
#include "third_party/python/Include/pymacro.h"
#include "third_party/python/pyconfig.h"
/* clang-format off */
#ifdef Py_DEBUG
int _Py_HashSecret_Initialized = 0;
@ -8,7 +21,6 @@ int _Py_HashSecret_Initialized = 0;
static int _Py_HashSecret_Initialized = 0;
#endif
#if defined(HAVE_GETRANDOM) || defined(HAVE_GETRANDOM_SYSCALL)
#define PY_GETRANDOM 1
/* Call getrandom() to get random bytes:
@ -41,17 +53,9 @@ py_getrandom(void *buffer, Py_ssize_t size, int blocking, int raise)
flags = blocking ? 0 : GRND_NONBLOCK;
dest = buffer;
while (0 < size) {
#ifdef sun
/* Issue #26735: On Solaris, getrandom() is limited to returning up
to 1024 bytes. Call it multiple times if more bytes are
requested. */
n = Py_MIN(size, 1024);
#else
n = Py_MIN(size, LONG_MAX);
#endif
n = Py_MIN(size, 256);
errno = 0;
#ifdef HAVE_GETRANDOM
if (raise) {
Py_BEGIN_ALLOW_THREADS
n = getrandom(dest, n, flags);
@ -60,24 +64,6 @@ py_getrandom(void *buffer, Py_ssize_t size, int blocking, int raise)
else {
n = getrandom(dest, n, flags);
}
#else
/* On Linux, use the syscall() function because the GNU libc doesn't
expose the Linux getrandom() syscall yet. See:
https://sourceware.org/bugzilla/show_bug.cgi?id=17252 */
if (raise) {
Py_BEGIN_ALLOW_THREADS
n = syscall(SYS_getrandom, dest, n, flags);
Py_END_ALLOW_THREADS
}
else {
n = syscall(SYS_getrandom, dest, n, flags);
}
# ifdef _Py_MEMORY_SANITIZER
if (n > 0) {
__msan_unpoison(dest, n);
}
# endif
#endif
if (n < 0) {
/* ENOSYS: the syscall is not supported by the kernel.
@ -259,7 +245,6 @@ dev_urandom_close(void)
urandom_cache.fd = -1;
}
}
#endif /* !MS_WINDOWS */
/* Fill buffer with pseudo-random bytes generated by a linear congruent
@ -422,7 +407,7 @@ _PyRandom_Init(void)
}
if (seed == 0) {
/* disable the randomized hash */
memset(secret, 0, secret_size);
bzero(secret, secret_size);
Py_HashRandomizationFlag = 0;
}
else {

View file

@ -1,4 +1,5 @@
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/intrcheck.h"
#include "third_party/python/Include/pyerrors.h"
/* clang-format off */
/* Sigcheck is similar to intrcheck() but sets an exception when an

View file

@ -1,5 +1,10 @@
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/boolobject.h"
#include "third_party/python/Include/floatobject.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/object.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/structmember.h"
#include "third_party/python/Include/warnings.h"
/* clang-format off */
/* Map C struct members to Python object attributes */

View file

@ -1,7 +1,14 @@
#include "third_party/python/Include/Python.h"
/**/
#include "third_party/python/Include/Python-ast.h"
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/ceval.h"
#include "third_party/python/Include/code.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/listobject.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/objimpl.h"
#include "third_party/python/Include/pymem.h"
#include "third_party/python/Include/setobject.h"
#include "third_party/python/Include/structmember.h"
#include "third_party/python/Include/symtable.h"
/* clang-format off */

View file

@ -1,26 +1,41 @@
/* clang-format off */
/* System module */
/*
Various bits of information used by the interpreter are collected in
module 'sys'.
Function member:
- exit(sts): raise SystemExit
Data members:
- stdin, stdout, stderr: standard file objects
- modules: the table of modules (dictionary)
- path: module search path (list of strings)
- argv: script arguments (list of strings)
- ps1, ps2: optional primary and secondary prompts (strings)
*/
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/code.h"
#include "third_party/python/Include/frameobject.h"
#include "third_party/python/Include/pythread.h"
#include "third_party/python/Include/osdefs.h"
#include "libc/calls/calls.h"
#include "libc/dce.h"
#include "libc/runtime/runtime.h"
#include "libc/sysv/consts/exit.h"
#include "libc/unicode/locale.h"
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/boolobject.h"
#include "third_party/python/Include/ceval.h"
#include "third_party/python/Include/code.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/eval.h"
#include "third_party/python/Include/fileobject.h"
#include "third_party/python/Include/fileutils.h"
#include "third_party/python/Include/floatobject.h"
#include "third_party/python/Include/frameobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/listobject.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/namespaceobject.h"
#include "third_party/python/Include/objimpl.h"
#include "third_party/python/Include/osdefs.h"
#include "third_party/python/Include/patchlevel.h"
#include "third_party/python/Include/pgenheaders.h"
#include "third_party/python/Include/pydebug.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pyhash.h"
#include "third_party/python/Include/pylifecycle.h"
#include "third_party/python/Include/pymacro.h"
#include "third_party/python/Include/pyport.h"
#include "third_party/python/Include/pythonrun.h"
#include "third_party/python/Include/pythread.h"
#include "third_party/python/Include/structseq.h"
#include "third_party/python/Include/traceback.h"
#include "third_party/python/Include/unicodeobject.h"
#include "third_party/python/Include/warnings.h"
#include "third_party/python/pyconfig.h"
/* clang-format off */
_Py_IDENTIFIER(_);
_Py_IDENTIFIER(__sizeof__);
@ -2231,7 +2246,7 @@ sys_update_path(int argc, wchar_t **argv)
if (p != NULL) {
n = p + 1 - argv0;
#if SEP == '/' /* Special case for Unix filename syntax */
if (n > 1)
if (n > 1 && (!IsWindows() || p[-1] != ':'))
n--; /* Drop trailing separator */
#endif /* Unix */
}

View file

@ -1,13 +1,17 @@
#include "libc/assert.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pymacro.h"
#include "third_party/python/Include/pymem.h"
#include "third_party/python/Include/pythread.h"
#include "third_party/python/Include/structseq.h"
/* clang-format off */
/* Thread package.
This is intended to be usable independently from Python.
The implementation for system foobar is in a file thread_foobar.h
The implementation for system foobar is in a file thread_foobar.inc
which is included by this file dependent on config settings.
Stuff shared by all thread_*.h files is collected here. */
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/pythread.h"
#ifndef _POSIX_THREADS
/* Check if we're running on HP-UX and _SC_THREADS is defined. If so, then
@ -67,18 +71,18 @@ static size_t _pythread_stacksize = 0;
#ifdef _POSIX_THREADS
#define PYTHREAD_NAME "pthread"
#include "thread_pthread.h"
#include "thread_pthread.inc"
#endif
#ifdef NT_THREADS
#define PYTHREAD_NAME "nt"
#include "thread_nt.h"
#include "thread_nt.inc"
#endif
/*
#ifdef FOOBAR_THREADS
#include "thread_foobar.h"
#include "thread_foobar.inc"
#endif
*/

View file

@ -1,3 +1,6 @@
#include "libc/calls/calls.h"
/* clang-format off */
/*
* Initialization.
*/

View file

@ -16,7 +16,7 @@
#if _PY_USE_CV_LOCKS
#include "third_party/python/Include/condvar.h"
#include "third_party/python/Python/condvar.h"
typedef struct _NRMUTEX
{

View file

@ -1,8 +1,23 @@
#include "third_party/python/Include/Python.h"
#include "libc/calls/calls.h"
#include "libc/calls/weirdtypes.h"
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/bytesobject.h"
#include "third_party/python/Include/code.h"
#include "third_party/python/Include/codecs.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/fileobject.h"
#include "third_party/python/Include/fileutils.h"
#include "third_party/python/Include/frameobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/listobject.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/objimpl.h"
#include "third_party/python/Include/osdefs.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/structmember.h"
#include "third_party/python/Include/sysmodule.h"
#include "third_party/python/Include/traceback.h"
/* clang-format off */
#define OFF(x) offsetof(PyTracebackObject, x)

View file

@ -1,3 +1,6 @@
#include "third_party/python/Include/code.h"
/* clang-format off */
/* This file contains code shared by the compiler and the peephole
optimizer.
*/