Itseez/opencv — pull request #1660 by prattmic (2013-10-22 00:18:35+00:00)
Title: Support Python 3 < version 3.3

In pycompat.hpp, PyUnicode_AsUTF8() is used to replace
PyString_AsString(), which is not available in Python 3. Unfortunately,
PyUnicode_AsUTF8() was only added in Python 3.3, and thus does not work
when building for Python 3.0, 3.1, or 3.2.

Add an additional check and #define to provide the PyString_AsString()
functionality in those versions of Python. Doing so requires two
function calls, as there is no direct replacement.

This patch is based on a very similar patch for llvmpy:
https://github.com/llvmpy/llvmpy/commit/e4996f02d7573cec9033acb65176196a370710c8