mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Source changes for compilation
These are the commits from https://github.com/ahgamut/cpython/tree/cosmo_py36 squashed for simplicity. Also included is the pyconfig.h used for compilation. The pyconfig.h has to be changed manually in case Cosmopolitan gets new features.
This commit is contained in:
parent
0c4c56ff39
commit
5ef64dbcdb
82 changed files with 2009 additions and 424 deletions
28
third_party/python/Lib/_dummy_thread.py
vendored
28
third_party/python/Lib/_dummy_thread.py
vendored
|
@ -13,11 +13,18 @@ Suggested usage is::
|
|||
"""
|
||||
# Exports only things specified by thread documentation;
|
||||
# skipping obsolete synonyms allocate(), start_new(), exit_thread().
|
||||
__all__ = ['error', 'start_new_thread', 'exit', 'get_ident', 'allocate_lock',
|
||||
'interrupt_main', 'LockType']
|
||||
__all__ = [
|
||||
"error",
|
||||
"start_new_thread",
|
||||
"exit",
|
||||
"get_ident",
|
||||
"allocate_lock",
|
||||
"interrupt_main",
|
||||
"LockType",
|
||||
]
|
||||
|
||||
# A dummy value
|
||||
TIMEOUT_MAX = 2**31
|
||||
TIMEOUT_MAX = 2 ** 31
|
||||
|
||||
# NOTE: this module can be imported early in the extension building process,
|
||||
# and so top level imports of other modules should be avoided. Instead, all
|
||||
|
@ -26,6 +33,7 @@ TIMEOUT_MAX = 2**31
|
|||
|
||||
error = RuntimeError
|
||||
|
||||
|
||||
def start_new_thread(function, args, kwargs={}):
|
||||
"""Dummy implementation of _thread.start_new_thread().
|
||||
|
||||
|
@ -51,6 +59,7 @@ def start_new_thread(function, args, kwargs={}):
|
|||
pass
|
||||
except:
|
||||
import traceback
|
||||
|
||||
traceback.print_exc()
|
||||
_main = True
|
||||
global _interrupt
|
||||
|
@ -58,10 +67,12 @@ def start_new_thread(function, args, kwargs={}):
|
|||
_interrupt = False
|
||||
raise KeyboardInterrupt
|
||||
|
||||
|
||||
def exit():
|
||||
"""Dummy implementation of _thread.exit()."""
|
||||
raise SystemExit
|
||||
|
||||
|
||||
def get_ident():
|
||||
"""Dummy implementation of _thread.get_ident().
|
||||
|
||||
|
@ -71,20 +82,24 @@ def get_ident():
|
|||
"""
|
||||
return -1
|
||||
|
||||
def allocate_lock():
|
||||
|
||||
def allocate_lock(*args, **kwargs):
|
||||
"""Dummy implementation of _thread.allocate_lock()."""
|
||||
return LockType()
|
||||
|
||||
|
||||
def stack_size(size=None):
|
||||
"""Dummy implementation of _thread.stack_size()."""
|
||||
if size is not None:
|
||||
raise error("setting thread stack size not supported")
|
||||
return 0
|
||||
|
||||
|
||||
def _set_sentinel():
|
||||
"""Dummy implementation of _thread._set_sentinel()."""
|
||||
return LockType()
|
||||
|
||||
|
||||
class LockType(object):
|
||||
"""Class implementing dummy implementation of _thread.LockType.
|
||||
|
||||
|
@ -120,6 +135,7 @@ class LockType(object):
|
|||
else:
|
||||
if timeout > 0:
|
||||
import time
|
||||
|
||||
time.sleep(timeout)
|
||||
return False
|
||||
|
||||
|
@ -145,14 +161,16 @@ class LockType(object):
|
|||
"locked" if self.locked_status else "unlocked",
|
||||
self.__class__.__module__,
|
||||
self.__class__.__qualname__,
|
||||
hex(id(self))
|
||||
hex(id(self)),
|
||||
)
|
||||
|
||||
|
||||
# Used to signal that interrupt_main was called in a "thread"
|
||||
_interrupt = False
|
||||
# True when not executing in a "thread"
|
||||
_main = True
|
||||
|
||||
|
||||
def interrupt_main():
|
||||
"""Set _interrupt flag to True to have start_new_thread raise
|
||||
KeyboardInterrupt upon exiting."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue