Commit 954464cd authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge branch 'capi'

parents dd3c61df 576a7f45
......@@ -276,9 +276,10 @@ SRCS := $(MAIN_SRCS) $(STDLIB_SRCS)
STDLIB_OBJS := stdlib.bc.o stdlib.stripped.bc.o
STDLIB_RELEASE_OBJS := stdlib.release.bc.o
STDMODULE_SRCS := errnomodule.c shamodule.c sha256module.c sha512module.c _math.c mathmodule.c md5.c md5module.c _randommodule.c _sre.c operator.c binascii.c pwdmodule.c $(EXTRA_STDMODULE_SRCS)
STDOBJECT_SRCS := structseq.c $(EXTRA_STDOBJECT_SRCS)
FROM_CPYTHON_SRCS := $(addprefix lib_python/2.7_Modules/,$(STDMODULE_SRCS)) $(addprefix lib_python/2.7_Objects/,$(STDOBJECT_SRCS)) $(wildcard src/capi/*.c)
STDMODULE_SRCS := errnomodule.c shamodule.c sha256module.c sha512module.c _math.c mathmodule.c md5.c md5module.c _randommodule.c _sre.c operator.c binascii.c pwdmodule.c posixmodule.c $(EXTRA_STDMODULE_SRCS)
STDOBJECT_SRCS := structseq.c capsule.c $(EXTRA_STDOBJECT_SRCS)
STDPYTHON_SRCS := pyctype.c getargs.c $(EXTRA_STDPYTHON_SRCS)
FROM_CPYTHON_SRCS := $(addprefix lib_python/2.7_Modules/,$(STDMODULE_SRCS)) $(addprefix lib_python/2.7_Objects/,$(STDOBJECT_SRCS)) $(addprefix lib_python/2.7_Python/,$(STDPYTHON_SRCS))
# The stdlib objects have slightly longer dependency chains,
# so put them first in the list:
......
......@@ -15,19 +15,30 @@
#ifndef PYSTON_EXTINCLUDE_PYTHON_H
#define PYSTON_EXTINCLUDE_PYTHON_H
#include <assert.h>
#include <errno.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
// These include orders come from CPython:
#include "patchlevel.h"
#include "pyconfig.h"
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_STDDEF_H
#include <stddef.h>
#endif
#include <assert.h>
// CPython doesn't seem to include this but I'm not sure how they get the definition of 'bool':
#include <stdbool.h>
#include "pyport.h"
#include "pymath.h"
......@@ -47,10 +58,12 @@
#include "complexobject.h"
#endif
#include "stringobject.h"
#include "bytesobject.h"
#include "listobject.h"
#include "dictobject.h"
#include "tupleobject.h"
#include "methodobject.h"
#include "fileobject.h"
#include "pycapsule.h"
#include "sliceobject.h"
#include "iterobject.h"
......@@ -65,6 +78,7 @@
#include "modsupport.h"
#include "pythonrun.h"
#include "ceval.h"
#include "intrcheck.h"
#include "import.h"
#include "abstract.h"
......
// This file is originally from CPython 2.7, with modifications for Pyston
#define PyBytesObject PyStringObject
#define PyBytes_Type PyString_Type
#define PyBytes_Check PyString_Check
#define PyBytes_CheckExact PyString_CheckExact
#define PyBytes_CHECK_INTERNED PyString_CHECK_INTERNED
#define PyBytes_AS_STRING PyString_AS_STRING
#define PyBytes_GET_SIZE PyString_GET_SIZE
#define Py_TPFLAGS_BYTES_SUBCLASS Py_TPFLAGS_STRING_SUBCLASS
#define PyBytes_FromStringAndSize PyString_FromStringAndSize
#define PyBytes_FromString PyString_FromString
#define PyBytes_FromFormatV PyString_FromFormatV
#define PyBytes_FromFormat PyString_FromFormat
#define PyBytes_Size PyString_Size
#define PyBytes_AsString PyString_AsString
#define PyBytes_Repr PyString_Repr
#define PyBytes_Concat PyString_Concat
#define PyBytes_ConcatAndDel PyString_ConcatAndDel
#define _PyBytes_Resize _PyString_Resize
#define _PyBytes_Eq _PyString_Eq
#define PyBytes_Format PyString_Format
#define _PyBytes_FormatLong _PyString_FormatLong
#define PyBytes_DecodeEscape PyString_DecodeEscape
#define _PyBytes_Join _PyString_Join
#define PyBytes_AsStringAndSize PyString_AsStringAndSize
#define _PyBytes_InsertThousandsGrouping _PyString_InsertThousandsGrouping
......@@ -92,7 +92,11 @@ struct _dictobject {
PyDictEntry ma_smalltable[PyDict_MINSIZE];
};
#endif
PyAPI_DATA(PyTypeObject*) list_cls;
#define PyList_Type (*list_cls)
// Pyston change: these are no longer static objects:
#if 0
PyAPI_DATA(PyTypeObject) PyDict_Type;
PyAPI_DATA(PyTypeObject) PyDictIterKey_Type;
PyAPI_DATA(PyTypeObject) PyDictIterValue_Type;
......@@ -100,6 +104,21 @@ PyAPI_DATA(PyTypeObject) PyDictIterItem_Type;
PyAPI_DATA(PyTypeObject) PyDictKeys_Type;
PyAPI_DATA(PyTypeObject) PyDictItems_Type;
PyAPI_DATA(PyTypeObject) PyDictValues_Type;
#endif
PyAPI_DATA(PyTypeObject*) dict_cls;
#define PyDict_Type (*dict_cls)
PyAPI_DATA(PyTypeObject*) dictiterkey_cls;
#define PyDictIterKey_Type (*dictiterkey_cls)
PyAPI_DATA(PyTypeObject*) dictitervalue_cls;
#define PyDictIterValue_Type (*dictitervalue_cls)
PyAPI_DATA(PyTypeObject*) dictiteritem_cls;
#define PyDictIterItem_Type (*dictiteritem_cls)
PyAPI_DATA(PyTypeObject*) dictkeys_cls;
#define PyDictKeys_Type (*dictkeys_cls)
PyAPI_DATA(PyTypeObject*) dictitems_cls;
#define PyDictItems_Type (*dictitems_cls)
PyAPI_DATA(PyTypeObject*) dictvalues_cls;
#define PyDictValues_Type (*dictvalues_cls)
// Pyston changes: these aren't direct macros any more [they potentially could be though]
PyAPI_FUNC(bool) PyDict_Check(PyObject*);
......
// This file is originally from CPython 2.7, with modifications for Pyston
/* File object interface */
#ifndef Py_FILEOBJECT_H
#define Py_FILEOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
// Pyston change: this is not our format
#if 0
typedef struct {
PyObject_HEAD
FILE *f_fp;
PyObject *f_name;
PyObject *f_mode;
int (*f_close)(FILE *);
int f_softspace; /* Flag used by 'print' command */
int f_binary; /* Flag which indicates whether the file is
open in binary (1) or text (0) mode */
char* f_buf; /* Allocated readahead buffer */
char* f_bufend; /* Points after last occupied position */
char* f_bufptr; /* Current buffer position */
char *f_setbuf; /* Buffer for setbuf(3) and setvbuf(3) */
int f_univ_newline; /* Handle any newline convention */
int f_newlinetypes; /* Types of newlines seen */
int f_skipnextlf; /* Skip next \n */
PyObject *f_encoding;
PyObject *f_errors;
PyObject *weakreflist; /* List of weak references */
int unlocked_count; /* Num. currently running sections of code
using f_fp with the GIL released. */
int readable;
int writable;
} PyFileObject;
#endif
typedef struct _PyFileObject PyFileObject;
// Pyston change: this is no longer a static object
PyAPI_DATA(PyTypeObject*) file_cls;
#define PyFile_Type (*file_cls)
#define PyFile_Check(op) PyObject_TypeCheck(op, &PyFile_Type)
#define PyFile_CheckExact(op) (Py_TYPE(op) == &PyFile_Type)
PyAPI_FUNC(PyObject *) PyFile_FromString(char *, char *);
PyAPI_FUNC(void) PyFile_SetBufSize(PyObject *, int);
PyAPI_FUNC(int) PyFile_SetEncoding(PyObject *, const char *);
PyAPI_FUNC(int) PyFile_SetEncodingAndErrors(PyObject *, const char *, char *errors);
PyAPI_FUNC(PyObject *) PyFile_FromFile(FILE *, char *, char *,
int (*)(FILE *));
PyAPI_FUNC(FILE *) PyFile_AsFile(PyObject *);
PyAPI_FUNC(void) PyFile_IncUseCount(PyFileObject *);
PyAPI_FUNC(void) PyFile_DecUseCount(PyFileObject *);
PyAPI_FUNC(PyObject *) PyFile_Name(PyObject *);
PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int);
PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int);
PyAPI_FUNC(int) PyFile_SoftSpace(PyObject *, int);
PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *);
PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *);
/* The default encoding used by the platform file system APIs
If non-NULL, this is different than the default encoding for strings
*/
PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding;
/* Routines to replace fread() and fgets() which accept any of \r, \n
or \r\n as line terminators.
*/
#define PY_STDIOTEXTMODE "b"
char *Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *);
size_t Py_UniversalNewlineFread(char *, size_t, FILE *, PyObject *);
/* A routine to do sanity checking on the file mode string. returns
non-zero on if an exception occurred
*/
int _PyFile_SanitizeMode(char *mode);
#if defined _MSC_VER && _MSC_VER >= 1400
/* A routine to check if a file descriptor is valid on Windows. Returns 0
* and sets errno to EBADF if it isn't. This is to avoid Assertions
* from various functions in the Windows CRT beginning with
* Visual Studio 2005
*/
int _PyVerify_fd(int fd);
#elif defined _MSC_VER && _MSC_VER >= 1200
/* fdopen doesn't set errno EBADF and crashes for large fd on debug build */
#define _PyVerify_fd(fd) (_get_osfhandle(fd) >= 0)
#else
#define _PyVerify_fd(A) (1) /* dummy */
#endif
/* A routine to check if a file descriptor can be select()-ed. */
#ifdef HAVE_SELECT
#define _PyIsSelectable_fd(FD) (((FD) >= 0) && ((FD) < FD_SETSIZE))
#else
#define _PyIsSelectable_fd(FD) (1)
#endif /* HAVE_SELECT */
#ifdef __cplusplus
}
#endif
#endif /* !Py_FILEOBJECT_H */
......@@ -63,7 +63,7 @@ PyAPI_FUNC(long) PyInt_GetMax(void);
/* Macro, trading safety for speed */
// Pyston changes: these aren't direct macros any more [they potentially could be though]
#define PyInt_AS_LONG(op) PyInt_FromLong(op)
#define PyInt_AS_LONG(op) PyInt_AsLong((PyObject*)op)
//#define PyInt_AS_LONG(op) (((PyIntObject *)(op))->ob_ival)
/* These aren't really part of the Int object, but they're handy; the protos
......
// This file is originally from CPython 2.7, with modifications for Pyston
#ifndef Py_INTRCHECK_H
#define Py_INTRCHECK_H
#ifdef __cplusplus
extern "C" {
#endif
PyAPI_FUNC(int) PyOS_InterruptOccurred(void);
PyAPI_FUNC(void) PyOS_InitInterrupts(void);
PyAPI_FUNC(void) PyOS_AfterFork(void);
#ifdef __cplusplus
}
#endif
#endif /* !Py_INTRCHECK_H */
......@@ -23,6 +23,8 @@
#define SIZEOF_VOID_P 8
#define SIZEOF_SIZE_T 8
#define SIZEOF_INT 4
#define SIZEOF_LONG 8
#define SIZEOF_LONG_LONG 8
#define HAVE_COPYSIGN 1
#define HAVE_ROUND 1
#define HAVE_HYPOT 1
......@@ -35,6 +37,57 @@
#define Py_USING_UNICODE 1
#define Py_UNICODE_SIZE 4
// Copied from a CPython ./configure run on a Linux machine:
#define HAVE_ALLOCA_H 1
#define HAVE_ASM_TYPES_H 1
#define HAVE_CURSES_H 1
#define HAVE_DIRENT_H 1
#define HAVE_DLFCN_H 1
#define HAVE_ERRNO_H 1
#define HAVE_FCNTL_H 1
#define HAVE_GRP_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_LANGINFO_H 1
#define HAVE_LIBINTL_H 1
#define HAVE_LIBUTIL_H 1
#define HAVE_LINUX_NETLINK_H 1
#define HAVE_LINUX_TIPC_H 1
#define HAVE_MEMORY_H 1
#define HAVE_NCURSES_H 1
#define HAVE_NETPACKET_PACKET_H 1
#define HAVE_POLL_H 1
#define HAVE_PTHREAD_H 1
#define HAVE_PTY_H 1
#define HAVE_SHADOW_H 1
#define HAVE_SIGNAL_H 1
#define HAVE_SPAWN_H 1
#define HAVE_STDINT_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRINGS_H 1
#define HAVE_STRING_H 1
#define HAVE_STROPTS_H 1
#define HAVE_SYSEXITS_H 1
#define HAVE_SYS_EPOLL_H 1
#define HAVE_SYS_FILE_H 1
#define HAVE_SYS_PARAM_H 1
#define HAVE_SYS_POLL_H 1
#define HAVE_SYS_RESOURCE_H 1
#define HAVE_SYS_SELECT_H 1
#define HAVE_SYS_SOCKET_H 1
#define HAVE_SYS_STATVFS_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_SYS_TIMES_H 1
#define HAVE_SYS_TIME_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_SYS_UN_H 1
#define HAVE_SYS_UTSNAME_H 1
#define HAVE_SYS_WAIT_H 1
#define HAVE_TERMIOS_H 1
#define HAVE_TERM_H 1
#define HAVE_UNISTD_H 1
#define HAVE_UTIME_H 1
#define HAVE_WCHAR_H 1
// Added this for some Pyston modifications:
#define MAX_PYSTRING_SIZE (PY_SSIZE_T_MAX/2 - (1<<20))
......
......@@ -6901,7 +6901,11 @@ posix_fdopen(PyObject *self, PyObject *args)
if (fp == NULL)
return posix_error();
/* We now know we will succeed, so initialize the file object. */
((PyFileObject *)f)->f_fp = fp;
// Pyston change:
Py_FatalError("Pyston TODO: implement this");
//((PyFileObject *)f)->f_fp = fp;
PyFile_SetBufSize(f, bufsize);
return f;
}
......
// This file is originally from CPython 2.7, with modifications for Pyston
/* Wrap void * pointers to be passed between C modules */
#include "Python.h"
/* Internal structure of PyCapsule */
typedef struct {
PyObject_HEAD
void *pointer;
const char *name;
void *context;
PyCapsule_Destructor destructor;
} PyCapsule;
static int
_is_legal_capsule(PyCapsule *capsule, const char *invalid_capsule)
{
if (!capsule || !PyCapsule_CheckExact(capsule) || capsule->pointer == NULL) {
PyErr_SetString(PyExc_ValueError, invalid_capsule);
return 0;
}
return 1;
}
#define is_legal_capsule(capsule, name) \
(_is_legal_capsule(capsule, \
name " called with invalid PyCapsule object"))
static int
name_matches(const char *name1, const char *name2) {
/* if either is NULL, */
if (!name1 || !name2) {
/* they're only the same if they're both NULL. */
return name1 == name2;
}
return !strcmp(name1, name2);
}
PyObject *
PyCapsule_New(void *pointer, const char *name, PyCapsule_Destructor destructor)
{
PyCapsule *capsule;
if (!pointer) {
PyErr_SetString(PyExc_ValueError, "PyCapsule_New called with null pointer");
return NULL;
}
capsule = PyObject_NEW(PyCapsule, &PyCapsule_Type);
if (capsule == NULL) {
return NULL;
}
capsule->pointer = pointer;
capsule->name = name;
capsule->context = NULL;
capsule->destructor = destructor;
return (PyObject *)capsule;
}
int
PyCapsule_IsValid(PyObject *o, const char *name)
{
PyCapsule *capsule = (PyCapsule *)o;
return (capsule != NULL &&
PyCapsule_CheckExact(capsule) &&
capsule->pointer != NULL &&
name_matches(capsule->name, name));
}
void *
PyCapsule_GetPointer(PyObject *o, const char *name)
{
PyCapsule *capsule = (PyCapsule *)o;
if (!is_legal_capsule(capsule, "PyCapsule_GetPointer")) {
return NULL;
}
if (!name_matches(name, capsule->name)) {
PyErr_SetString(PyExc_ValueError, "PyCapsule_GetPointer called with incorrect name");
return NULL;
}
return capsule->pointer;
}
const char *
PyCapsule_GetName(PyObject *o)
{
PyCapsule *capsule = (PyCapsule *)o;
if (!is_legal_capsule(capsule, "PyCapsule_GetName")) {
return NULL;
}
return capsule->name;
}
PyCapsule_Destructor
PyCapsule_GetDestructor(PyObject *o)
{
PyCapsule *capsule = (PyCapsule *)o;
if (!is_legal_capsule(capsule, "PyCapsule_GetDestructor")) {
return NULL;
}
return capsule->destructor;
}
void *
PyCapsule_GetContext(PyObject *o)
{
PyCapsule *capsule = (PyCapsule *)o;
if (!is_legal_capsule(capsule, "PyCapsule_GetContext")) {
return NULL;
}
return capsule->context;
}
int
PyCapsule_SetPointer(PyObject *o, void *pointer)
{
PyCapsule *capsule = (PyCapsule *)o;
if (!pointer) {
PyErr_SetString(PyExc_ValueError, "PyCapsule_SetPointer called with null pointer");
return -1;
}
if (!is_legal_capsule(capsule, "PyCapsule_SetPointer")) {
return -1;
}
capsule->pointer = pointer;
return 0;
}
int
PyCapsule_SetName(PyObject *o, const char *name)
{
PyCapsule *capsule = (PyCapsule *)o;
if (!is_legal_capsule(capsule, "PyCapsule_SetName")) {
return -1;
}
capsule->name = name;
return 0;
}
int
PyCapsule_SetDestructor(PyObject *o, PyCapsule_Destructor destructor)
{
PyCapsule *capsule = (PyCapsule *)o;
if (!is_legal_capsule(capsule, "PyCapsule_SetDestructor")) {
return -1;
}
capsule->destructor = destructor;
return 0;
}
int
PyCapsule_SetContext(PyObject *o, void *context)
{
PyCapsule *capsule = (PyCapsule *)o;
if (!is_legal_capsule(capsule, "PyCapsule_SetContext")) {
return -1;
}
capsule->context = context;
return 0;
}
void *
PyCapsule_Import(const char *name, int no_block)
{
// Pyston change:
Py_FatalError("Pyston TODO: implement this");
#if 0
PyObject *object = NULL;
void *return_value = NULL;
char *trace;
size_t name_length = (strlen(name) + 1) * sizeof(char);
char *name_dup = (char *)PyMem_MALLOC(name_length);
if (!name_dup) {
return NULL;
}
memcpy(name_dup, name, name_length);
trace = name_dup;
while (trace) {
char *dot = strchr(trace, '.');
if (dot) {
*dot++ = '\0';
}
if (object == NULL) {
if (no_block) {
object = PyImport_ImportModuleNoBlock(trace);
} else {
object = PyImport_ImportModule(trace);
if (!object) {
PyErr_Format(PyExc_ImportError, "PyCapsule_Import could not import module \"%s\"", trace);
}
}
} else {
PyObject *object2 = PyObject_GetAttrString(object, trace);
Py_DECREF(object);
object = object2;
}
if (!object) {
goto EXIT;
}
trace = dot;
}
/* compare attribute name to module.name by hand */
if (PyCapsule_IsValid(object, name)) {
PyCapsule *capsule = (PyCapsule *)object;
return_value = capsule->pointer;
} else {
PyErr_Format(PyExc_AttributeError,
"PyCapsule_Import \"%s\" is not valid",
name);
}
EXIT:
Py_XDECREF(object);
if (name_dup) {
PyMem_FREE(name_dup);
}
return return_value;
#endif
}
static void
capsule_dealloc(PyObject *o)
{
PyCapsule *capsule = (PyCapsule *)o;
if (capsule->destructor) {
capsule->destructor(o);
}
PyObject_DEL(o);
}
static PyObject *
capsule_repr(PyObject *o)
{
PyCapsule *capsule = (PyCapsule *)o;
const char *name;
const char *quote;
if (capsule->name) {
quote = "\"";
name = capsule->name;
} else {
quote = "";
name = "NULL";
}
return PyString_FromFormat("<capsule object %s%s%s at %p>",
quote, name, quote, capsule);
}
PyDoc_STRVAR(PyCapsule_Type__doc__,
"Capsule objects let you wrap a C \"void *\" pointer in a Python\n\
object. They're a way of passing data through the Python interpreter\n\
without creating your own custom type.\n\
\n\
Capsules are used for communication between extension modules.\n\
They provide a way for an extension module to export a C interface\n\
to other extension modules, so that extension modules can use the\n\
Python import mechanism to link to one another.\n\
");
PyTypeObject PyCapsule_Type = {
// Pyston change:
//PyVarObject_HEAD_INIT(&PyType_Type, 0)
PyVarObject_HEAD_INIT(NULL, 0)
"PyCapsule", /*tp_name*/
sizeof(PyCapsule), /*tp_basicsize*/
0, /*tp_itemsize*/
/* methods */
capsule_dealloc, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_reserved*/
capsule_repr, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
0, /*tp_flags*/
PyCapsule_Type__doc__ /*tp_doc*/
};
// This file is originally from CPython 2.7, with modifications for Pyston
/* Implementation helper: a struct that looks like a tuple. See timemodule
and posixmodule for example uses. */
......
This diff is collapsed.
......@@ -2,6 +2,7 @@ Files in this directory were originally obtained from the CPython mercurial repo
revision 90928 (2.7.7 release). The "2.7" directory is a copy of the Lib directory, and the
"2.7_Modules" directory is a copy of the Modules directory.
The 2.7_Objects directory contains some of the Objects/ directory.
The 2.7_Python directory contains some of the Python/ directory.
The original code is redistributed under the original license (see main LICENSE file);
modifications are distributed under the Apache License, Version 2.0 (again, see main LICENSE file).
......@@ -686,7 +686,7 @@ public:
for (; i < arg_names.args->size(); i++) {
AST_expr* arg = (*arg_names.args)[i];
assert(arg->type == AST_TYPE::Name);
RELEASE_ASSERT(arg->type == AST_TYPE::Name, "");
AST_Name* arg_name = ast_cast<AST_Name>(arg);
initial_types[arg_name->id] = unboxedType(arg_types[i]);
}
......
// Copyright (c) 2014 Dropbox, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Hopefully soon we will be able to switch to CPython's getargs.c, instead of having
// to reimplement it. For now, it's easier to create simple versions of the functions
// instead of trying to support all of the internals of getargs.c
#include <dlfcn.h>
#include <stdarg.h>
#include <string.h>
#include "Python.h"
#include "core/threading.h"
#include "core/types.h"
#include "runtime/objmodel.h"
#include "runtime/types.h"
namespace pyston {
#define FLAG_COMPAT 1
#define FLAG_SIZE_T 2
// This function is named after the CPython one:
static int vgetargs1(PyObject* _tuple, const char* fmt, va_list* ap, int flags) {
RELEASE_ASSERT(_tuple->cls == tuple_cls, "");
BoxedTuple* tuple = static_cast<BoxedTuple*>(_tuple);
bool now_optional = false;
int arg_idx = 0;
int tuple_size = tuple->elts.size();
while (char c = *fmt) {
fmt++;
if (c == ':') {
break;
} else if (c == '|') {
now_optional = true;
continue;
} else {
if (arg_idx >= tuple_size) {
RELEASE_ASSERT(now_optional, "");
break;
}
PyObject* arg = tuple->elts[arg_idx];
arg_idx++;
switch (c) {
case 'i': { // signed int
int* p = (int*)va_arg(*ap, int*);
RELEASE_ASSERT(arg->cls == int_cls, "%s", getTypeName(arg)->c_str());
int64_t n = static_cast<BoxedInt*>(arg)->n;
RELEASE_ASSERT(n >= INT_MIN, "");
RELEASE_ASSERT(n <= INT_MAX, "");
*p = n;
break;
}
case 'n': { // ssize_t
Py_ssize_t* p = (Py_ssize_t*)va_arg(*ap, Py_ssize_t*);
// could also be a long:
RELEASE_ASSERT(arg->cls == int_cls, "%s", getTypeName(arg)->c_str());
int64_t n = static_cast<BoxedInt*>(arg)->n;
*p = n;
break;
}
case 'd': { // double
double* p = (double*)va_arg(*ap, double*);
RELEASE_ASSERT(arg->cls == float_cls, "%s", getTypeName(arg)->c_str());
*p = static_cast<BoxedFloat*>(arg)->d;
break;
}
case 's': {
if (*fmt == '*') {
Py_buffer* p = (Py_buffer*)va_arg(*ap, Py_buffer*);
RELEASE_ASSERT(arg->cls == str_cls, "");
PyBuffer_FillInfo(p, arg, PyString_AS_STRING(arg), PyString_GET_SIZE(arg), 1, 0);
fmt++;
} else if (*fmt == ':') {
break;
} else {
RELEASE_ASSERT(0, "");
}
break;
}
case 'O': {
if (fmt && *fmt == '!') {
fmt++;
PyObject* _cls = (PyObject*)va_arg(*ap, PyObject*);
PyObject** p = (PyObject**)va_arg(*ap, PyObject**);
RELEASE_ASSERT(_cls->cls == type_cls, "%s", getTypeName(_cls)->c_str());
PyTypeObject* cls = static_cast<PyTypeObject*>(_cls);
if (!isSubclass(arg->cls, cls)) {
// should raise a TypeError
abort();
}
*p = arg;
} else if (fmt && *fmt == '&') {
// Copied from CPython:
typedef int (*converter)(PyObject*, void*);
converter convert = va_arg(*ap, converter);
void* addr = va_arg(*ap, void*);
fmt++;
if (!(*convert)(arg, addr)) {
Py_FatalError("unsupported error case");
}
} else {
RELEASE_ASSERT(*fmt != '?', "unsupported");
PyObject** p = (PyObject**)va_arg(*ap, PyObject**);
*p = arg;
}
break;
}
default:
RELEASE_ASSERT(0, "Unhandled format character: '%c'", c);
}
}
}
return 1;
}
extern "C" int PyArg_VaParse(PyObject* _tuple, const char* fmt, va_list ap) {
va_list lva;
__va_copy(lva, ap);
return vgetargs1(_tuple, fmt, &lva, 0);
}
extern "C" int PyArg_ParseTuple(PyObject* _tuple, const char* fmt, ...) {
va_list ap;
va_start(ap, fmt);
int r = vgetargs1(_tuple, fmt, &ap, 0);
va_end(ap);
return r;
}
extern "C" int _PyArg_ParseTuple_SizeT(PyObject* args, char* format, ...) {
int retval;
va_list va;
va_start(va, format);
retval = vgetargs1(args, format, &va, FLAG_SIZE_T);
va_end(va);
return retval;
}
extern "C" int PyArg_ParseTupleAndKeywords(PyObject* args, PyObject* kwargs, const char* format, char** kwlist, ...) {
assert(kwargs->cls == dict_cls);
RELEASE_ASSERT(static_cast<BoxedDict*>(kwargs)->d.size() == 0, "");
va_list ap;
va_start(ap, kwlist);
int r = vgetargs1(args, format, &ap, 0);
va_end(ap);
return r;
}
extern "C" int _PyArg_ParseTupleAndKeywords_SizeT(PyObject* args, PyObject* keywords, const char* format, char** kwlist,
...) {
if ((args == NULL || !PyTuple_Check(args)) || (keywords != NULL && !PyDict_Check(keywords)) || format == NULL
|| kwlist == NULL) {
PyErr_BadInternalCall();
return 0;
}
assert(keywords->cls == dict_cls);
RELEASE_ASSERT(static_cast<BoxedDict*>(keywords)->d.size() == 0, "");
va_list ap;
va_start(ap, kwlist);
int r = vgetargs1(args, format, &ap, FLAG_SIZE_T);
va_end(ap);
return r;
}
extern "C" int PyArg_UnpackTuple(PyObject* args, const char* name, Py_ssize_t min, Py_ssize_t max, ...) {
RELEASE_ASSERT(args->cls == tuple_cls, "");
BoxedTuple* t = static_cast<BoxedTuple*>(args);
RELEASE_ASSERT(min <= t->elts.size() && t->elts.size() <= max, "");
va_list ap;
va_start(ap, max);
for (auto e : t->elts) {
PyObject** p = (PyObject**)va_arg(ap, PyObject**);
*p = e;
}
va_end(ap);
return true;
}
extern "C" int _PyArg_NoKeywords(const char* funcname, PyObject* kw) {
if (kw == NULL)
return 1;
if (kw->cls != dict_cls) {
PyErr_BadInternalCall();
return 0;
}
if (static_cast<BoxedDict*>(kw)->d.empty())
return 1;
PyErr_Format(PyExc_TypeError, "%s does not take keyword arguments", funcname);
return 0;
}
} // namespace pyston
......@@ -38,6 +38,17 @@
namespace pyston {
extern "C" {
// Copied from CPython:
#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
const char* Py_FileSystemDefaultEncoding = "mbcs";
#elif defined(__APPLE__)
const char* Py_FileSystemDefaultEncoding = "utf-8";
#else
const char* Py_FileSystemDefaultEncoding = NULL; /* use default */
#endif
}
extern "C" Box* trap() {
raise(SIGTRAP);
......@@ -453,7 +464,7 @@ BoxedClass* BaseException, *Exception, *StandardError, *AssertionError, *Attribu
*NameError, *KeyError, *IndexError, *IOError, *OSError, *ZeroDivisionError, *ValueError, *UnboundLocalError,
*RuntimeError, *ImportError, *StopIteration, *Warning, *SyntaxError, *OverflowError, *DeprecationWarning,
*MemoryError, *LookupError, *EnvironmentError, *ArithmeticError, *BufferError, *KeyboardInterrupt, *SystemExit,
*SystemError;
*SystemError, *NotImplementedError;
}
Box* exceptionNew1(BoxedClass* cls) {
......@@ -745,10 +756,10 @@ void setupBuiltins() {
/*BytesWarning =*/makeBuiltinException(Warning, "BytesWarning");
MemoryError = makeBuiltinException(StandardError, "MemoryError");
BufferError = makeBuiltinException(StandardError, "BufferError");
/*NotImplementedError=*/makeBuiltinException(RuntimeError, "NotImplementedError");
KeyboardInterrupt = makeBuiltinException(BaseException, "KeyboardInterrupt");
SystemExit = makeBuiltinException(BaseException, "SystemExit");
SystemError = makeBuiltinException(StandardError, "SystemError");
NotImplementedError = makeBuiltinException(RuntimeError, "NotImplementedError");
repr_obj = new BoxedFunction(boxRTFunction((void*)repr, UNKNOWN, 1));
builtins_module->giveAttr("repr", repr_obj);
......
// Copyright (c) 2014 Dropbox, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <cmath>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include "core/types.h"
#include "gc/collector.h"
#include "runtime/inline/boxing.h"
#include "runtime/types.h"
#include "runtime/util.h"
namespace pyston {
BoxedModule* posix_module;
namespace posix {
static Box* urandom(Box* _n) {
RELEASE_ASSERT(_n->cls == int_cls, "");
int64_t n = static_cast<BoxedInt*>(_n)->n;
RELEASE_ASSERT(n < INT_MAX, "");
int fd = ::open("/dev/urandom", O_RDONLY);
RELEASE_ASSERT(fd > 0, "");
BoxedString* r = static_cast<BoxedString*>(PyString_FromStringAndSize(NULL, n));
RELEASE_ASSERT(r, "");
char* buf = PyString_AsString(r);
int total_read = 0;
while (total_read < n) {
int this_read = read(fd, buf, n - total_read);
assert(this_read > 0);
total_read += this_read;
}
::close(fd);
return r;
}
static Box* posix_getuid() {
return boxInt(getuid());
}
extern "C" {
extern char** environ;
}
static Box* convertEnviron() {
assert(environ);
BoxedDict* d = new BoxedDict();
// Ported from CPython:
for (char** e = environ; *e != NULL; e++) {
char* p = strchr(*e, '=');
if (p == NULL)
continue;
Box* k = PyString_FromStringAndSize(*e, (int)(p - *e));
Box* v = PyString_FromString(p + 1);
Box*& cur_v = d->d[k];
if (cur_v == NULL)
cur_v = v;
}
return d;
}
} // namespace posix
using namespace posix;
void setupPosix() {
posix_module = createModule("posix", "__builtin__");
posix_module->giveAttr("urandom", new BoxedFunction(boxRTFunction((void*)posix::urandom, STR, 1)));
posix_module->giveAttr("getuid", new BoxedFunction(boxRTFunction((void*)posix::posix_getuid, BOXED_INT, 0)));
posix_module->giveAttr("error", OSError);
posix_module->giveAttr("environ", convertEnviron());
}
}
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare"
#else
#pragma GCC diagnostic ignored "-Wtype-limits"
#endif
// Copied from CPython/Modules/posixmodule.c:
extern "C" {
PyObject* _PyInt_FromUid(uid_t uid) {
if (uid <= LONG_MAX)
return PyInt_FromLong(uid);
return PyLong_FromUnsignedLong(uid);
}
PyObject* _PyInt_FromGid(gid_t gid) {
if (gid <= LONG_MAX)
return PyInt_FromLong(gid);
return PyLong_FromUnsignedLong(gid);
}
int _Py_Uid_Converter(PyObject* obj, void* p) {
int overflow;
long result;
if (PyFloat_Check(obj)) {
PyErr_SetString(PyExc_TypeError, "integer argument expected, got float");
return 0;
}
result = PyLong_AsLongAndOverflow(obj, &overflow);
if (overflow < 0)
goto OverflowDown;
if (!overflow && result == -1) {
/* error or -1 */
if (PyErr_Occurred())
return 0;
*(uid_t*)p = (uid_t)-1;
} else {
/* unsigned uid_t */
unsigned long uresult;
if (overflow > 0) {
uresult = PyLong_AsUnsignedLong(obj);
if (PyErr_Occurred()) {
if (PyErr_ExceptionMatches(PyExc_OverflowError))
goto OverflowUp;
return 0;
}
} else {
if (result < 0)
goto OverflowDown;
uresult = result;
}
if (sizeof(uid_t) < sizeof(long) && (unsigned long)(uid_t)uresult != uresult)
goto OverflowUp;
*(uid_t*)p = (uid_t)uresult;
}
return 1;
OverflowDown:
PyErr_SetString(PyExc_OverflowError, "user id is less than minimum");
return 0;
OverflowUp:
PyErr_SetString(PyExc_OverflowError, "user id is greater than maximum");
return 0;
}
int _Py_Gid_Converter(PyObject* obj, void* p) {
int overflow;
long result;
if (PyFloat_Check(obj)) {
PyErr_SetString(PyExc_TypeError, "integer argument expected, got float");
return 0;
}
result = PyLong_AsLongAndOverflow(obj, &overflow);
if (overflow < 0)
goto OverflowDown;
if (!overflow && result == -1) {
/* error or -1 */
if (PyErr_Occurred())
return 0;
*(gid_t*)p = (gid_t)-1;
} else {
/* unsigned gid_t */
unsigned long uresult;
if (overflow > 0) {
uresult = PyLong_AsUnsignedLong(obj);
if (PyErr_Occurred()) {
if (PyErr_ExceptionMatches(PyExc_OverflowError))
goto OverflowUp;
return 0;
}
} else {
if (result < 0)
goto OverflowDown;
uresult = result;
}
if (sizeof(gid_t) < sizeof(long) && (unsigned long)(gid_t)uresult != uresult)
goto OverflowUp;
*(gid_t*)p = (gid_t)uresult;
}
return 1;
OverflowDown:
PyErr_SetString(PyExc_OverflowError, "group id is less than minimum");
return 0;
OverflowUp:
PyErr_SetString(PyExc_OverflowError, "group id is greater than maximum");
return 0;
}
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
......@@ -13,6 +13,7 @@
// limitations under the License.
#include <dlfcn.h>
#include <fcntl.h>
#include <stdarg.h>
#include <string.h>
......@@ -777,6 +778,220 @@ extern "C" const char* PyUnicode_AS_DATA(PyObject*) {
Py_FatalError("unimplemented");
}
extern "C" const char* PyUnicode_GetDefaultEncoding(void) {
Py_FatalError("unimplemented");
}
extern "C" int PyBuffer_IsContiguous(Py_buffer* view, char fort) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyErr_SetFromErrnoWithFilename(PyObject* exc, const char* filename) {
PyObject* name = filename ? PyString_FromString(filename) : NULL;
PyObject* result = PyErr_SetFromErrnoWithFilenameObject(exc, name);
Py_XDECREF(name);
return result;
}
extern "C" PyObject* PyErr_SetFromErrnoWithFilenameObject(PyObject* exc, PyObject* filenameObject) {
PyObject* v;
const char* s;
int i = errno;
#ifdef PLAN9
char errbuf[ERRMAX];
#endif
#ifdef MS_WINDOWS
char* s_buf = NULL;
char s_small_buf[28]; /* Room for "Windows Error 0xFFFFFFFF" */
#endif
#ifdef EINTR
if (i == EINTR && PyErr_CheckSignals())
return NULL;
#endif
#ifdef PLAN9
rerrstr(errbuf, sizeof errbuf);
s = errbuf;
#else
if (i == 0)
s = "Error"; /* Sometimes errno didn't get set */
else
#ifndef MS_WINDOWS
s = strerror(i);
#else
{
/* Note that the Win32 errors do not lineup with the
errno error. So if the error is in the MSVC error
table, we use it, otherwise we assume it really _is_
a Win32 error code
*/
if (i > 0 && i < _sys_nerr) {
s = _sys_errlist[i];
} else {
int len = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, /* no message source */
i, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
/* Default language */
(LPTSTR)&s_buf, 0, /* size not used */
NULL); /* no args */
if (len == 0) {
/* Only ever seen this in out-of-mem
situations */
sprintf(s_small_buf, "Windows Error 0x%X", i);
s = s_small_buf;
s_buf = NULL;
} else {
s = s_buf;
/* remove trailing cr/lf and dots */
while (len > 0 && (s[len - 1] <= ' ' || s[len - 1] == '.'))
s[--len] = '\0';
}
}
}
#endif /* Unix/Windows */
#endif /* PLAN 9*/
if (filenameObject != NULL)
v = Py_BuildValue("(isO)", i, s, filenameObject);
else
v = Py_BuildValue("(is)", i, s);
if (v != NULL) {
PyErr_SetObject(exc, v);
Py_DECREF(v);
}
#ifdef MS_WINDOWS
LocalFree(s_buf);
#endif
return NULL;
}
extern "C" int PyOS_snprintf(char* str, size_t size, const char* format, ...) {
int rc;
va_list va;
va_start(va, format);
rc = PyOS_vsnprintf(str, size, format, va);
va_end(va);
return rc;
}
extern "C" int PyOS_vsnprintf(char* str, size_t size, const char* format, va_list va) {
int len; /* # bytes written, excluding \0 */
#ifdef HAVE_SNPRINTF
#define _PyOS_vsnprintf_EXTRA_SPACE 1
#else
#define _PyOS_vsnprintf_EXTRA_SPACE 512
char* buffer;
#endif
assert(str != NULL);
assert(size > 0);
assert(format != NULL);
/* We take a size_t as input but return an int. Sanity check
* our input so that it won't cause an overflow in the
* vsnprintf return value or the buffer malloc size. */
if (size > INT_MAX - _PyOS_vsnprintf_EXTRA_SPACE) {
len = -666;
goto Done;
}
#ifdef HAVE_SNPRINTF
len = vsnprintf(str, size, format, va);
#else
/* Emulate it. */
buffer = (char*)PyMem_MALLOC(size + _PyOS_vsnprintf_EXTRA_SPACE);
if (buffer == NULL) {
len = -666;
goto Done;
}
len = vsprintf(buffer, format, va);
if (len < 0)
/* ignore the error */;
else if ((size_t)len >= size + _PyOS_vsnprintf_EXTRA_SPACE)
Py_FatalError("Buffer overflow in PyOS_snprintf/PyOS_vsnprintf");
else {
const size_t to_copy = (size_t)len < size ? (size_t)len : size - 1;
assert(to_copy < size);
memcpy(str, buffer, to_copy);
str[to_copy] = '\0';
}
PyMem_FREE(buffer);
#endif
Done:
if (size > 0)
str[size - 1] = '\0';
return len;
#undef _PyOS_vsnprintf_EXTRA_SPACE
}
extern "C" void PyOS_AfterFork(void) {
Py_FatalError("unimplemented");
}
extern "C" {
static int dev_urandom_python(char* buffer, Py_ssize_t size) noexcept {
int fd;
Py_ssize_t n;
if (size <= 0)
return 0;
Py_BEGIN_ALLOW_THREADS fd = ::open("/dev/urandom", O_RDONLY);
Py_END_ALLOW_THREADS if (fd < 0) {
if (errno == ENOENT || errno == ENXIO || errno == ENODEV || errno == EACCES)
PyErr_SetString(PyExc_NotImplementedError, "/dev/urandom (or equivalent) not found");
else
PyErr_SetFromErrno(PyExc_OSError);
return -1;
}
Py_BEGIN_ALLOW_THREADS do {
do {
n = read(fd, buffer, (size_t)size);
} while (n < 0 && errno == EINTR);
if (n <= 0)
break;
buffer += n;
size -= (Py_ssize_t)n;
}
while (0 < size)
;
Py_END_ALLOW_THREADS
if (n <= 0) {
/* stop on error or if read(size) returned 0 */
if (n < 0)
PyErr_SetFromErrno(PyExc_OSError);
else
PyErr_Format(PyExc_RuntimeError, "Failed to read %zi bytes from /dev/urandom", size);
close(fd);
return -1;
}
close(fd);
return 0;
}
}
extern "C" int _PyOS_URandom(void* buffer, Py_ssize_t size) {
if (size < 0) {
PyErr_Format(PyExc_ValueError, "negative argument not allowed");
return -1;
}
if (size == 0)
return 0;
#ifdef MS_WINDOWS
return win32_urandom((unsigned char*)buffer, size, 1);
#else
#ifdef __VMS
return vms_urandom((unsigned char*)buffer, size, 1);
#else
return dev_urandom_python((char*)buffer, size);
#endif
#endif
}
BoxedModule* importTestExtension(const std::string& name) {
std::string pathname_name = "test/test_extension/" + name + ".pyston.so";
const char* pathname = pathname_name.c_str();
......
......@@ -30,6 +30,10 @@ extern "C" Box* createPureImaginary(double i) {
return new BoxedComplex(0.0, i);
}
extern "C" Py_complex PyComplex_AsCComplex(PyObject* op) {
Py_FatalError("unimplemented");
}
// addition
extern "C" Box* complexAddComplex(BoxedComplex* lhs, BoxedComplex* rhs) {
......
......@@ -159,10 +159,16 @@ extern "C" PyObject* PyDict_GetItem(PyObject* dict, PyObject* key) {
try {
return getitem(dict, key);
} catch (Box* b) {
if (isSubclass(b->cls, KeyError))
return NULL;
abort();
}
}
extern "C" int PyDict_Next(PyObject* op, Py_ssize_t* ppos, PyObject** pkey, PyObject** pvalue) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyDict_GetItemString(PyObject* dict, const char* key) {
Box* key_s;
try {
......
......@@ -178,6 +178,18 @@ Box* fileIterHasNext(Box* s) {
return boxBool(!fileEof(self));
}
extern "C" PyObject* PyFile_FromFile(FILE* fp, char* name, char* mode, int (*close)(FILE*)) {
Py_FatalError("unimplemented");
}
extern "C" void PyFile_SetBufSize(PyObject* f, int bufsize) {
Py_FatalError("unimplemented");
}
extern "C" int _PyFile_SanitizeMode(char* mode) {
Py_FatalError("unimplemented");
}
void setupFile() {
file_cls->giveAttr("__name__", boxStrConstant("file"));
......
......@@ -31,6 +31,10 @@
namespace pyston {
extern "C" unsigned long PyInt_AsUnsignedLongMask(PyObject* op) {
Py_FatalError("unimplemented");
}
extern "C" long PyInt_AsLong(PyObject* op) {
RELEASE_ASSERT(op->cls == int_cls, "");
return static_cast<BoxedInt*>(op)->n;
......
......@@ -32,6 +32,18 @@ namespace pyston {
BoxedClass* long_cls;
extern "C" unsigned long PyLong_AsUnsignedLongMask(PyObject* op) {
Py_FatalError("unimplemented");
}
extern "C" unsigned PY_LONG_LONG PyLong_AsUnsignedLongLongMask(PyObject* vv) {
Py_FatalError("unimplemented");
}
extern "C" PY_LONG_LONG PyLong_AsLongLong(PyObject* vv) {
Py_FatalError("unimplemented");
}
static int64_t asSignedLong(BoxedLong* self) {
assert(self->cls == long_cls);
if (!mpz_fits_slong_p(self->n))
......
......@@ -399,8 +399,10 @@ BoxedHeapClass::BoxedHeapClass(BoxedClass* metaclass, BoxedClass* base, gcvisit_
tp_as_sequence = &as_sequence;
tp_as_buffer = &as_buffer;
// just make sure these get zero-initialized:
assert(as_sequence.sq_item == NULL);
memset(&as_number, 0, sizeof(as_number));
memset(&as_mapping, 0, sizeof(as_mapping));
memset(&as_sequence, 0, sizeof(as_sequence));
memset(&as_buffer, 0, sizeof(as_buffer));
}
std::string getFullNameOfClass(BoxedClass* cls) {
......
......@@ -31,6 +31,10 @@
namespace pyston {
extern "C" PyObject* PyString_FromFormat(const char* format, ...) {
Py_FatalError("unimplemented");
}
extern "C" BoxedString* strAdd(BoxedString* lhs, Box* _rhs) {
assert(lhs->cls == str_cls);
......
......@@ -44,6 +44,7 @@ extern "C" void initmath();
extern "C" void initoperator();
extern "C" void initbinascii();
extern "C" void initpwd();
extern "C" void initposix();
namespace pyston {
......@@ -949,10 +950,11 @@ void setupRuntime() {
setupBuiltins();
setupTime();
setupThread();
setupPosix();
setupCAPI();
PyType_Ready(&PyCapsule_Type);
initerrno();
init_sha();
init_sha256();
......@@ -964,6 +966,7 @@ void setupRuntime() {
initoperator();
initbinascii();
initpwd();
initposix();
setupSysEnd();
......
......@@ -70,7 +70,6 @@ void setupSys();
void setupBuiltins();
void setupTime();
void setupThread();
void setupPosix();
void setupSysEnd();
BoxedDict* getSysModulesDict();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment