Commit bf4846a8 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge commit '02bd71' into refcounting

parents 8165581c 02bd71a8
......@@ -84,7 +84,7 @@ JitCodeBlock::JitCodeBlock(llvm::StringRef name)
int32_t* offset_ptr = (int32_t*)((uint8_t*)eh_frame_addr + 0x20);
int32_t* size_ptr = (int32_t*)((uint8_t*)eh_frame_addr + 0x24);
int64_t offset = (int8_t*)code.get() - (int8_t*)offset_ptr;
assert(offset >= INT_MIN && offset <= INT_MAX);
RELEASE_ASSERT(offset >= INT_MIN && offset <= INT_MAX, "");
*offset_ptr = offset;
*size_ptr = code_size;
......
......@@ -168,7 +168,7 @@ static void writeTrivialEhFrame(void* eh_frame_addr, void* func_addr, uint64_t f
int32_t* size_ptr = (int32_t*)((uint8_t*)eh_frame_addr + 0x24);
int64_t offset = (int8_t*)func_addr - (int8_t*)offset_ptr;
assert(offset >= INT_MIN && offset <= INT_MAX);
RELEASE_ASSERT(offset >= INT_MIN && offset <= INT_MAX, "");
*offset_ptr = offset;
assert(func_size <= UINT_MAX);
......
......@@ -3086,7 +3086,7 @@ static Box* typeName(Box* b, void*) {
}
static void typeSetName(Box* b, Box* v, void*) {
assert(b->cls == type_cls);
assert(PyType_Check(b));
BoxedClass* type = static_cast<BoxedClass*>(b);
// Awkward... in CPython you can only set __name__ for heaptype classes
......@@ -4047,6 +4047,7 @@ void setupRuntime() {
none_cls->giveAttr("__nonzero__", new BoxedFunction(FunctionMetadata::create((void*)noneNonzero, BOXED_BOOL, 1)));
none_cls->giveAttrBorrowed("__doc__", None);
none_cls->tp_hash = (hashfunc)_Py_HashPointer;
none_cls->tp_new = NULL; // don't allow creating instances
none_cls->freeze();
none_cls->tp_repr = none_repr;
......@@ -4345,24 +4346,25 @@ BoxedModule* createModule(BoxedString* name, const char* fn, const char* doc) no
BoxedDict* d = getSysModulesDict();
BoxedModule* module = NULL;
// Surprisingly, there are times that we need to return the existing module if
// one exists:
Box* existing = d->getOrNull(name);
if (existing && PyModule_Check(existing)) {
return static_cast<BoxedModule*>(existing);
module = static_cast<BoxedModule*>(existing);
Py_INCREF(module);
} else {
module = new BoxedModule();
autoDecref(moduleInit(module, name, autoDecref(boxString(doc ? doc : ""))));
d->d[incref(name)] = module;
}
BoxedModule* module = new BoxedModule();
autoDecref(moduleInit(module, name, autoDecref(boxString(doc ? doc : ""))));
if (fn)
module->giveAttr("__file__", boxString(fn));
Py_XDECREF(existing);
d->d[incref(name)] = module;
module->setattr(autoDecref(internStringMortal("__file__")), autoDecref(boxString(fn)), NULL);
if (name->s() == "__main__")
module->giveAttrBorrowed("__builtins__", builtins_module);
module->setattr(autoDecref(internStringMortal("__builtins__")), builtins_module, NULL);
return module;
}
......
......@@ -32,9 +32,10 @@ def install_and_test_lxml():
print "Applied lxml patch"
subprocess.check_call([PYTHON_EXE, "setup.py", "build_ext", "-i", "--with-cython"], cwd=LXML_DIR)
expected = [{'ran': 1381, 'failures': 28, 'errors': 5}]
run_test([PYTHON_EXE, "test.py"], cwd=LXML_DIR, expected=expected)
# We currently don't run the objectify tests because the assume that the python impl use refcounting.
expected = [{'ran': 1188, 'failures': 3, 'errors': 1}]
run_test([PYTHON_EXE, "test.py", "!.*test_objectify.py"], cwd=LXML_DIR, expected=expected)
create_virtenv(ENV_NAME, None, force_create = True)
install_and_test_lxml()
......@@ -54,3 +54,9 @@ print sorted.__name__
# should all fail:
set_name(sorted, "blah")
set_name(sorted, 5)
import abc
class D(C):
__metaclass__ = abc.ABCMeta
D.__name__ = "has_abc_meta"
print D
......@@ -35,3 +35,11 @@ def n(s):
return str(s).replace(".pyc", ".py")
print n(m), n(m.__name__), n(m.__file__), hasattr(m, "__path__")
import sys, types
name = "json"
m = sys.modules[name] = types.ModuleType(name)
print sorted(dir(m))
s = imp.find_module(name)
m = imp.load_module(name, *s)
print name in m.__file__, sorted(dir(m))
print None.__class__
print type(None).__doc__, None.__doc__
try:
type(None)()
except TypeError as e:
print e
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