Repository: opencv
Issue: Build fail on macOS 10.13 with python 3.7 binding 
Labels: bug,category: python bindings,category: build/install

- OpenCV => 4.0 - pre
- Operating System / Platform => macOS 10.13
- Compiler => Apple LLVM version 9.1.0 (clang-902.0.39.2)


##### Detailed description
```
[ 84%] Building CXX object modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.o
Buildfile: /Volumes/GDrive/git/opencv/build/java_test/build.xml
[ 84%] Building CXX object samples/cpp/CMakeFiles/example_tutorial_pnp_registration.dir/tutorial_code/calib3d/real_time_pose_estimation/src/main_registration.cpp.o
[ 84%] Building CXX object samples/cpp/CMakeFiles/example_tutorial_pnp_detection.dir/tutorial_code/calib3d/real_time_pose_estimation/src/main_detection.cpp.o

compile:
    [mkdir] Created dir: /Volumes/GDrive/git/opencv/build/java_test/build/classes
    [javac] Compiling 55 source files to /Volumes/GDrive/git/opencv/build/java_test/build/classes
/Volumes/GDrive/git/opencv/modules/python/src2/cv2.cpp:919:11: error: cannot initialize a variable of type
      'char *' with an rvalue of type 'const char *'
    char* str = PyString_AsString(obj);
          ^     ~~~~~~~~~~~~~~~~~~~~~~
[ 84%] Building CXX object samples/cpp/CMakeFiles/example_tutorial_pnp_registration.dir/tutorial_code/calib3d/real_time_pose_estimation/src/CsvReader.cpp.o
[ 84%] Building CXX object samples/cpp/CMakeFiles/example_tutorial_pnp_detection.dir/tutorial_code/calib3d/real_time_pose_estimation/src/CsvReader.cpp.o
```

##### Steps to reproduce
Following is my build configuration
```
cmake -D CMAKE_BUILD_TYPE=RELEASE \
 -D CMAKE_INSTALL_PREFIX=/usr/local \
 -D CMAKE_C_COMPILER=gcc \
 -D CMAKE_CXX_COMPILER=g++ \
 -D PYTHON_LIBRARY=/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib \
 -D PYTHON_INCLUDE_DIR=/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/include/python2.7 \
 -D PYTHON_PACKAGE_PATH=/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages \
 -D PYTHON_NUMPY_INCLUDE_DIRS=/usr/local/lib/python2.7/site-packages/numpy/core/include \
 -D PYTHON3_PACKAGE_PATH=/Users/Azhng/.virtual_env/keras/lib/python3.6/site-package\
 -D PYTHON3_LIBRARY=/usr/local/Cellar/python3/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7.dylib \
 -D PYTHON3_INCLUDE_DIR=/usr/local/Cellar/python3/3.7.0/Frameworks/Python.framework/Versions/3.7/include/python3.7m \
 -D PYTHON3_NUMPY_INCLUDE_DIRS=/usr/local/lib/python3.7/site-packages/numpy/core/include \
 -D BUILD_NEW_PYTHON_SUPPORT=ON \
 -D INSTALL_C_EXAMPLES=OFF \
 -D INSTALL_PYTHON_EXAMPLES=ON \
 -D BUILD_EXAMPLES=ON \
 -D BUILD_opencv_python3=ON \
 -D OPENCV_EXTRA_MODULES_PATH=/Volumes/GDrive/git/opencv_contrib/modules \
 -D WITH_TBB=ON \
 -D TBBROOT=/opt/intel/tbb \
 -D TBB_ENV_INCLUDE=/opt/intel/compilers_and_libraries_2018.1.126/mac/tbb/include \
 -D TBB_ENV_LIB=/opt/intel/compilers_and_libraries_2018.1.126/mac/tbb/lib/libtbb.dylib \
 -D OPENCL_INCLUDE_DIR=/System/Library/Frameworks/OpenCL.framework/Versions/A/Headers \
 -D OPENCL_LIBRARY=/System/Library/Frameworks/OpenCL.framework \
 -D WITH_IPP=ON \
 -D IPPROOT=/opt/intel/ipp \
 -D BUILD_DOCS=ON \
 -D WITH_EIGEN=ON \
 -D WITH_AVFOUNDATION=ON \
 -D WITH_GSTREAMER=ON \
 -D WITH_JASPER=ON \
 -D WITH_JPEG=ON \
 -D TINYDNN_ROOT=/Volumes/GDrive/git/tiny-dnn \
 -DTINYDNN_USE_SSE=ON \
 -DTINYDNN_USE_AVX=ON \
 -DENABLE_CXX11=ON \
 ..
```