1
1
#pragma once
2
- // #include <string>
2
+ #include " ../pyref.hpp "
3
3
4
4
namespace cpp2py {
5
5
@@ -11,7 +11,7 @@ namespace cpp2py {
11
11
12
12
static bool is_convertible (PyObject *ob, bool raise_exception) {
13
13
if (PyUnicode_Check (ob) or PyUnicode_Check (ob)) return true ;
14
- if (raise_exception) { PyErr_SetString (PyExc_TypeError, " Cannot convert to string" ); }
14
+ if (raise_exception) { PyErr_SetString (PyExc_TypeError, ( " Cannot convert " s + to_string (ob) + " to string" s). c_str () ); }
15
15
return false ;
16
16
}
17
17
};
@@ -24,7 +24,7 @@ namespace cpp2py {
24
24
25
25
static bool is_convertible (PyObject *ob, bool raise_exception) {
26
26
if (PyUnicode_Check (ob) and PyUnicode_GET_LENGTH (ob) == 1 ) return true ;
27
- if (raise_exception) { PyErr_SetString (PyExc_TypeError, " Cannot convert to char" ); }
27
+ if (raise_exception) { PyErr_SetString (PyExc_TypeError, ( " Cannot convert " s + to_string (ob) + " to char" s). c_str () ); }
28
28
return false ;
29
29
}
30
30
};
@@ -37,7 +37,7 @@ namespace cpp2py {
37
37
38
38
static bool is_convertible (PyObject *ob, bool raise_exception) {
39
39
if (PyBytes_Check (ob) and PyBytes_Size (ob) == 1 ) return true ;
40
- if (raise_exception) { PyErr_SetString (PyExc_TypeError, " Cannot convert to unsigned char" ); }
40
+ if (raise_exception) { PyErr_SetString (PyExc_TypeError, ( " Cannot convert " s + to_string (ob) + " to unsigned char" s). c_str () ); }
41
41
return false ;
42
42
}
43
43
};
@@ -50,7 +50,7 @@ namespace cpp2py {
50
50
51
51
static bool is_convertible (PyObject *ob, bool raise_exception) {
52
52
if (PyUnicode_Check (ob)) return true ;
53
- if (raise_exception) { PyErr_SetString (PyExc_TypeError, " Cannot convert to string" ); }
53
+ if (raise_exception) { PyErr_SetString (PyExc_TypeError, ( " Cannot convert " s + to_string (ob) + " to string" s). c_str () ); }
54
54
return false ;
55
55
}
56
56
};
0 commit comments