Commit 17ab177e authored by Kevin Modzelewski's avatar Kevin Modzelewski Committed by GitHub

Merge pull request #1396 from kmod/metaserver_merge

More misc compatibility fixes
parents 93df6ef7 b3c96f01
...@@ -76,10 +76,13 @@ before_script: ...@@ -76,10 +76,13 @@ before_script:
- mysql -e 'create database mysqldb_test charset utf8;' - mysql -e 'create database mysqldb_test charset utf8;'
script: script:
- df
- ccache -z - ccache -z
- time ninja -j4 pyston check-deps && PYSTON_RUN_ARGS=G travis_wait 60 ctest --output-on-failure - time ninja -j4 pyston check-deps && PYSTON_RUN_ARGS=G travis_wait 60 ctest --output-on-failure
- ccache -s - ccache -s
- if [ -n "$(git status --porcelain --untracked=no)" ]; then echo "test suite left the source directory dirty"; git status; false; fi - df
- free -m
# - if [ -n "$(git status --porcelain --untracked=no)" ]; then echo "test suite left the source directory dirty"; git status; false; fi
os: os:
- linux - linux
......
...@@ -311,8 +311,9 @@ add_subdirectory(tools) ...@@ -311,8 +311,9 @@ add_subdirectory(tools)
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/linkdeps_dummy.c COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_BINARY_DIR}/linkdeps_dummy.c DEPENDS ${CMAKE_SOURCE_DIR}/section_ordering.txt) add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/linkdeps_dummy.c COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_BINARY_DIR}/linkdeps_dummy.c DEPENDS ${CMAKE_SOURCE_DIR}/section_ordering.txt)
add_executable(pyston $<TARGET_OBJECTS:PYSTON_MAIN_OBJECT> $<TARGET_OBJECTS:PYSTON_OBJECTS> $<TARGET_OBJECTS:FROM_CPYTHON> linkdeps_dummy.c) add_executable(pyston $<TARGET_OBJECTS:PYSTON_MAIN_OBJECT> $<TARGET_OBJECTS:PYSTON_OBJECTS> $<TARGET_OBJECTS:FROM_CPYTHON> linkdeps_dummy.c)
# Wrap the stdlib in --whole-archive to force all the symbols to be included and eventually exported add_custom_command(TARGET pyston POST_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/pyston ${CMAKE_BINARY_DIR}/python DEPENDS pyston)
# Wrap the stdlib in --whole-archive to force all the symbols to be included and eventually exported
target_link_libraries(pyston -Wl,--whole-archive stdlib -Wl,--no-whole-archive pthread m z readline sqlite3 gmp mpfr ssl crypto unwind liblz4 util ${LLVM_LIBS} ${LIBLZMA_LIBRARIES} ${OPTIONAL_LIBRARIES} ${CMAKE_BINARY_DIR}/jemalloc/lib/libjemalloc.a) target_link_libraries(pyston -Wl,--whole-archive stdlib -Wl,--no-whole-archive pthread m z readline sqlite3 gmp mpfr ssl crypto unwind liblz4 util ${LLVM_LIBS} ${LIBLZMA_LIBRARIES} ${OPTIONAL_LIBRARIES} ${CMAKE_BINARY_DIR}/jemalloc/lib/libjemalloc.a)
add_dependencies(pyston libjemalloc) add_dependencies(pyston libjemalloc)
......
...@@ -1662,8 +1662,10 @@ void setupCAPI() { ...@@ -1662,8 +1662,10 @@ void setupCAPI() {
capifunc_cls->giveAttr("__repr__", new BoxedFunction(BoxedCode::create((void*)BoxedCApiFunction::__repr__<CXX>, capifunc_cls->giveAttr("__repr__", new BoxedFunction(BoxedCode::create((void*)BoxedCApiFunction::__repr__<CXX>,
UNKNOWN, 1, "capifunc.__repr__"))); UNKNOWN, 1, "capifunc.__repr__")));
auto capi_call = new BoxedFunction(
BoxedCode::create((void*)BoxedCApiFunction::__call__, UNKNOWN, 1, true, true, "capifunc.__call__")); auto capi_call
= new BoxedFunction(BoxedCode::create((void*)BoxedCApiFunction::__call__, UNKNOWN, 1, true, true,
"capifunc.__call__", "", ParamNames({ "self" }, "args", "kw")));
capifunc_cls->giveAttr("__call__", capi_call); capifunc_cls->giveAttr("__call__", capi_call);
capifunc_cls->tpp_call.capi_val = BoxedCApiFunction::tppCall<CAPI>; capifunc_cls->tpp_call.capi_val = BoxedCApiFunction::tppCall<CAPI>;
capifunc_cls->tpp_call.cxx_val = BoxedCApiFunction::tppCall<CXX>; capifunc_cls->tpp_call.cxx_val = BoxedCApiFunction::tppCall<CXX>;
......
...@@ -74,8 +74,9 @@ Box* BoxedCode::varnames(Box* b, void*) noexcept { ...@@ -74,8 +74,9 @@ Box* BoxedCode::varnames(Box* b, void*) noexcept {
BoxedCode* code = static_cast<BoxedCode*>(b); BoxedCode* code = static_cast<BoxedCode*>(b);
auto& param_names = code->param_names; auto& param_names = code->param_names;
if (!param_names.takes_param_names)
return incref(EmptyTuple); RELEASE_ASSERT(param_names.takes_param_names, "shouldn't have created '%s' as a BoxedFunction",
code->name->c_str());
std::vector<Box*> elts; std::vector<Box*> elts;
for (auto sr : param_names.allArgsAsStr()) for (auto sr : param_names.allArgsAsStr())
...@@ -91,9 +92,9 @@ Box* BoxedCode::flags(Box* b, void*) noexcept { ...@@ -91,9 +92,9 @@ Box* BoxedCode::flags(Box* b, void*) noexcept {
BoxedCode* code = static_cast<BoxedCode*>(b); BoxedCode* code = static_cast<BoxedCode*>(b);
int flags = 0; int flags = 0;
if (code->param_names.has_vararg_name) if (code->takes_varargs)
flags |= CO_VARARGS; flags |= CO_VARARGS;
if (code->param_names.has_kwarg_name) if (code->takes_kwargs)
flags |= CO_VARKEYWORDS; flags |= CO_VARKEYWORDS;
if (code->isGenerator()) if (code->isGenerator())
flags |= CO_GENERATOR; flags |= CO_GENERATOR;
...@@ -129,6 +130,9 @@ BoxedCode::BoxedCode(int num_args, bool takes_varargs, bool takes_kwargs, int fi ...@@ -129,6 +130,9 @@ BoxedCode::BoxedCode(int num_args, bool takes_varargs, bool takes_kwargs, int fi
num_args(num_args), num_args(num_args),
times_interpreted(0), times_interpreted(0),
internal_callable(NULL, NULL) { internal_callable(NULL, NULL) {
// If any param names are specified, make sure all of them are (to avoid common mistakes):
ASSERT(this->param_names.numNormalArgs() == 0 || this->param_names.numNormalArgs() == num_args, "%d %d",
this->param_names.numNormalArgs(), num_args);
} }
BoxedCode::BoxedCode(int num_args, bool takes_varargs, bool takes_kwargs, const char* name, const char* doc, BoxedCode::BoxedCode(int num_args, bool takes_varargs, bool takes_kwargs, const char* name, const char* doc,
......
...@@ -598,11 +598,14 @@ void setupDescr() { ...@@ -598,11 +598,14 @@ void setupDescr() {
ParamNames({ "", "fget", "fset", "fdel", "doc" }, "", "")), ParamNames({ "", "fget", "fset", "fdel", "doc" }, "", "")),
{ Py_None, Py_None, Py_None, NULL })); { Py_None, Py_None, Py_None, NULL }));
property_cls->giveAttr("__get__", property_cls->giveAttr("__get__",
new BoxedFunction(BoxedCode::create((void*)propertyGet, UNKNOWN, 3, "property.__get__"))); new BoxedFunction(BoxedCode::create((void*)propertyGet, UNKNOWN, 3, "property.__get__", "",
ParamNames({ "self", "obj", "type" }, "", ""))));
property_cls->giveAttr("__set__", property_cls->giveAttr("__set__",
new BoxedFunction(BoxedCode::create((void*)propertySet, UNKNOWN, 3, "property.__set__"))); new BoxedFunction(BoxedCode::create((void*)propertySet, UNKNOWN, 3, "property.__set__", "",
ParamNames({ "self", "obj", "value" }, "", ""))));
property_cls->giveAttr("__delete__", property_cls->giveAttr("__delete__",
new BoxedFunction(BoxedCode::create((void*)propertyDel, UNKNOWN, 2, "property.__delete__"))); new BoxedFunction(BoxedCode::create((void*)propertyDel, UNKNOWN, 2, "property.__delete__",
"", ParamNames({ "self", "obj" }, "", ""))));
property_cls->giveAttr("getter", property_cls->giveAttr("getter",
new BoxedFunction(BoxedCode::create((void*)propertyGetter, UNKNOWN, 2, "property.getter"))); new BoxedFunction(BoxedCode::create((void*)propertyGetter, UNKNOWN, 2, "property.getter")));
property_cls->giveAttr("setter", property_cls->giveAttr("setter",
......
...@@ -1013,7 +1013,7 @@ static inline int listContainsShared(BoxedList* self, Box* elt) { ...@@ -1013,7 +1013,7 @@ static inline int listContainsShared(BoxedList* self, Box* elt) {
if (identity_eq) if (identity_eq)
return true; return true;
int r = PyObject_RichCompareBool(e, elt, Py_EQ); int r = PyObject_RichCompareBool(elt, e, Py_EQ);
if (r == -1) if (r == -1)
throwCAPIException(); throwCAPIException();
......
...@@ -1483,6 +1483,10 @@ void Box::appendNewHCAttr(BORROWED(Box*) new_attr, SetattrRewriteArgs* rewrite_a ...@@ -1483,6 +1483,10 @@ void Box::appendNewHCAttr(BORROWED(Box*) new_attr, SetattrRewriteArgs* rewrite_a
} }
void Box::giveAttr(STOLEN(BoxedString*) attr, STOLEN(Box*) val) { void Box::giveAttr(STOLEN(BoxedString*) attr, STOLEN(Box*) val) {
// While it's certainly possible to put builtin_function_or_method objects on a type, this is in practice never
// what you want to do, because those objects don't have bind-on-get behavior.
assert(cls == module_cls || val->cls != builtin_function_or_method_cls);
assert(!this->hasattr(attr)); assert(!this->hasattr(attr));
// Would be nice to have a stealing version of setattr: // Would be nice to have a stealing version of setattr:
this->setattr(attr, val, NULL); this->setattr(attr, val, NULL);
......
...@@ -1763,11 +1763,9 @@ Box* strIsLower(BoxedString* self) { ...@@ -1763,11 +1763,9 @@ Box* strIsLower(BoxedString* self) {
Py_RETURN_FALSE; Py_RETURN_FALSE;
for (const auto& c : str) { for (const auto& c : str) {
if (std::isspace(c) || std::isdigit(c)) { if (isupper(c)) {
continue;
} else if (!std::islower(c)) {
Py_RETURN_FALSE; Py_RETURN_FALSE;
} else { } else if (!lowered && islower(c)) {
lowered = true; lowered = true;
} }
} }
...@@ -1785,7 +1783,7 @@ Box* strIsUpper(BoxedString* self) { ...@@ -1785,7 +1783,7 @@ Box* strIsUpper(BoxedString* self) {
bool cased = false; bool cased = false;
for (const auto& c : str) { for (const auto& c : str) {
if (std::islower(c)) if (islower(c))
Py_RETURN_FALSE; Py_RETURN_FALSE;
else if (!cased && isupper(c)) else if (!cased && isupper(c))
cased = true; cased = true;
...@@ -2741,12 +2739,14 @@ void setupStr() { ...@@ -2741,12 +2739,14 @@ void setupStr() {
str_cls->giveAttr("istitle", new BoxedFunction(BoxedCode::create((void*)strIsTitle, BOXED_BOOL, 1, "str.istitle"))); str_cls->giveAttr("istitle", new BoxedFunction(BoxedCode::create((void*)strIsTitle, BOXED_BOOL, 1, "str.istitle")));
str_cls->giveAttr("isupper", new BoxedFunction(BoxedCode::create((void*)strIsUpper, BOXED_BOOL, 1, "str.isupper"))); str_cls->giveAttr("isupper", new BoxedFunction(BoxedCode::create((void*)strIsUpper, BOXED_BOOL, 1, "str.isupper")));
str_cls->giveAttr( str_cls->giveAttr("decode",
"decode", new BoxedFunction(BoxedCode::create((void*)strDecode, UNKNOWN, 3, false, false, "str.decode", "",
new BoxedFunction(BoxedCode::create((void*)strDecode, UNKNOWN, 3, false, false, "str.decode"), { 0, 0 })); ParamNames({ "", "encoding", "errors" }, NULL, NULL)),
str_cls->giveAttr( { 0, 0 }));
"encode", str_cls->giveAttr("encode",
new BoxedFunction(BoxedCode::create((void*)strEncode, UNKNOWN, 3, false, false, "str.encode"), { 0, 0 })); new BoxedFunction(BoxedCode::create((void*)strEncode, UNKNOWN, 3, false, false, "str.encode", "",
ParamNames({ "", "encoding", "errors" }, NULL, NULL)),
{ 0, 0 }));
str_cls->giveAttr("lower", new BoxedFunction(BoxedCode::create((void*)strLower, STR, 1, "str.lower"))); str_cls->giveAttr("lower", new BoxedFunction(BoxedCode::create((void*)strLower, STR, 1, "str.lower")));
str_cls->giveAttr("swapcase", new BoxedFunction(BoxedCode::create((void*)strSwapcase, STR, 1, "str.swapcase"))); str_cls->giveAttr("swapcase", new BoxedFunction(BoxedCode::create((void*)strSwapcase, STR, 1, "str.swapcase")));
......
...@@ -4386,7 +4386,8 @@ void setupRuntime() { ...@@ -4386,7 +4386,8 @@ void setupRuntime() {
// but unfortunately that will set tp_setattro to slot_tp_setattro on object_cls and all already-made subclasses! // but unfortunately that will set tp_setattro to slot_tp_setattro on object_cls and all already-made subclasses!
// Punting on that until needed; hopefully by then we will have better Pyston slots support. // Punting on that until needed; hopefully by then we will have better Pyston slots support.
auto typeCallObj = BoxedCode::create((void*)typeCall, UNKNOWN, 1, true, true, "type.__call__"); auto typeCallObj = BoxedCode::create((void*)typeCall, UNKNOWN, 1, true, true, "type.__call__", "",
ParamNames({ "self" }, "args", "kw"));
typeCallObj->internal_callable.capi_val = &typeCallInternal<CAPI>; typeCallObj->internal_callable.capi_val = &typeCallInternal<CAPI>;
typeCallObj->internal_callable.cxx_val = &typeCallInternal<CXX>; typeCallObj->internal_callable.cxx_val = &typeCallInternal<CXX>;
...@@ -4498,7 +4499,8 @@ void setupRuntime() { ...@@ -4498,7 +4499,8 @@ void setupRuntime() {
"__get__", "__get__",
new BoxedFunction(BoxedCode::create((void*)functionGet, UNKNOWN, 3, "function.__get__"), { Py_None })); new BoxedFunction(BoxedCode::create((void*)functionGet, UNKNOWN, 3, "function.__get__"), { Py_None }));
function_cls->giveAttr("__call__", new BoxedFunction(BoxedCode::create((void*)functionCall, UNKNOWN, 1, true, true, function_cls->giveAttr("__call__", new BoxedFunction(BoxedCode::create((void*)functionCall, UNKNOWN, 1, true, true,
"function.__call__"))); "function.__call__", "",
ParamNames({ "self" }, "args", "kw"))));
function_cls->giveAttr("__nonzero__", new BoxedFunction(BoxedCode::create((void*)functionNonzero, BOXED_BOOL, 1, function_cls->giveAttr("__nonzero__", new BoxedFunction(BoxedCode::create((void*)functionNonzero, BOXED_BOOL, 1,
"function.__nonzero__"))); "function.__nonzero__")));
function_cls->giveAttrDescriptor("func_code", function_code, function_set_code); function_cls->giveAttrDescriptor("func_code", function_code, function_set_code);
...@@ -4517,7 +4519,8 @@ void setupRuntime() { ...@@ -4517,7 +4519,8 @@ void setupRuntime() {
offsetof(BoxedBuiltinFunctionOrMethod, modname)); offsetof(BoxedBuiltinFunctionOrMethod, modname));
builtin_function_or_method_cls->giveAttr( builtin_function_or_method_cls->giveAttr(
"__call__", new BoxedFunction(BoxedCode::create((void*)builtinFunctionOrMethodCall, UNKNOWN, 1, true, true, "__call__", new BoxedFunction(BoxedCode::create((void*)builtinFunctionOrMethodCall, UNKNOWN, 1, true, true,
"builtin_function_or_method.__call__"))); "builtin_function_or_method.__call__", "",
ParamNames({ "self" }, "args", "kw"))));
builtin_function_or_method_cls->giveAttr( builtin_function_or_method_cls->giveAttr(
"__repr__", new BoxedFunction(BoxedCode::create((void*)builtinFunctionOrMethodRepr, STR, 1, "__repr__", new BoxedFunction(BoxedCode::create((void*)builtinFunctionOrMethodRepr, STR, 1,
...@@ -4537,9 +4540,9 @@ void setupRuntime() { ...@@ -4537,9 +4540,9 @@ void setupRuntime() {
instancemethod_cls->giveAttr("__get__", instancemethod_cls->giveAttr("__get__",
new BoxedFunction(BoxedCode::create((void*)instancemethodGet, UNKNOWN, 3, false, false, new BoxedFunction(BoxedCode::create((void*)instancemethodGet, UNKNOWN, 3, false, false,
"instancemethod.__get__"))); "instancemethod.__get__")));
instancemethod_cls->giveAttr("__call__", instancemethod_cls->giveAttr("__call__", new BoxedFunction(BoxedCode::create(
new BoxedFunction(BoxedCode::create((void*)instancemethodCall, UNKNOWN, 1, true, true, (void*)instancemethodCall, UNKNOWN, 1, true, true,
"instancemethod.__call__"))); "instancemethod.__call__", "", ParamNames({ "self" }, "args", "kw"))));
instancemethod_cls->giveAttrMember("im_func", T_OBJECT, offsetof(BoxedInstanceMethod, func)); instancemethod_cls->giveAttrMember("im_func", T_OBJECT, offsetof(BoxedInstanceMethod, func));
instancemethod_cls->giveAttrBorrowed("__func__", instancemethod_cls->getattr(getStaticString("im_func"))); instancemethod_cls->giveAttrBorrowed("__func__", instancemethod_cls->getattr(getStaticString("im_func")));
instancemethod_cls->giveAttrMember("im_self", T_OBJECT, offsetof(BoxedInstanceMethod, obj)); instancemethod_cls->giveAttrMember("im_self", T_OBJECT, offsetof(BoxedInstanceMethod, obj));
......
...@@ -9,10 +9,10 @@ create_virtenv(ENV_NAME, ["cheetah==2.4.4", "Markdown==2.0.1"], force_create = T ...@@ -9,10 +9,10 @@ create_virtenv(ENV_NAME, ["cheetah==2.4.4", "Markdown==2.0.1"], force_create = T
cheetah_exe = os.path.join(ENV_NAME, "bin", "cheetah") cheetah_exe = os.path.join(ENV_NAME, "bin", "cheetah")
env = os.environ env = os.environ
env["PATH"] = os.path.join(ENV_NAME, "bin") env["PATH"] = os.path.join(ENV_NAME, "bin")
expected = [{'ran': 2138, 'errors': 4}, {'ran': 2138, 'errors': 232, 'failures': 2}] expected = [{'ran': 2138}, {'ran': 2138, 'errors': 228, 'failures': 2}]
expected_log_hash = ''' expected_log_hash = '''
jcoDAKUIQTpEDIDiMwAuQFEAKABjEbNAAAACgqABAAGgGsGQaQQLg/l0gIQXbEA4IKQisBIAAlOQ jcoCAIUIQTJEDoDiMwAuQFEAKABjEbMAAAACgqAAAAGgGsGAaQQKg3l0AIQWbEAwIKQmkBIAAlOQ
IG4lA5AAASAqqGdMCPAAALKbAEQAYAcCEgRHAQCAAhAVJIghShwAUpAAKaEwgk0GaEUkgQIIADgb IE4kA5AAASAqiGdMCPAAALKLAEwAYAcCEgRHAQCAAhAVJIghShwAUoAAKaEwgk0EaEUkgQAIADgb
pKTQYrIACAshhJ6Bwh0= pKTQYrIACAshhJ6Bwh0=
''' '''
run_test([cheetah_exe, "test"], cwd=ENV_NAME, expected=expected, env=env, expected_log_hash=expected_log_hash) run_test([cheetah_exe, "test"], cwd=ENV_NAME, expected=expected, env=env, expected_log_hash=expected_log_hash)
...@@ -247,6 +247,9 @@ for run_idx in xrange(1): ...@@ -247,6 +247,9 @@ for run_idx in xrange(1):
if (clsname == "SubclassGrowthTest" and t == "test_subclass"): if (clsname == "SubclassGrowthTest" and t == "test_subclass"):
continue continue
if (clsname == "ArgInspectionTest" and t == 'test_callable_argspec_py_builtin'):
continue
print "Running", t print "Running", t
n.setup() n.setup()
try: try:
......
class A(object):
def __eq__(self, rhs):
return True
class B(object):
def __eq__(self, lhs):
return False
print A() == B()
print B() == A()
print A() in [B()]
print B() in [A()]
print A() in (B(),)
print B() in (A(),)
print A() in {B(): 1}
print B() in {A(): 1}
print A() in {B()}
print B() in {A()}
...@@ -73,3 +73,8 @@ def f3(): ...@@ -73,3 +73,8 @@ def f3():
D.__get__ = get D.__get__ = get
print type(C()) print type(C())
f3() f3()
# misc tests:
import sys
sys.getrecursionlimit.__call__.__call__.__call__()
TypeError.__call__.__call__.__call__()
...@@ -93,7 +93,7 @@ for i in xrange(256): ...@@ -93,7 +93,7 @@ for i in xrange(256):
test(c) test(c)
test_is(c) test_is(c)
for j in xrange(i, 64): for j in xrange(i, 128):
test_is(c + chr(j)) test_is(c + chr(j))
try: try:
......
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