Make improvements

- Fix build flakes
- Polyfill SIGWINCH on Windows
- Fix an execve issue on Windows
- Make strerror show more information
- Improve cmd.exe setup/teardown on Windows
- Support bracketed paste mode in Blinkenlights
- Show keyboard shortcuts in Blinkenlights status bar
- Fixed copy_file_range() and copyfile() w/ zip filesystem
- Size optimize GetDosArgv() to keep life.com 12kb in size
- Improve Blinkenlights ability to load weird ELF executables
- Fix program_executable_name and add GetInterpreterExecutableName
- Make Python in tiny mode fail better if docstrings are requested
- Update Python test exclusions in tiny* modes such as tinylinux
- Add bulletproof unbreakable kprintf() troubleshooting function
- Remove "oldskool" keyword from ape.S for virus scanners
- Fix issue that caused backtraces to not print sometimes
- Improve Blinkenlights serial uart character i/o
- Make clock_gettime() not clobber errno on xnu
- Improve sha256 cpuid check for old computers
- Integrate some bestline linenoise fixes
- Show runit process names better in htop
- Remove SIGPIPE from ShowCrashReports()
- Make realpath() not clobber errno
- Avoid attaching GDB on non-Linux
- Improve img.com example
This commit is contained in:
Justine Tunney 2022-03-16 13:33:13 -07:00
parent 2a938b3eaa
commit b45d50b690
194 changed files with 4881 additions and 2966 deletions

View file

@ -1,7 +1,7 @@
#ifndef COSMOPOLITAN_THIRD_PARTY_PYTHON_INCLUDE_EZPRINT_H_
#define COSMOPOLITAN_THIRD_PARTY_PYTHON_INCLUDE_EZPRINT_H_
#include "libc/calls/calls.h"
#include "libc/log/libfatal.internal.h"
#include "libc/intrin/kprintf.h"
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/bytesobject.h"
#include "third_party/python/Include/pyerrors.h"
@ -11,24 +11,24 @@ COSMOPOLITAN_C_START_
static void EzPrint(PyObject *x, const char *s) {
PyObject *u, *r, *t;
__printf("%s = ", s);
kprintf("%s = ", s);
if (!s) {
__printf("NULL");
kprintf("NULL");
} else {
t = PyObject_Type(x);
r = PyObject_Repr(t);
u = PyUnicode_AsUTF8String(r);
__printf("%.*s ", PyBytes_GET_SIZE(u), PyBytes_AS_STRING(u));
kprintf("%.*s ", PyBytes_GET_SIZE(u), PyBytes_AS_STRING(u));
Py_DECREF(u);
Py_DECREF(r);
Py_DECREF(t);
r = PyObject_Repr(x);
u = PyUnicode_AsUTF8String(r);
__printf("%.*s", PyBytes_GET_SIZE(u), PyBytes_AS_STRING(u));
kprintf("%.*s", PyBytes_GET_SIZE(u), PyBytes_AS_STRING(u));
Py_DECREF(u);
Py_DECREF(r);
}
__printf("\n");
kprintf("\n");
}
#define EZPRINT(x) EzPrint(x, #x)

View file

@ -3,6 +3,7 @@
if __name__ != 'test.support':
raise ImportError('support must be imported from the test package')
import cosmo
import collections.abc
import contextlib
import datetime
@ -2043,9 +2044,10 @@ def run_unittest(*classes):
def _check_docstrings():
"""Just used to check if docstrings are enabled"""
MISSING_C_DOCSTRINGS = (check_impl_detail() and
sys.platform != 'win32' and
not sysconfig.get_config_var('WITH_DOC_STRINGS'))
MISSING_C_DOCSTRINGS = (cosmo.MODE.startswith('tiny') or
(check_impl_detail() and
sys.platform != 'win32' and
not sysconfig.get_config_var('WITH_DOC_STRINGS')))
HAVE_DOCSTRINGS = (_check_docstrings.__doc__ is not None and
not MISSING_C_DOCSTRINGS)

View file

@ -734,7 +734,7 @@ class BZ2DecompressorTest(BaseTest):
with self.assertRaises(TypeError):
pickle.dumps(BZ2Decompressor(), proto)
@unittest.skipIf(cosmo.MODE == 'tiny',
@unittest.skipIf(cosmo.MODE.startswith("tiny"),
"TODO(jart): what's going on here?")
def testDecompressorChunksMaxsize(self):
bzd = BZ2Decompressor()

View file

@ -490,7 +490,8 @@ class ClassTests(unittest.TestCase):
self.assertRaises(TypeError, hash, C2())
@unittest.skipIf(cosmo.MODE == 'tiny', "no stack awareness in tiny mode")
@unittest.skipIf(cosmo.MODE.startswith("tiny"),
"no stack awareness in tiny mode")
def testSFBug532646(self):
# Test for SF bug 532646

View file

@ -1152,7 +1152,7 @@ class ExceptionTests(unittest.TestCase):
os.listdir(__file__)
self.assertEqual(cm.exception.errno, errno.ENOTDIR, cm.exception)
@unittest.skipIf(cosmo.MODE == 'tiny',
@unittest.skipIf(cosmo.MODE.startswith("tiny"),
"todo(jart): why is it broken")
def test_unraisable(self):
# Issue #22836: PyErr_WriteUnraisable() should give sensible reports
@ -1186,7 +1186,7 @@ class ExceptionTests(unittest.TestCase):
self.assertIn("del is broken", report)
self.assertTrue(report.endswith("\n"))
@unittest.skipIf(cosmo.MODE == 'tiny',
@unittest.skipIf(cosmo.MODE.startswith("tiny"),
"todo(jart): why is it broken")
def test_unhandled(self):
# Check for sensible reporting of unhandled exceptions

View file

@ -177,7 +177,7 @@ class AutoFileTests:
finally:
os.close(fd)
@unittest.skipIf(cosmo.MODE == 'tiny', "no stack awareness in tiny mode")
@unittest.skipIf(cosmo.MODE.startswith("tiny"), "no stack awareness in tiny mode")
def testRecursiveRepr(self):
# Issue #25455
with swap_attr(self.f, 'name', self.f):

View file

@ -619,7 +619,7 @@ class TestUpdateWrapper(unittest.TestCase):
@unittest.skipIf(sys.flags.optimize >= 2,
"Docstrings are omitted with -O2 and above")
@unittest.skipIf(cosmo.MODE == 'tiny',
@unittest.skipIf(cosmo.MODE.startswith("tiny"),
"No .py files available in Cosmo MODE=tiny")
def test_default_update_doc(self):
wrapper, f = self._default_update()
@ -681,7 +681,7 @@ class TestUpdateWrapper(unittest.TestCase):
@support.requires_docstrings
@unittest.skipIf(sys.flags.optimize >= 2,
"Docstrings are omitted with -O2 and above")
@unittest.skipIf(cosmo.MODE == 'tiny',
@unittest.skipIf(cosmo.MODE .startswith("tiny"),
"No .py files available in Cosmo MODE=tiny")
def test_builtin_update(self):
# Test for bug #1576241
@ -715,7 +715,7 @@ class TestWraps(TestUpdateWrapper):
@unittest.skipIf(sys.flags.optimize >= 2,
"Docstrings are omitted with -O2 and above")
@unittest.skipIf(cosmo.MODE == 'tiny',
@unittest.skipIf(cosmo.MODE .startswith("tiny"),
"No .py files available in Cosmo MODE=tiny")
def test_default_update_doc(self):
wrapper, _ = self._default_update()

View file

@ -814,7 +814,8 @@ class TestBinaryPlistlib(unittest.TestCase):
b = plistlib.loads(plistlib.dumps(a, fmt=plistlib.FMT_BINARY))
self.assertIs(b['x'], b)
@unittest.skipIf(cosmo.MODE == 'tiny', "no stack awareness in tiny mode")
@unittest.skipIf(cosmo.MODE.startswith("tiny"),
"no stack awareness in tiny mode")
def test_deep_nesting(self):
for N in [300, 100000]:
chunks = [b'\xa1' + (i + 1).to_bytes(4, 'big') for i in range(N)]

View file

@ -131,7 +131,7 @@ class UnicodeFunctionsTest(UnicodeDatabaseTest):
self.assertRaises(TypeError, self.db.numeric, 'xx')
self.assertRaises(ValueError, self.db.numeric, 'x')
@unittest.skipIf(cosmo.MODE == 'tiny', 'astral planes arent tiny')
@unittest.skipIf(cosmo.MODE.startswith('tiny'), 'astral planes arent tiny')
def test_numeric_astral(self):
self.assertEqual(self.db.numeric('\U00020000', None), None)
self.assertEqual(self.db.numeric('\U0001012A'), 9000)

View file

@ -46,7 +46,7 @@
PYTHON_PROVIDE("tls");
#if 0
#define LOG(...) __printf(__VA_ARGS__)
#define LOG(...) kprintf(__VA_ARGS__)
#else
#define LOG(...) (void)0
#endif

View file

@ -6,6 +6,7 @@
*/
#include "libc/calls/calls.h"
#include "libc/dce.h"
#include "libc/intrin/kprintf.h"
#include "libc/log/libfatal.internal.h"
#include "libc/log/log.h"
#include "libc/runtime/runtime.h"
@ -94,10 +95,10 @@ ShowCrashReportHook(int err, int fd, int sig,
{
PyObject *str;
PyFrameObject *frame;
__printf("\nCalamity Occurred w/ Python\n");
kprintf("\nCalamity Occurred w/ Python\n");
for (frame = PyEval_GetFrame(); frame; frame = frame->f_back) {
str = PyUnicode_AsUTF8String(frame->f_code->co_filename);
__printf("%s:%d\n", PyBytes_AS_STRING(str), frame->f_code->co_firstlineno/* frame->f_lineno */);
kprintf("%s:%d\n", PyBytes_AS_STRING(str), frame->f_code->co_firstlineno/* frame->f_lineno */);
Py_DECREF(str);
}
}

File diff suppressed because it is too large Load diff