mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-19 09:00:31 +00:00
Get more Python tests passing (#141)
This commit is contained in:
parent
916f19eea1
commit
59e1c245d1
141 changed files with 3536 additions and 1203 deletions
98
third_party/linenoise/linenoise.c
vendored
98
third_party/linenoise/linenoise.c
vendored
|
@ -190,8 +190,11 @@
|
|||
#include "third_party/linenoise/linenoise.h"
|
||||
/* clang-format off */
|
||||
|
||||
#define LINENOISE_DEFAULT_HISTORY_MAX_LEN 100
|
||||
#define LINENOISE_MAX_LINE 4096
|
||||
#define LINENOISE_DEFAULT_HISTORY_MAX_LEN 100
|
||||
#define LINENOISE_HISTORY_NEXT 0
|
||||
#define LINENOISE_HISTORY_PREV 1
|
||||
|
||||
static char *unsupported_term[] = {"dumb","cons25","emacs",NULL};
|
||||
static linenoiseCompletionCallback *completionCallback = NULL;
|
||||
static linenoiseHintsCallback *hintsCallback = NULL;
|
||||
|
@ -520,7 +523,7 @@ static void abFree(struct abuf *ab) {
|
|||
|
||||
/* Helper of refreshSingleLine() and refreshMultiLine() to show hints
|
||||
* to the right of the prompt. */
|
||||
void refreshShowHints(struct abuf *ab, struct linenoiseState *l, int plen) {
|
||||
static void refreshShowHints(struct abuf *ab, struct linenoiseState *l, int plen) {
|
||||
char seq[64];
|
||||
if (hintsCallback && plen+l->len < l->cols) {
|
||||
int color = -1, bold = 0;
|
||||
|
@ -679,7 +682,7 @@ static void refreshLine(struct linenoiseState *l) {
|
|||
/* Insert the character 'c' at cursor current position.
|
||||
*
|
||||
* On error writing to the terminal -1 is returned, otherwise 0. */
|
||||
int linenoiseEditInsert(struct linenoiseState *l, char c) {
|
||||
static int linenoiseEditInsert(struct linenoiseState *l, char c) {
|
||||
if (l->len < l->buflen) {
|
||||
if (l->len == l->pos) {
|
||||
l->buf[l->pos] = c;
|
||||
|
@ -707,37 +710,37 @@ int linenoiseEditInsert(struct linenoiseState *l, char c) {
|
|||
}
|
||||
|
||||
/* Move cursor on the left. */
|
||||
void linenoiseEditMoveLeft(struct linenoiseState *l) {
|
||||
static void linenoiseEditMoveLeft(struct linenoiseState *l) {
|
||||
if (l->pos > 0) {
|
||||
l->pos--;
|
||||
refreshLine(l);
|
||||
}
|
||||
}
|
||||
|
||||
static bool IsSeparator(int c) {
|
||||
return !(isalnum(c) || c >= 128);
|
||||
}
|
||||
|
||||
/* Move cursor on the left. */
|
||||
void linenoiseEditMoveLeftWord(struct linenoiseState *l) {
|
||||
static void linenoiseEditMoveLeftWord(struct linenoiseState *l) {
|
||||
if (l->pos > 0) {
|
||||
while (l->pos > 0 && l->buf[l->pos-1] == ' ')
|
||||
l->pos--;
|
||||
while (l->pos > 0 && l->buf[l->pos-1] != ' ')
|
||||
l->pos--;
|
||||
while (l->pos > 0 && IsSeparator(l->buf[l->pos-1])) l->pos--;
|
||||
while (l->pos > 0 && !IsSeparator(l->buf[l->pos-1])) l->pos--;
|
||||
refreshLine(l);
|
||||
}
|
||||
}
|
||||
|
||||
/* Move cursor on the right. */
|
||||
void linenoiseEditMoveRightWord(struct linenoiseState *l) {
|
||||
static void linenoiseEditMoveRightWord(struct linenoiseState *l) {
|
||||
if (l->pos != l->len) {
|
||||
while (l->pos < l->len && l->buf[l->pos] == ' ')
|
||||
l->pos++;
|
||||
while (l->pos < l->len && l->buf[l->pos] != ' ')
|
||||
l->pos++;
|
||||
while (l->pos < l->len && IsSeparator(l->buf[l->pos])) l->pos++;
|
||||
while (l->pos < l->len && !IsSeparator(l->buf[l->pos])) l->pos++;
|
||||
refreshLine(l);
|
||||
}
|
||||
}
|
||||
|
||||
/* Move cursor on the right. */
|
||||
void linenoiseEditMoveRight(struct linenoiseState *l) {
|
||||
static void linenoiseEditMoveRight(struct linenoiseState *l) {
|
||||
if (l->pos != l->len) {
|
||||
l->pos++;
|
||||
refreshLine(l);
|
||||
|
@ -745,7 +748,7 @@ void linenoiseEditMoveRight(struct linenoiseState *l) {
|
|||
}
|
||||
|
||||
/* Move cursor to the start of the line. */
|
||||
void linenoiseEditMoveHome(struct linenoiseState *l) {
|
||||
static void linenoiseEditMoveHome(struct linenoiseState *l) {
|
||||
if (l->pos != 0) {
|
||||
l->pos = 0;
|
||||
refreshLine(l);
|
||||
|
@ -753,7 +756,7 @@ void linenoiseEditMoveHome(struct linenoiseState *l) {
|
|||
}
|
||||
|
||||
/* Move cursor to the end of the line. */
|
||||
void linenoiseEditMoveEnd(struct linenoiseState *l) {
|
||||
static void linenoiseEditMoveEnd(struct linenoiseState *l) {
|
||||
if (l->pos != l->len) {
|
||||
l->pos = l->len;
|
||||
refreshLine(l);
|
||||
|
@ -762,9 +765,7 @@ void linenoiseEditMoveEnd(struct linenoiseState *l) {
|
|||
|
||||
/* Substitute the currently edited line with the next or previous history
|
||||
* entry as specified by 'dir'. */
|
||||
#define LINENOISE_HISTORY_NEXT 0
|
||||
#define LINENOISE_HISTORY_PREV 1
|
||||
void linenoiseEditHistoryNext(struct linenoiseState *l, int dir) {
|
||||
static void linenoiseEditHistoryNext(struct linenoiseState *l, int dir) {
|
||||
if (history_len > 1) {
|
||||
/* Update the current history entry before to
|
||||
* overwrite it with the next one. */
|
||||
|
@ -788,7 +789,7 @@ void linenoiseEditHistoryNext(struct linenoiseState *l, int dir) {
|
|||
|
||||
/* Delete the character at the right of the cursor without altering the cursor
|
||||
* position. Basically this is what happens with the "Delete" keyboard key. */
|
||||
void linenoiseEditDelete(struct linenoiseState *l) {
|
||||
static void linenoiseEditDelete(struct linenoiseState *l) {
|
||||
if (l->len > 0 && l->pos < l->len) {
|
||||
memmove(l->buf+l->pos,l->buf+l->pos+1,l->len-l->pos-1);
|
||||
l->len--;
|
||||
|
@ -798,7 +799,7 @@ void linenoiseEditDelete(struct linenoiseState *l) {
|
|||
}
|
||||
|
||||
/* Backspace implementation. */
|
||||
void linenoiseEditBackspace(struct linenoiseState *l) {
|
||||
static void linenoiseEditBackspace(struct linenoiseState *l) {
|
||||
if (l->pos > 0 && l->len > 0) {
|
||||
memmove(l->buf+l->pos-1,l->buf+l->pos,l->len-l->pos);
|
||||
l->pos--;
|
||||
|
@ -808,15 +809,22 @@ void linenoiseEditBackspace(struct linenoiseState *l) {
|
|||
}
|
||||
}
|
||||
|
||||
/* Delete the previosu word, maintaining the cursor at the start of the
|
||||
static void linenoiseEditDeleteNextWord(struct linenoiseState *l) {
|
||||
size_t i = l->pos;
|
||||
while (i != l->len && IsSeparator(l->buf[i])) i++;
|
||||
while (i != l->len && !IsSeparator(l->buf[i])) i++;
|
||||
memmove(l->buf+l->pos,l->buf+i,l->len-i);
|
||||
l->len -= i - l->pos;
|
||||
refreshLine(l);
|
||||
}
|
||||
|
||||
/* Delete the previous word, maintaining the cursor at the start of the
|
||||
* current word. */
|
||||
void linenoiseEditDeletePrevWord(struct linenoiseState *l) {
|
||||
static void linenoiseEditDeletePrevWord(struct linenoiseState *l) {
|
||||
size_t old_pos = l->pos;
|
||||
size_t diff;
|
||||
while (l->pos > 0 && l->buf[l->pos-1] == ' ')
|
||||
l->pos--;
|
||||
while (l->pos > 0 && l->buf[l->pos-1] != ' ')
|
||||
l->pos--;
|
||||
while (l->pos > 0 && IsSeparator(l->buf[l->pos-1])) l->pos--;
|
||||
while (l->pos > 0 && !IsSeparator(l->buf[l->pos-1])) l->pos--;
|
||||
diff = old_pos - l->pos;
|
||||
memmove(l->buf+l->pos,l->buf+old_pos,l->len-old_pos+1);
|
||||
l->len -= diff;
|
||||
|
@ -981,9 +989,16 @@ static int linenoiseEdit(int stdin_fd, int stdout_fd, char *buf, size_t buflen,
|
|||
}
|
||||
else if (seq[1] == 'b') { /* "\eb" is alt-b */
|
||||
linenoiseEditMoveLeftWord(&l);
|
||||
} else if (seq[1] == 'f') { /* "\ef" is alt-f */
|
||||
}
|
||||
else if (seq[1] == 'f') { /* "\ef" is alt-f */
|
||||
linenoiseEditMoveRightWord(&l);
|
||||
}
|
||||
else if (seq[1] == 'd') { /* "\e\b" is alt-d */
|
||||
linenoiseEditDeleteNextWord(&l);
|
||||
}
|
||||
else if (seq[1] == CTRL('H')) { /* "\e\b" is ctrl-alt-h */
|
||||
linenoiseEditDeletePrevWord(&l);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (32 <= seq[0] && seq[0] < 127) {
|
||||
|
@ -1022,31 +1037,6 @@ static int linenoiseEdit(int stdin_fd, int stdout_fd, char *buf, size_t buflen,
|
|||
return l.len;
|
||||
}
|
||||
|
||||
/* This special mode is used by linenoise in order to print scan codes
|
||||
* on screen for debugging / development purposes. It is implemented
|
||||
* by the linenoise_example program using the --keycodes option. */
|
||||
void linenoisePrintKeyCodes(void) {
|
||||
char quit[4];
|
||||
printf("Linenoise key codes debugging mode.\n"
|
||||
"Press keys to see scan codes. Type 'quit' at any time to exit.\n");
|
||||
if (enableRawMode(STDIN_FILENO) == -1) return;
|
||||
memset(quit,' ',4);
|
||||
while(1) {
|
||||
char c;
|
||||
int nread;
|
||||
nread = read(STDIN_FILENO,&c,1);
|
||||
if (nread <= 0) continue;
|
||||
memmove(quit,quit+1,sizeof(quit)-1); /* shift string to left. */
|
||||
quit[sizeof(quit)-1] = c; /* Insert current char on the right. */
|
||||
if (memcmp(quit,"quit",sizeof(quit)) == 0) break;
|
||||
printf("'%c' %02x (%d) (type quit to exit)\n",
|
||||
isprint(c) ? c : '?', (int)c, (int)c);
|
||||
printf("\r"); /* Go left edge manually, we are in raw mode. */
|
||||
fflush(stdout);
|
||||
}
|
||||
linenoiseDisableRawMode(STDIN_FILENO);
|
||||
}
|
||||
|
||||
/* This function calls the line editing function linenoiseEdit() using
|
||||
* the STDIN file descriptor set in raw mode. */
|
||||
static int linenoiseRaw(char *buf, size_t buflen, const char *prompt) {
|
||||
|
|
18
third_party/linenoise/linenoise.h
vendored
18
third_party/linenoise/linenoise.h
vendored
|
@ -1,7 +1,7 @@
|
|||
#ifndef __LINENOISE_H
|
||||
#define __LINENOISE_H
|
||||
#ifndef COSMOPOLITAN_THIRD_PARTY_LINENOISE_LINENOISE_H_
|
||||
#define COSMOPOLITAN_THIRD_PARTY_LINENOISE_LINENOISE_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
typedef struct linenoiseCompletions {
|
||||
size_t len;
|
||||
|
@ -9,7 +9,7 @@ typedef struct linenoiseCompletions {
|
|||
} linenoiseCompletions;
|
||||
|
||||
typedef void(linenoiseCompletionCallback)(const char *, linenoiseCompletions *);
|
||||
typedef char*(linenoiseHintsCallback)(const char *, int *, int *);
|
||||
typedef char *(linenoiseHintsCallback)(const char *, int *, int *);
|
||||
typedef void(linenoiseFreeHintsCallback)(void *);
|
||||
|
||||
void linenoiseSetCompletionCallback(linenoiseCompletionCallback *);
|
||||
|
@ -17,18 +17,18 @@ void linenoiseSetHintsCallback(linenoiseHintsCallback *);
|
|||
void linenoiseSetFreeHintsCallback(linenoiseFreeHintsCallback *);
|
||||
void linenoiseAddCompletion(linenoiseCompletions *, const char *);
|
||||
|
||||
char *linenoise(const char *);
|
||||
void linenoiseFree(void *);
|
||||
char *linenoise(const char *) nodiscard;
|
||||
int linenoiseHistoryAdd(const char *);
|
||||
int linenoiseHistorySetMaxLen(int);
|
||||
int linenoiseHistorySave(const char *);
|
||||
int linenoiseHistoryLoad(const char *);
|
||||
void linenoiseClearScreen(void);
|
||||
void linenoiseSetMultiLine(int );
|
||||
void linenoisePrintKeyCodes(void);
|
||||
void linenoiseSetMultiLine(int);
|
||||
void linenoiseMaskModeEnable(void);
|
||||
void linenoiseMaskModeDisable(void);
|
||||
void linenoiseDisableRawMode(int);
|
||||
void linenoiseFree(void *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* __LINENOISE_H */
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_THIRD_PARTY_LINENOISE_LINENOISE_H_ */
|
||||
|
|
5
third_party/linenoise/linenoise.mk
vendored
5
third_party/linenoise/linenoise.mk
vendored
|
@ -42,6 +42,11 @@ $(THIRD_PARTY_LINENOISE_A).pkg: \
|
|||
$(THIRD_PARTY_LINENOISE_A_OBJS) \
|
||||
$(foreach x,$(THIRD_PARTY_LINENOISE_A_DIRECTDEPS),$($(x)_A).pkg)
|
||||
|
||||
$(THIRD_PARTY_LINENOISE_A_OBJS): \
|
||||
OVERRIDE_CFLAGS += \
|
||||
-ffunction-sections \
|
||||
-fdata-sections
|
||||
|
||||
THIRD_PARTY_LINENOISE_LIBS = $(foreach x,$(THIRD_PARTY_LINENOISE_ARTIFACTS),$($(x)))
|
||||
THIRD_PARTY_LINENOISE_SRCS = $(foreach x,$(THIRD_PARTY_LINENOISE_ARTIFACTS),$($(x)_SRCS))
|
||||
THIRD_PARTY_LINENOISE_HDRS = $(foreach x,$(THIRD_PARTY_LINENOISE_ARTIFACTS),$($(x)_HDRS))
|
||||
|
|
2
third_party/python/Lib/test/test_locale.py
vendored
2
third_party/python/Lib/test/test_locale.py
vendored
|
@ -11,7 +11,7 @@ class BaseLocalizedTest(unittest.TestCase):
|
|||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
if sys.platform == 'darwin':
|
||||
if sys.platform in ('darwin', 'cosmo'):
|
||||
import os
|
||||
tlocs = ("en_US.UTF-8", "en_US.ISO8859-1", "en_US")
|
||||
if int(os.uname().release.split('.')[0]) < 10:
|
||||
|
|
1
third_party/python/Modules/_math.h
vendored
1
third_party/python/Modules/_math.h
vendored
|
@ -1,5 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_THIRD_PARTY_PYTHON_MODULES__MATH_H_
|
||||
#define COSMOPOLITAN_THIRD_PARTY_PYTHON_MODULES__MATH_H_
|
||||
#include "third_party/python/pyconfig.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
|
|
1
third_party/python/Modules/cmathmodule.c
vendored
1
third_party/python/Modules/cmathmodule.c
vendored
|
@ -6,6 +6,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/errno.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "third_party/python/Include/boolobject.h"
|
||||
#include "third_party/python/Include/complexobject.h"
|
||||
#include "third_party/python/Include/dtoa.h"
|
||||
|
|
2
third_party/python/Modules/config.c
vendored
2
third_party/python/Modules/config.c
vendored
|
@ -89,6 +89,7 @@ extern PyObject* PyInit__codecs_tw(void);
|
|||
extern PyObject* PyInit__json(void);
|
||||
extern PyObject* PyInit__lsprof(void);
|
||||
extern PyObject* PyInit__opcode(void);
|
||||
extern PyObject* PyInit_termios(void);
|
||||
|
||||
/* -- ADDMODULE MARKER 1 -- */
|
||||
|
||||
|
@ -164,6 +165,7 @@ struct _inittab _PyImport_Inittab[] = {
|
|||
{"_json", PyInit__json},
|
||||
{"_lsprof", PyInit__lsprof},
|
||||
{"_opcode", PyInit__opcode},
|
||||
{"termios", PyInit_termios},
|
||||
|
||||
/* -- ADDMODULE MARKER 2 -- */
|
||||
|
||||
|
|
8
third_party/python/Modules/faulthandler.c
vendored
8
third_party/python/Modules/faulthandler.c
vendored
|
@ -1100,15 +1100,9 @@ faulthandler_fatal_error_py(PyObject *self, PyObject *args)
|
|||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
/* TODO(jart): sigaltstack */
|
||||
#if defined(HAVE_SIGALTSTACK) && defined(HAVE_SIGACTION)
|
||||
#define FAULTHANDLER_STACK_OVERFLOW
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
/* Issue #23654: Turn off ICC's tail call optimization for the
|
||||
* stack_overflow generator. ICC turns the recursive tail call into
|
||||
* a loop. */
|
||||
# pragma intel optimization_level 0
|
||||
#endif
|
||||
static
|
||||
uintptr_t
|
||||
stack_overflow(uintptr_t min_sp, uintptr_t max_sp, size_t *depth)
|
||||
|
|
5
third_party/python/Modules/fcntlmodule.c
vendored
5
third_party/python/Modules/fcntlmodule.c
vendored
|
@ -11,6 +11,7 @@
|
|||
#include "libc/errno.h"
|
||||
#include "libc/sysv/consts/f.h"
|
||||
#include "libc/sysv/consts/fd.h"
|
||||
#include "libc/sysv/consts/lock.h"
|
||||
#include "third_party/python/Include/abstract.h"
|
||||
#include "third_party/python/Include/bytesobject.h"
|
||||
#include "third_party/python/Include/ceval.h"
|
||||
|
@ -558,10 +559,10 @@ all_ins(PyObject* m)
|
|||
|
||||
/* OS X specifics */
|
||||
#ifdef F_FULLFSYNC
|
||||
if (PyModule_AddIntMacro(m, F_FULLFSYNC)) return -1;
|
||||
if (F_FULLFSYNC && PyModule_AddIntMacro(m, F_FULLFSYNC)) return -1;
|
||||
#endif
|
||||
#ifdef F_NOCACHE
|
||||
if (PyModule_AddIntMacro(m, F_NOCACHE)) return -1;
|
||||
if (F_NOCACHE && PyModule_AddIntMacro(m, F_NOCACHE)) return -1;
|
||||
#endif
|
||||
|
||||
/* For F_{GET|SET}FL */
|
||||
|
|
74
third_party/python/Modules/posixmodule.c
vendored
74
third_party/python/Modules/posixmodule.c
vendored
|
@ -9,6 +9,7 @@
|
|||
#include "libc/assert.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/makedev.h"
|
||||
#include "libc/calls/struct/dirent.h"
|
||||
#include "libc/calls/termios.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
|
@ -16,6 +17,7 @@
|
|||
#include "libc/runtime/dlfcn.h"
|
||||
#include "libc/runtime/sysconf.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/sysv/consts/at.h"
|
||||
#include "libc/sysv/consts/dt.h"
|
||||
#include "libc/sysv/consts/ex.h"
|
||||
|
@ -6997,59 +6999,20 @@ os_symlink_impl(PyObject *module, path_t *src, path_t *dst,
|
|||
int target_is_directory, int dir_fd)
|
||||
/*[clinic end generated code: output=08ca9f3f3cf960f6 input=e820ec4472547bc3]*/
|
||||
{
|
||||
#ifdef MS_WINDOWS
|
||||
DWORD result;
|
||||
#else
|
||||
int result;
|
||||
#endif
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
if (!check_CreateSymbolicLink()) {
|
||||
PyErr_SetString(PyExc_NotImplementedError,
|
||||
"CreateSymbolicLink functions not found");
|
||||
return NULL;
|
||||
}
|
||||
if (!win32_can_symlink) {
|
||||
PyErr_SetString(PyExc_OSError, "symbolic link privilege not held");
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
_Py_BEGIN_SUPPRESS_IPH
|
||||
/* if src is a directory, ensure target_is_directory==1 */
|
||||
target_is_directory |= _check_dirW(src->wide, dst->wide);
|
||||
result = Py_CreateSymbolicLinkW(dst->wide, src->wide,
|
||||
target_is_directory);
|
||||
_Py_END_SUPPRESS_IPH
|
||||
Py_END_ALLOW_THREADS
|
||||
|
||||
if (!result)
|
||||
return path_error2(src, dst);
|
||||
|
||||
#else
|
||||
|
||||
if ((src->narrow && dst->wide) || (src->wide && dst->narrow)) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"symlink: src and dst must be the same type");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
#if HAVE_SYMLINKAT
|
||||
if (dir_fd != DEFAULT_DIR_FD)
|
||||
result = symlinkat(src->narrow, dir_fd, dst->narrow);
|
||||
else
|
||||
#endif
|
||||
result = symlink(src->narrow, dst->narrow);
|
||||
Py_END_ALLOW_THREADS
|
||||
|
||||
if (result)
|
||||
return path_error2(src, dst);
|
||||
#endif
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
#endif /* HAVE_SYMLINK */
|
||||
|
@ -10718,6 +10681,7 @@ os_cpu_count_impl(PyObject *module)
|
|||
{
|
||||
int ncpu;
|
||||
ncpu = GetCpuCount();
|
||||
printf("cpu count %d\n", ncpu);
|
||||
if (ncpu >= 1)
|
||||
return PyLong_FromLong(ncpu);
|
||||
else
|
||||
|
@ -12062,34 +12026,6 @@ static PyMethodDef posix_methods[] = {
|
|||
};
|
||||
|
||||
|
||||
#if defined(HAVE_SYMLINK) && defined(MS_WINDOWS)
|
||||
static int
|
||||
enable_symlink()
|
||||
{
|
||||
HANDLE tok;
|
||||
TOKEN_PRIVILEGES tok_priv;
|
||||
LUID luid;
|
||||
|
||||
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &tok))
|
||||
return 0;
|
||||
|
||||
if (!LookupPrivilegeValue(NULL, SE_CREATE_SYMBOLIC_LINK_NAME, &luid))
|
||||
return 0;
|
||||
|
||||
tok_priv.PrivilegeCount = 1;
|
||||
tok_priv.Privileges[0].Luid = luid;
|
||||
tok_priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||
|
||||
if (!AdjustTokenPrivileges(tok, FALSE, &tok_priv,
|
||||
sizeof(TOKEN_PRIVILEGES),
|
||||
(PTOKEN_PRIVILEGES) NULL, (PDWORD) NULL))
|
||||
return 0;
|
||||
|
||||
/* ERROR_NOT_ALL_ASSIGNED returned when the privilege can't be assigned. */
|
||||
return GetLastError() == ERROR_NOT_ALL_ASSIGNED ? 0 : 1;
|
||||
}
|
||||
#endif /* defined(HAVE_SYMLINK) && defined(MS_WINDOWS) */
|
||||
|
||||
static int
|
||||
all_ins(PyObject *m)
|
||||
{
|
||||
|
@ -12482,10 +12418,6 @@ INITFUNC(void)
|
|||
PyObject *list;
|
||||
const char * const *trace;
|
||||
|
||||
#if defined(HAVE_SYMLINK) && defined(MS_WINDOWS)
|
||||
win32_can_symlink = enable_symlink();
|
||||
#endif
|
||||
|
||||
m = PyModule_Create(&posixmodule);
|
||||
if (m == NULL)
|
||||
return NULL;
|
||||
|
|
6
third_party/python/Modules/termios.c
vendored
6
third_party/python/Modules/termios.c
vendored
|
@ -24,12 +24,6 @@
|
|||
|
||||
/* termiosmodule.c -- POSIX terminal I/O module implementation. */
|
||||
|
||||
/* Apparently, on SGI, termios.h won't define CTRL if _XOPEN_SOURCE
|
||||
is defined, so we define it here. */
|
||||
#if defined(__sgi)
|
||||
#define CTRL(c) ((c)&037)
|
||||
#endif
|
||||
|
||||
PyDoc_STRVAR(termios__doc__,
|
||||
"This module provides an interface to the Posix calls for tty I/O control.\n\
|
||||
For a complete description of these calls, see the Posix or Unix manual\n\
|
||||
|
|
8
third_party/python/Objects/longobject.c
vendored
8
third_party/python/Objects/longobject.c
vendored
|
@ -1604,7 +1604,7 @@ long_to_decimal_string_internal(PyObject *aa,
|
|||
digit *pout, *pin, rem, tenpow;
|
||||
int negative;
|
||||
int d;
|
||||
enum PyUnicode_Kind kind = -1;
|
||||
enum PyUnicode_Kind kind = 0;
|
||||
|
||||
a = (PyLongObject *)aa;
|
||||
if (a == NULL || !PyLong_Check(a)) {
|
||||
|
@ -1696,8 +1696,6 @@ long_to_decimal_string_internal(PyObject *aa,
|
|||
kind = PyUnicode_KIND(str);
|
||||
}
|
||||
|
||||
CHECK_NE(-1, kind); /* if this fails there's a serious bug upstream */
|
||||
|
||||
#define WRITE_DIGITS(p) \
|
||||
do { \
|
||||
/* pout[0] through pout[size-2] contribute exactly \
|
||||
|
@ -1796,7 +1794,7 @@ long_format_binary(PyObject *aa, int base, int alternate,
|
|||
PyObject *v = NULL;
|
||||
Py_ssize_t sz;
|
||||
Py_ssize_t size_a;
|
||||
enum PyUnicode_Kind kind = -1;
|
||||
enum PyUnicode_Kind kind = 0;
|
||||
int negative;
|
||||
int bits;
|
||||
|
||||
|
@ -1863,8 +1861,6 @@ long_format_binary(PyObject *aa, int base, int alternate,
|
|||
kind = PyUnicode_KIND(v);
|
||||
}
|
||||
|
||||
CHECK_NE(-1, kind); /* if this fails there's a serious bug upstream */
|
||||
|
||||
#define WRITE_DIGITS(p) \
|
||||
do { \
|
||||
if (size_a == 0) { \
|
||||
|
|
4
third_party/python/Programs/python.c
vendored
4
third_party/python/Programs/python.c
vendored
|
@ -46,7 +46,7 @@ GetMember(const char *s, Py_ssize_t n, PyObject *o)
|
|||
if (v != Py_None && PyUnicode_Check(k)) {
|
||||
t = PyUnicode_AsUTF8AndSize(k, &m);
|
||||
printf("\r%`'.*s vs. %`'.*s\n", n, s, m, t);
|
||||
if (n == m && !memcmp(s, t, n)) {
|
||||
if (n == m && !memcasecmp(s, t, n)) {
|
||||
Py_INCREF(v);
|
||||
return v;
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ TerminalComplete(const char *s, linenoiseCompletions *c, PyObject *o)
|
|||
for (n = strlen(s), i = 0; PyDict_Next(o, &i, &k, &v);) {
|
||||
if (v != Py_None && PyUnicode_Check(k)) {
|
||||
t = PyUnicode_AsUTF8AndSize(k, &m);
|
||||
if (m > n && !memcmp(t, s, n)) {
|
||||
if (m > n && !memcasecmp(t, s, n)) {
|
||||
c->cvec = realloc(c->cvec, ++c->len * sizeof(*c->cvec));
|
||||
c->cvec[c->len - 1] = strdup(t);
|
||||
}
|
||||
|
|
2
third_party/python/Python/sysmodule.c
vendored
2
third_party/python/Python/sysmodule.c
vendored
|
@ -7,6 +7,7 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/sysv/consts/exit.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
#include "third_party/python/Include/abstract.h"
|
||||
|
@ -2216,6 +2217,7 @@ sys_update_path(int argc, wchar_t **argv)
|
|||
}
|
||||
}
|
||||
#endif /* HAVE_READLINK */
|
||||
|
||||
#if SEP == '\\' /* Special case for MS filename syntax */
|
||||
if (_HAVE_SCRIPT_ARGUMENT(argc, argv)) {
|
||||
wchar_t *q;
|
||||
|
|
6
third_party/python/pyconfig.h
vendored
6
third_party/python/pyconfig.h
vendored
|
@ -408,7 +408,7 @@
|
|||
#define HAVE_GETPEERNAME 1
|
||||
|
||||
/* Define to 1 if you have the `getpgid' function. */
|
||||
/* #undef HAVE_GETPGID */
|
||||
#define HAVE_GETPGID 1
|
||||
|
||||
/* Define to 1 if you have the `getpgrp' function. */
|
||||
#define HAVE_GETPGRP 1
|
||||
|
@ -592,7 +592,7 @@
|
|||
/* #undef HAVE_LUTIMES */
|
||||
|
||||
/* Define this if you have the makedev macro. */
|
||||
/* #undef HAVE_MAKEDEV */
|
||||
#define HAVE_MAKEDEV 1
|
||||
|
||||
/* Define to 1 if you have the `mbrtowc' function. */
|
||||
#define HAVE_MBRTOWC 1
|
||||
|
@ -1486,4 +1486,6 @@
|
|||
|
||||
#define Py_NSIG 32
|
||||
|
||||
#define HAVE_SYSTEM 1
|
||||
|
||||
#endif /*Py_PYCONFIG_H*/
|
||||
|
|
7
third_party/python/python-modules.mk
vendored
7
third_party/python/python-modules.mk
vendored
|
@ -212,3 +212,10 @@ $(EXTMODULE_PYEXPAT_OBJS): \
|
|||
o/$(MODE)/third_party/python/Modules/_decimal/libmpdec/transpose.o: \
|
||||
OVERRIDE_CFLAGS += \
|
||||
-DSTACK_FRAME_UNLIMITED
|
||||
|
||||
# Issue #23654: Turn off ICC's tail call optimization for the
|
||||
# stack_overflow generator. ICC turns the recursive tail
|
||||
# call into a loop. [Let's do GCC too, just to be safe.]
|
||||
o/$(MODE)/third_party/python/Modules/faulthandler.o: \
|
||||
OVERRIDE_CFLAGS += \
|
||||
-fno-optimize-sibling-calls
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue