Attempt to fix object code printing problem due to unicode
This commit is contained in:
parent
9df508f7c0
commit
0cccb3dec9
4 changed files with 16 additions and 6 deletions
|
|
@ -291,7 +291,13 @@ class TargetMachine(llvm.Wrapper):
|
|||
pm.add(api.llvm.DataLayout.new(str(self.target_data)))
|
||||
failed = self._ptr.addPassesToEmitFile(pm, os, cgft)
|
||||
pm.run(module)
|
||||
return os.str()
|
||||
|
||||
|
||||
CGFT = api.llvm.TargetMachine.CodeGenFileType
|
||||
if cgft == CGFT.CGFT_ObjectFile:
|
||||
return os.bytes()
|
||||
else:
|
||||
return os.str()
|
||||
|
||||
def emit_assembly(self, module):
|
||||
'''returns byte string of the module as assembly code of the target machine
|
||||
|
|
|
|||
|
|
@ -729,11 +729,7 @@ class TestNative(TestCase):
|
|||
|
||||
src = os.path.join(self.tmpdir, 'llvmobj.o')
|
||||
with open(src, 'wb') as fout:
|
||||
if is_py3k:
|
||||
fout.write(output.encode('utf-8'))
|
||||
else:
|
||||
fout.write(output)
|
||||
|
||||
fout.write(output)
|
||||
|
||||
self._compile(src)
|
||||
|
||||
|
|
|
|||
|
|
@ -209,6 +209,12 @@ static
|
|||
PyObject* py_str_from(const std::string &str){
|
||||
return PyString_FromStringAndSize(str.c_str(), str.size());
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
PyObject* py_bytes_from(const std::string &str){
|
||||
return PyBytes_FromStringAndSize(str.c_str(), str.size());
|
||||
}
|
||||
//
|
||||
//static
|
||||
//PyObject* py_str_from(const llvm::StringRef *str){
|
||||
|
|
|
|||
|
|
@ -15,4 +15,6 @@ class raw_svector_ostream:
|
|||
_base_ = raw_ostream
|
||||
|
||||
str = Method(cast(str, StringRef))
|
||||
bytes = Method(cast(bytes, StringRef))
|
||||
bytes.realname = 'str'
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue