mirror of
https://github.com/nasa/trick.git
synced 2024-12-19 21:27:54 +00:00
Fix filename output in attach_units for Python 3
This commit is contained in:
parent
9e5383bac0
commit
5027c02c51
@ -38,7 +38,12 @@ PyObject * attach_units(PyObject * in_units_obj , PyObject * in_object) {
|
||||
std::string file_name ;
|
||||
int line_no = 0 ;
|
||||
if (NULL != tstate && NULL != tstate->frame) {
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
PyObject * temp = PyUnicode_AsEncodedString(tstate->frame->f_code->co_filename, "utf-8", "Error ~");
|
||||
file_name = PyBytes_AS_STRING(temp) ;
|
||||
#else
|
||||
file_name = PyString_AsString(tstate->frame->f_code->co_filename);
|
||||
#endif
|
||||
#if (PY_MAJOR_VERSION == 2 ) && (PY_MINOR_VERSION <= 6)
|
||||
line_no = PyCode_Addr2Line(tstate->frame->f_code, tstate->frame->f_lasti) ;
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user