Skip to content

Commit

Permalink
Fix the incompatibility between Python2 and Python3.
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuchm committed Oct 12, 2017
1 parent 581f593 commit 75695aa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions python/sentencepiece.i
Expand Up @@ -5,6 +5,12 @@

%{
#include <sentencepiece_processor.h>
#if PY_VERSION_HEX >= 0x03000000
#undef PyString_Check
#define PyString_Check(name) PyUnicode_Check(name)
#define PyString_AsStringAndSize(obj, s, len) {*s = PyUnicode_AsUTF8AndSize(obj, len);}
#define PyString_FromStringAndSize(s, len) PyUnicode_FromStringAndSize(s, len)
#endif
%}

%ignore sentencepiece::SentencePieceProcessor::Encode(std::string const &, std::vector<std::string>*) const;
Expand Down
2 changes: 1 addition & 1 deletion python/sentencepiece.py
@@ -1,5 +1,5 @@
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 2.0.11
# Version 2.0.12
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
Expand Down
10 changes: 8 additions & 2 deletions python/sentencepiece_wrap.cxx
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 2.0.11
* Version 2.0.12
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
Expand Down Expand Up @@ -2964,7 +2964,7 @@ static swig_module_info swig_module = {swig_types, 5, 0, 0, 0, 0};
#endif
#define SWIG_name "_sentencepiece"

#define SWIGVERSION 0x020011
#define SWIGVERSION 0x020012
#define SWIG_VERSION SWIGVERSION


Expand Down Expand Up @@ -3038,6 +3038,12 @@ namespace swig {


#include <sentencepiece_processor.h>
#if PY_VERSION_HEX >= 0x03000000
#undef PyString_Check
#define PyString_Check(name) PyUnicode_Check(name)
#define PyString_AsStringAndSize(obj, s, len) {*s = PyUnicode_AsUTF8AndSize(obj, len);}
#define PyString_FromStringAndSize(s, len) PyUnicode_FromStringAndSize(s, len)
#endif


SWIGINTERNINLINE PyObject*
Expand Down

0 comments on commit 75695aa

Please sign in to comment.