mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Implement tree-shaking for Python sources
This commit is contained in:
parent
81287b7ec0
commit
44c87b83ff
110 changed files with 899 additions and 1922 deletions
22
third_party/python/Objects/fileobject.c
vendored
22
third_party/python/Objects/fileobject.c
vendored
|
@ -23,6 +23,7 @@
|
|||
#include "third_party/python/Include/pyerrors.h"
|
||||
#include "third_party/python/Include/tupleobject.h"
|
||||
#include "third_party/python/Include/unicodeobject.h"
|
||||
#include "third_party/python/Include/yoink.h"
|
||||
/* clang-format off */
|
||||
|
||||
/* File object implementation (what's left of it -- see io.py) */
|
||||
|
@ -46,27 +47,6 @@
|
|||
|
||||
/* External C interface */
|
||||
|
||||
PyObject *
|
||||
PyFile_FromFd(int fd, const char *name, const char *mode, int buffering, const char *encoding,
|
||||
const char *errors, const char *newline, int closefd)
|
||||
{
|
||||
PyObject *io, *stream;
|
||||
_Py_IDENTIFIER(open);
|
||||
|
||||
io = PyImport_ImportModule("io");
|
||||
if (io == NULL)
|
||||
return NULL;
|
||||
stream = _PyObject_CallMethodId(io, &PyId_open, "isisssi", fd, mode,
|
||||
buffering, encoding, errors,
|
||||
newline, closefd);
|
||||
Py_DECREF(io);
|
||||
if (stream == NULL)
|
||||
return NULL;
|
||||
/* ignore name attribute because the name attribute of _BufferedIOMixin
|
||||
and TextIOWrapper is read only */
|
||||
return stream;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
PyFile_GetLine(PyObject *f, int n)
|
||||
{
|
||||
|
|
34
third_party/python/Objects/fromfd.c
vendored
Normal file
34
third_party/python/Objects/fromfd.c
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=4 sts=4 sw=4 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Python 3 │
|
||||
│ https://docs.python.org/3/license.html │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "third_party/python/Include/abstract.h"
|
||||
#include "third_party/python/Include/import.h"
|
||||
#include "third_party/python/Include/object.h"
|
||||
#include "third_party/python/Include/yoink.h"
|
||||
/* clang-format off */
|
||||
|
||||
PYTHON_YOINK("io");
|
||||
|
||||
PyObject *
|
||||
PyFile_FromFd(int fd, const char *name, const char *mode, int buffering,
|
||||
const char *encoding, const char *errors, const char *newline,
|
||||
int closefd)
|
||||
{
|
||||
PyObject *io, *stream;
|
||||
_Py_IDENTIFIER(open);
|
||||
io = PyImport_ImportModule("io");
|
||||
if (io == NULL)
|
||||
return NULL;
|
||||
stream = _PyObject_CallMethodId(io, &PyId_open, "isisssi", fd, mode,
|
||||
buffering, encoding, errors,
|
||||
newline, closefd);
|
||||
Py_DECREF(io);
|
||||
if (stream == NULL)
|
||||
return NULL;
|
||||
/* ignore name attribute because the name attribute of _BufferedIOMixin
|
||||
and TextIOWrapper is read only */
|
||||
return stream;
|
||||
}
|
1
third_party/python/Objects/memoryobject.c
vendored
1
third_party/python/Objects/memoryobject.c
vendored
|
@ -21,6 +21,7 @@
|
|||
#include "third_party/python/Include/pymacro.h"
|
||||
#include "third_party/python/Include/pystrhex.h"
|
||||
#include "third_party/python/Include/sliceobject.h"
|
||||
#include "third_party/python/Include/yoink.h"
|
||||
/* clang-format off */
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
13
third_party/python/Objects/unicodeobject.c
vendored
13
third_party/python/Objects/unicodeobject.c
vendored
|
@ -38,9 +38,12 @@
|
|||
#include "third_party/python/Include/ucnhash.h"
|
||||
#include "third_party/python/Include/unicodeobject.h"
|
||||
#include "third_party/python/Include/warnings.h"
|
||||
#include "third_party/python/Include/yoink.h"
|
||||
#include "third_party/python/Objects/stringlib/eq.inc"
|
||||
/* clang-format off */
|
||||
|
||||
PYTHON_PROVIDE("_string");
|
||||
|
||||
/*
|
||||
|
||||
Unicode implementation based on original code by Fredrik Lundh,
|
||||
|
@ -94,11 +97,6 @@ NOTE: In the interpreter's initialization phase, some globals are currently
|
|||
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Maximum code point of Unicode 6.0: 0x10ffff (1,114,111) */
|
||||
#define MAX_UNICODE 0x10ffff
|
||||
|
||||
|
@ -15760,8 +15758,3 @@ PyInit__string(void)
|
|||
{
|
||||
return PyModule_Create(&_string_module);
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue