Commit 23b021d8 authored by Marius Wachtler's avatar Marius Wachtler

Allow changing the name of types which have a different metaclass than type

parent 589e6a68
...@@ -84,7 +84,7 @@ JitCodeBlock::JitCodeBlock(llvm::StringRef name) ...@@ -84,7 +84,7 @@ JitCodeBlock::JitCodeBlock(llvm::StringRef name)
int32_t* offset_ptr = (int32_t*)((uint8_t*)eh_frame_addr + 0x20); int32_t* offset_ptr = (int32_t*)((uint8_t*)eh_frame_addr + 0x20);
int32_t* size_ptr = (int32_t*)((uint8_t*)eh_frame_addr + 0x24); int32_t* size_ptr = (int32_t*)((uint8_t*)eh_frame_addr + 0x24);
int64_t offset = (int8_t*)code.get() - (int8_t*)offset_ptr; 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; *offset_ptr = offset;
*size_ptr = code_size; *size_ptr = code_size;
......
...@@ -168,7 +168,7 @@ static void writeTrivialEhFrame(void* eh_frame_addr, void* func_addr, uint64_t f ...@@ -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); int32_t* size_ptr = (int32_t*)((uint8_t*)eh_frame_addr + 0x24);
int64_t offset = (int8_t*)func_addr - (int8_t*)offset_ptr; 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; *offset_ptr = offset;
assert(func_size <= UINT_MAX); assert(func_size <= UINT_MAX);
......
...@@ -3251,7 +3251,7 @@ static Box* typeName(Box* b, void*) { ...@@ -3251,7 +3251,7 @@ static Box* typeName(Box* b, void*) {
} }
static void typeSetName(Box* b, Box* v, void*) { static void typeSetName(Box* b, Box* v, void*) {
assert(b->cls == type_cls); assert(PyType_Check(b));
BoxedClass* type = static_cast<BoxedClass*>(b); BoxedClass* type = static_cast<BoxedClass*>(b);
// Awkward... in CPython you can only set __name__ for heaptype classes // Awkward... in CPython you can only set __name__ for heaptype classes
......
...@@ -54,3 +54,9 @@ print sorted.__name__ ...@@ -54,3 +54,9 @@ print sorted.__name__
# should all fail: # should all fail:
set_name(sorted, "blah") set_name(sorted, "blah")
set_name(sorted, 5) set_name(sorted, 5)
import abc
class D(C):
__metaclass__ = abc.ABCMeta
D.__name__ = "has_abc_meta"
print D
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