Commit 1a5837a3 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge pull request #795 from Daetalus/future_builtins

Enable future builtins module and add test file
parents 52e385e0 f9b80106
......@@ -1194,7 +1194,7 @@ TEST_EXT_MODULE_NAMES := basic_test descr_test slots_test
TEST_EXT_MODULE_SRCS := $(TEST_EXT_MODULE_NAMES:%=test/test_extension/%.c)
TEST_EXT_MODULE_OBJS := $(TEST_EXT_MODULE_NAMES:%=test/test_extension/%.pyston.so)
SHAREDMODS_NAMES := _multiprocessing pyexpat
SHAREDMODS_NAMES := _multiprocessing pyexpat future_builtins
SHAREDMODS_SRCS := \
_multiprocessing/multiprocessing.c \
_multiprocessing/semaphore.c \
......@@ -1205,7 +1205,8 @@ SHAREDMODS_SRCS := \
expat/xmltok_impl.c \
expat/xmltok_ns.c \
pyexpat.c \
_elementtree.c
_elementtree.c\
future_builtins.c
SHAREDMODS_SRCS := $(SHAREDMODS_SRCS:%=from_cpython/Modules/%)
SHAREDMODS_OBJS := $(SHAREDMODS_NAMES:%=lib_pyston/%.pyston.so)
......
......@@ -40,6 +40,7 @@ file(GLOB_RECURSE STDMODULE_SRCS Modules
errnomodule.c
fcntlmodule.c
fileio.c
future_builtins.c
getpath.c
iobase.c
itertoolsmodule.c
......@@ -114,6 +115,7 @@ add_library(FROM_CPYTHON OBJECT ${STDMODULE_SRCS} ${STDOBJECT_SRCS} ${STDPYTHON_
add_dependencies(FROM_CPYTHON copy_stdlib)
add_custom_command(OUTPUT
${CMAKE_BINARY_DIR}/lib_pyston/future_builtins.pyston.so
${CMAKE_BINARY_DIR}/lib_pyston/_multiprocessing.pyston.so
${CMAKE_BINARY_DIR}/lib_pyston/pyexpat.pyston.so
${CMAKE_BINARY_DIR}/lib_pyston/_elementtree.pyston.so
......@@ -141,6 +143,7 @@ add_custom_command(OUTPUT
Modules/expat/xmltok_impl.c
Modules/expat/xmltok_ns.c
Modules/pyexpat.c
Modules/future_builtins.c
Modules/_elementtree.c
Modules/bz2module.c
Modules/grpmodule.c
......
......@@ -17,6 +17,12 @@ def unique(f):
return cache[0]
return wrapper
@unique
def future_builtins_ext():
return Extension("future_builtins", sources = map(relpath, [
"Modules/future_builtins.c",
]))
@unique
def multiprocessing_ext():
return Extension("_multiprocessing", sources = map(relpath, [
......@@ -115,7 +121,8 @@ def elementtree_ext():
sources = [relpath('Modules/_elementtree.c')],
depends = pyexpat.depends,
)
ext_modules = [multiprocessing_ext(),
ext_modules = [future_builtins_ext(),
multiprocessing_ext(),
pyexpat_ext(),
elementtree_ext(),
bz2_ext(),
......
......@@ -2144,8 +2144,22 @@ extern "C" PyObject* PyNumber_Index(PyObject* o) noexcept {
}
extern "C" PyObject* PyNumber_ToBase(PyObject* n, int base) noexcept {
fatalOrError(PyExc_NotImplementedError, "unimplemented");
return nullptr;
PyObject* res = NULL;
PyObject* index = PyNumber_Index(n);
if (!index)
return NULL;
if (PyLong_Check(index))
res = _PyLong_Format(index, base, 0, 1);
else if (PyInt_Check(index))
res = _PyInt_Format((PyIntObject*)index, base, 1);
else
/* It should not be possible to get here, as
PyNumber_Index already has a check for the same
condition */
PyErr_SetString(PyExc_ValueError, "PyNumber_ToBase: index not int or long");
Py_DECREF(index);
return res;
}
extern "C" Py_ssize_t PyNumber_AsSsize_t(PyObject* item, PyObject* err) noexcept {
......
from future_builtins import hex, oct, map, zip, filter
from itertools import imap, izip, ifilter
value_list1 = [0, 42, 42L, -42, -42L, "", (), {}, []]
value_list2 = [0, 100, 100L, -100, -100L]
for value1 in value_list1:
try:
print(hex(value1))
except Exception as e:
print(type(e), e.message)
for value2 in value_list2:
try:
print(oct(value2))
except Exception as e:
print(type(e), e.message)
print(map == imap)
print(zip == izip)
print(filter == ifilter)
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