Skip to content

Commit 3d8f4c9

Browse files
committed
Make it work when Python is compiled with Unicode disabled.
[SVN r31321]
1 parent 5597dcb commit 3d8f4c9

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

include/boost/python/converter/builtin_converters.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ BOOST_PYTHON_TO_PYTHON_BY_VALUE(unsigned BOOST_PYTHON_LONG_LONG, ::PyLong_FromUn
116116
BOOST_PYTHON_TO_PYTHON_BY_VALUE(char, converter::do_return_to_python(x))
117117
BOOST_PYTHON_TO_PYTHON_BY_VALUE(char const*, converter::do_return_to_python(x))
118118
BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::string, ::PyString_FromStringAndSize(x.data(),implicit_cast<int>(x.size())))
119-
# ifndef BOOST_NO_STD_WSTRING
119+
#if defined(Py_USING_UNICODE) && !defined(BOOST_NO_STD_WSTRING)
120120
BOOST_PYTHON_TO_PYTHON_BY_VALUE(std::wstring, ::PyUnicode_FromWideChar(x.data(),implicit_cast<int>(x.size())))
121121
# endif
122122
BOOST_PYTHON_TO_PYTHON_BY_VALUE(float, ::PyFloat_FromDouble(x))

src/converter/builtin_converters.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ namespace
278278
}
279279
};
280280

281+
#if defined(Py_USING_UNICODE) && !defined(BOOST_NO_STD_WSTRING)
281282
// encode_string_unaryfunc/py_encode_string -- manufacture a unaryfunc
282283
// "slot" which encodes a Python string using the default encoding
283284
extern "C" PyObject* encode_string_unaryfunc(PyObject* x)
@@ -286,8 +287,6 @@ namespace
286287
}
287288
unaryfunc py_encode_string = encode_string_unaryfunc;
288289

289-
290-
#ifndef BOOST_NO_STD_WSTRING
291290
// A SlotPolicy for extracting C++ strings from Python objects.
292291
struct wstring_rvalue_from_python
293292
{
@@ -411,8 +410,8 @@ void initialize_builtin_converters()
411410
// Add an lvalue converter for char which gets us char const*
412411
registry::insert(convert_to_cstring,type_id<char>());
413412

414-
# ifndef BOOST_NO_STD_WSTRING
415413
// Register by-value converters to std::string, std::wstring
414+
#if defined(Py_USING_UNICODE) && !defined(BOOST_NO_STD_WSTRING)
416415
slot_rvalue_from_python<std::wstring, wstring_rvalue_from_python>();
417416
# endif
418417
slot_rvalue_from_python<std::string, string_rvalue_from_python>();

0 commit comments

Comments
 (0)