From ecbcd1db7667608a50dd7155e6aa3fa85b903a58 Mon Sep 17 00:00:00 2001 From: Jim Easterbrook Date: Sat, 3 Aug 2024 13:27:53 +0100 Subject: [PATCH 01/10] Update documentation link in PyPI metadata --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2adcb7bc..04ef7ca7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ dynamic = ["version"] [project.urls] Homepage = "https://github.com/jim-easterbrook/python-exiv2" Changelog = "https://github.com/jim-easterbrook/python-exiv2/blob/main/CHANGELOG.txt" -Documentation = "https://github.com/jim-easterbrook/python-exiv2/blob/main/USAGE.rst" +Documentation = "https://python-exiv2.readthedocs.io/" [tool.setuptools] platforms = ["POSIX", "MacOS", "Windows"] From 86aaac9695d567eaa76c43bc77d0335744885844 Mon Sep 17 00:00:00 2001 From: Jim Easterbrook Date: Thu, 8 Aug 2024 11:51:06 +0100 Subject: [PATCH 02/10] Allow Linux libdir name to be 'lib64' or 'lib' --- setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.py b/setup.py index c8360ab0..8d5d0fa4 100644 --- a/setup.py +++ b/setup.py @@ -84,6 +84,8 @@ def get_mod_src_dir(exiv2_version): packages.append('exiv2.lib') if platform == 'linux': path = os.path.join(exiv2_root, 'lib64') + if not os.path.exists(path): + path = os.path.join(exiv2_root, 'lib') library_dirs = [path] package_dir['exiv2.lib'] = path package_data['exiv2.lib'] = [x for x in os.listdir(path) From 0c42f0216fc64a7500d3ba60ff23d9286b6c6da3 Mon Sep 17 00:00:00 2001 From: Jim Easterbrook Date: Wed, 18 Sep 2024 10:41:30 +0100 Subject: [PATCH 03/10] Test localised exception with non-ASCII characters --- tests/test_types.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_types.py b/tests/test_types.py index 8fc69daa..1e0a36e3 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -138,9 +138,9 @@ def test_localisation(self): self.assertEqual(cm.output, [ 'WARNING:exiv2:Ungültiger Zeichensatz: "invalid"']) with self.assertRaises(exiv2.Exiv2Error) as cm: - image = exiv2.ImageFactory.open(bytes()) + key = exiv2.ExifKey('not.a.tag') self.assertEqual(cm.exception.message, - 'Die Eingabedaten konnten nicht gelesen werden.') + "Ungültiger Schlüssel 'not.a.tag'") # clear locale name = 'en_US.UTF-8' os.environ['LC_ALL'] = name From 509d2d1936b4233418eda4d06939d2c24de0488e Mon Sep 17 00:00:00 2001 From: Jim Easterbrook Date: Wed, 18 Sep 2024 11:14:58 +0100 Subject: [PATCH 04/10] Split utf8_to_wcp function to forward & reverse This is clearer than passing an opaque boolean to set the direction. --- src/interface/error.i | 2 +- src/interface/shared/exception.i | 2 +- src/interface/shared/windows_cp.i | 25 +++++++++++++++------ src/interface/shared/windows_path.i | 6 ++--- src/swig-0_27_7/basicio_wrap.cxx | 29 ++++++++++++++++-------- src/swig-0_27_7/datasets_wrap.cxx | 27 +++++++++++++++------- src/swig-0_27_7/easyaccess_wrap.cxx | 27 +++++++++++++++------- src/swig-0_27_7/error_wrap.cxx | 27 +++++++++++++++------- src/swig-0_27_7/exif_wrap.cxx | 33 ++++++++++++++++++--------- src/swig-0_27_7/image_wrap.cxx | 35 +++++++++++++++++++---------- src/swig-0_27_7/iptc_wrap.cxx | 27 +++++++++++++++------- src/swig-0_27_7/metadatum_wrap.cxx | 27 +++++++++++++++------- src/swig-0_27_7/preview_wrap.cxx | 31 ++++++++++++++++--------- src/swig-0_27_7/properties_wrap.cxx | 27 +++++++++++++++------- src/swig-0_27_7/tags_wrap.cxx | 27 +++++++++++++++------- src/swig-0_27_7/types_wrap.cxx | 27 +++++++++++++++------- src/swig-0_27_7/value_wrap.cxx | 27 +++++++++++++++------- src/swig-0_27_7/version_wrap.cxx | 27 +++++++++++++++------- src/swig-0_27_7/xmp_wrap.cxx | 27 +++++++++++++++------- src/swig-0_28_3/basicio_wrap.cxx | 27 +++++++++++++++------- src/swig-0_28_3/datasets_wrap.cxx | 25 +++++++++++++++------ src/swig-0_28_3/easyaccess_wrap.cxx | 25 +++++++++++++++------ src/swig-0_28_3/error_wrap.cxx | 27 +++++++++++++++------- src/swig-0_28_3/exif_wrap.cxx | 31 ++++++++++++++++--------- src/swig-0_28_3/image_wrap.cxx | 33 ++++++++++++++++++--------- src/swig-0_28_3/iptc_wrap.cxx | 25 +++++++++++++++------ src/swig-0_28_3/metadatum_wrap.cxx | 25 +++++++++++++++------ src/swig-0_28_3/preview_wrap.cxx | 29 ++++++++++++++++-------- src/swig-0_28_3/properties_wrap.cxx | 25 +++++++++++++++------ src/swig-0_28_3/tags_wrap.cxx | 25 +++++++++++++++------ src/swig-0_28_3/types_wrap.cxx | 25 +++++++++++++++------ src/swig-0_28_3/value_wrap.cxx | 25 +++++++++++++++------ src/swig-0_28_3/version_wrap.cxx | 25 +++++++++++++++------ src/swig-0_28_3/xmp_wrap.cxx | 25 +++++++++++++++------ 34 files changed, 599 insertions(+), 258 deletions(-) diff --git a/src/interface/error.i b/src/interface/error.i index 59e637bd..83fd2645 100644 --- a/src/interface/error.i +++ b/src/interface/error.i @@ -39,7 +39,7 @@ static PyObject* logger = NULL; static void log_to_python(int level, const char* msg) { std::string copy = msg; - utf8_to_wcp(©, false); + wcp_to_utf8(©); Py_ssize_t len = copy.size(); while (len > 0 && copy[len-1] == '\n') len--; diff --git a/src/interface/shared/exception.i b/src/interface/shared/exception.i index 64d200b5..e7c3b657 100644 --- a/src/interface/shared/exception.i +++ b/src/interface/shared/exception.i @@ -47,7 +47,7 @@ static void _set_python_exception() { #if EXIV2_VERSION_HEX < 0x001c0000 catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - utf8_to_wcp(&msg, false); + wcp_to_utf8(&msg); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); diff --git a/src/interface/shared/windows_cp.i b/src/interface/shared/windows_cp.i index 6ee6db2f..4bd6ad16 100644 --- a/src/interface/shared/windows_cp.i +++ b/src/interface/shared/windows_cp.i @@ -22,16 +22,10 @@ #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -49,7 +43,24 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; #endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else return 0; +#endif }; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else + return 0; +#endif +}; + %} diff --git a/src/interface/shared/windows_path.i b/src/interface/shared/windows_path.i index be5fb7f0..8b4a82ad 100644 --- a/src/interface/shared/windows_path.i +++ b/src/interface/shared/windows_path.i @@ -22,7 +22,7 @@ %define WINDOWS_PATH(signature) %typemap(check, fragment="utf8_to_wcp") signature { %#ifdef _WIN32 - if (utf8_to_wcp($1, true) < 0) { + if (utf8_to_wcp($1) < 0) { SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); } %#endif @@ -33,7 +33,7 @@ %define WINDOWS_PATH_OUT(function) %typemap(out, fragment="utf8_to_wcp") std::string function { %#ifdef _WIN32 - if (utf8_to_wcp(&$1, false) < 0) { + if (wcp_to_utf8(&$1) < 0) { SWIG_exception_fail(SWIG_ValueError, "failed to transcode result"); } %#endif @@ -42,7 +42,7 @@ %typemap(out, fragment="utf8_to_wcp") const std::string& function { std::string copy = *$1; %#ifdef _WIN32 - if (utf8_to_wcp(©, false) < 0) { + if (wcp_to_utf8(©) < 0) { SWIG_exception_fail(SWIG_ValueError, "failed to transcode result"); } %#endif diff --git a/src/swig-0_27_7/basicio_wrap.cxx b/src/swig-0_27_7/basicio_wrap.cxx index bf85abe6..8f6ba533 100644 --- a/src/swig-0_27_7/basicio_wrap.cxx +++ b/src/swig-0_27_7/basicio_wrap.cxx @@ -4200,16 +4200,10 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4227,11 +4221,28 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static void _set_python_exception() { try { throw; @@ -4239,7 +4250,7 @@ static void _set_python_exception() { catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - utf8_to_wcp(&msg, false); + wcp_to_utf8(&msg); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); @@ -5524,7 +5535,7 @@ SWIGINTERN PyObject *_wrap_BasicIo_path(PyObject *self, PyObject *args) { result = ((Exiv2::BasicIo const *)arg1)->path(); { #ifdef _WIN32 - if (utf8_to_wcp(&result, false) < 0) { + if (wcp_to_utf8(&result) < 0) { SWIG_exception_fail(SWIG_ValueError, "failed to transcode result"); } #endif diff --git a/src/swig-0_27_7/datasets_wrap.cxx b/src/swig-0_27_7/datasets_wrap.cxx index edf06adc..aa2f908b 100644 --- a/src/swig-0_27_7/datasets_wrap.cxx +++ b/src/swig-0_27_7/datasets_wrap.cxx @@ -4222,16 +4222,10 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4249,11 +4243,28 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static void _set_python_exception() { try { throw; @@ -4261,7 +4272,7 @@ static void _set_python_exception() { catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - utf8_to_wcp(&msg, false); + wcp_to_utf8(&msg); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); diff --git a/src/swig-0_27_7/easyaccess_wrap.cxx b/src/swig-0_27_7/easyaccess_wrap.cxx index 076fb405..c5e77087 100644 --- a/src/swig-0_27_7/easyaccess_wrap.cxx +++ b/src/swig-0_27_7/easyaccess_wrap.cxx @@ -4178,16 +4178,10 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4205,11 +4199,28 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static void _set_python_exception() { try { throw; @@ -4217,7 +4228,7 @@ static void _set_python_exception() { catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - utf8_to_wcp(&msg, false); + wcp_to_utf8(&msg); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); diff --git a/src/swig-0_27_7/error_wrap.cxx b/src/swig-0_27_7/error_wrap.cxx index 28ae65b2..aeda023c 100644 --- a/src/swig-0_27_7/error_wrap.cxx +++ b/src/swig-0_27_7/error_wrap.cxx @@ -4149,16 +4149,10 @@ static PyObject* exiv2_module = NULL; #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4176,15 +4170,32 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static PyObject* logger = NULL; static void log_to_python(int level, const char* msg) { std::string copy = msg; - utf8_to_wcp(©, false); + wcp_to_utf8(©); Py_ssize_t len = copy.size(); while (len > 0 && copy[len-1] == '\n') len--; diff --git a/src/swig-0_27_7/exif_wrap.cxx b/src/swig-0_27_7/exif_wrap.cxx index 058a6bb8..d63f9cb8 100644 --- a/src/swig-0_27_7/exif_wrap.cxx +++ b/src/swig-0_27_7/exif_wrap.cxx @@ -4238,16 +4238,10 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4265,11 +4259,28 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static void _set_python_exception() { try { throw; @@ -4277,7 +4288,7 @@ static void _set_python_exception() { catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - utf8_to_wcp(&msg, false); + wcp_to_utf8(&msg); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); @@ -8651,7 +8662,7 @@ SWIGINTERN PyObject *_wrap_ExifThumbC_writeFile(PyObject *self, PyObject *args) } { #ifdef _WIN32 - if (utf8_to_wcp(arg2, true) < 0) { + if (utf8_to_wcp(arg2) < 0) { SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); } #endif @@ -8865,7 +8876,7 @@ SWIGINTERN PyObject *_wrap_ExifThumb_setJpegThumbnail__SWIG_0(PyObject *self, Py arg5 = static_cast< uint16_t >(val5); { #ifdef _WIN32 - if (utf8_to_wcp(arg2, true) < 0) { + if (utf8_to_wcp(arg2) < 0) { SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); } #endif @@ -9000,7 +9011,7 @@ SWIGINTERN PyObject *_wrap_ExifThumb_setJpegThumbnail__SWIG_2(PyObject *self, Py } { #ifdef _WIN32 - if (utf8_to_wcp(arg2, true) < 0) { + if (utf8_to_wcp(arg2) < 0) { SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); } #endif diff --git a/src/swig-0_27_7/image_wrap.cxx b/src/swig-0_27_7/image_wrap.cxx index 3fc7b448..dd431a56 100644 --- a/src/swig-0_27_7/image_wrap.cxx +++ b/src/swig-0_27_7/image_wrap.cxx @@ -4251,16 +4251,10 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4278,11 +4272,28 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static void _set_python_exception() { try { throw; @@ -4290,7 +4301,7 @@ static void _set_python_exception() { catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - utf8_to_wcp(&msg, false); + wcp_to_utf8(&msg); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); @@ -6342,7 +6353,7 @@ SWIGINTERN PyObject *_wrap_ImageFactory_createIo__SWIG_0(PyObject *self, Py_ssiz } { #ifdef _WIN32 - if (utf8_to_wcp(arg1, true) < 0) { + if (utf8_to_wcp(arg1) < 0) { SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); } #endif @@ -6400,7 +6411,7 @@ SWIGINTERN PyObject *_wrap_ImageFactory_open__SWIG_0(PyObject *self, Py_ssize_t } { #ifdef _WIN32 - if (utf8_to_wcp(arg1, true) < 0) { + if (utf8_to_wcp(arg1) < 0) { SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); } #endif @@ -6550,7 +6561,7 @@ SWIGINTERN PyObject *_wrap_ImageFactory_create__SWIG_0(PyObject *self, Py_ssize_ } { #ifdef _WIN32 - if (utf8_to_wcp(arg2, true) < 0) { + if (utf8_to_wcp(arg2) < 0) { SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); } #endif @@ -6669,7 +6680,7 @@ SWIGINTERN PyObject *_wrap_ImageFactory_getType__SWIG_0(PyObject *self, Py_ssize } { #ifdef _WIN32 - if (utf8_to_wcp(arg1, true) < 0) { + if (utf8_to_wcp(arg1) < 0) { SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); } #endif diff --git a/src/swig-0_27_7/iptc_wrap.cxx b/src/swig-0_27_7/iptc_wrap.cxx index 80e90272..d643dfc2 100644 --- a/src/swig-0_27_7/iptc_wrap.cxx +++ b/src/swig-0_27_7/iptc_wrap.cxx @@ -4236,16 +4236,10 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4263,11 +4257,28 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static void _set_python_exception() { try { throw; @@ -4275,7 +4286,7 @@ static void _set_python_exception() { catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - utf8_to_wcp(&msg, false); + wcp_to_utf8(&msg); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); diff --git a/src/swig-0_27_7/metadatum_wrap.cxx b/src/swig-0_27_7/metadatum_wrap.cxx index 2c6c1a1d..0778e3c6 100644 --- a/src/swig-0_27_7/metadatum_wrap.cxx +++ b/src/swig-0_27_7/metadatum_wrap.cxx @@ -4222,16 +4222,10 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4249,11 +4243,28 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static void _set_python_exception() { try { throw; @@ -4261,7 +4272,7 @@ static void _set_python_exception() { catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - utf8_to_wcp(&msg, false); + wcp_to_utf8(&msg); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); diff --git a/src/swig-0_27_7/preview_wrap.cxx b/src/swig-0_27_7/preview_wrap.cxx index d4e0f000..bfba5d8a 100644 --- a/src/swig-0_27_7/preview_wrap.cxx +++ b/src/swig-0_27_7/preview_wrap.cxx @@ -4406,16 +4406,10 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4433,11 +4427,28 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static void _set_python_exception() { try { throw; @@ -4445,7 +4456,7 @@ static void _set_python_exception() { catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - utf8_to_wcp(&msg, false); + wcp_to_utf8(&msg); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); @@ -6388,7 +6399,7 @@ SWIGINTERN PyObject *_wrap_PreviewImage_writeFile(PyObject *self, PyObject *args } { #ifdef _WIN32 - if (utf8_to_wcp(arg2, true) < 0) { + if (utf8_to_wcp(arg2) < 0) { SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); } #endif @@ -6452,7 +6463,7 @@ SWIGINTERN PyObject *_wrap_PreviewImage_extension(PyObject *self, PyObject *args result = ((Exiv2::PreviewImage const *)arg1)->extension(); { #ifdef _WIN32 - if (utf8_to_wcp(&result, false) < 0) { + if (wcp_to_utf8(&result) < 0) { SWIG_exception_fail(SWIG_ValueError, "failed to transcode result"); } #endif diff --git a/src/swig-0_27_7/properties_wrap.cxx b/src/swig-0_27_7/properties_wrap.cxx index b65e1c61..78b12d1e 100644 --- a/src/swig-0_27_7/properties_wrap.cxx +++ b/src/swig-0_27_7/properties_wrap.cxx @@ -4224,16 +4224,10 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4251,11 +4245,28 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static void _set_python_exception() { try { throw; @@ -4263,7 +4274,7 @@ static void _set_python_exception() { catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - utf8_to_wcp(&msg, false); + wcp_to_utf8(&msg); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); diff --git a/src/swig-0_27_7/tags_wrap.cxx b/src/swig-0_27_7/tags_wrap.cxx index d06a3f51..21f19d50 100644 --- a/src/swig-0_27_7/tags_wrap.cxx +++ b/src/swig-0_27_7/tags_wrap.cxx @@ -4224,16 +4224,10 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4251,11 +4245,28 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static void _set_python_exception() { try { throw; @@ -4263,7 +4274,7 @@ static void _set_python_exception() { catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - utf8_to_wcp(&msg, false); + wcp_to_utf8(&msg); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); diff --git a/src/swig-0_27_7/types_wrap.cxx b/src/swig-0_27_7/types_wrap.cxx index 092f8759..f2f267cd 100644 --- a/src/swig-0_27_7/types_wrap.cxx +++ b/src/swig-0_27_7/types_wrap.cxx @@ -4210,16 +4210,10 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4237,11 +4231,28 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static void _set_python_exception() { try { throw; @@ -4249,7 +4260,7 @@ static void _set_python_exception() { catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - utf8_to_wcp(&msg, false); + wcp_to_utf8(&msg); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); diff --git a/src/swig-0_27_7/value_wrap.cxx b/src/swig-0_27_7/value_wrap.cxx index bcf0f5ea..d491aec9 100644 --- a/src/swig-0_27_7/value_wrap.cxx +++ b/src/swig-0_27_7/value_wrap.cxx @@ -4394,16 +4394,10 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4421,11 +4415,28 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static void _set_python_exception() { try { throw; @@ -4433,7 +4444,7 @@ static void _set_python_exception() { catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - utf8_to_wcp(&msg, false); + wcp_to_utf8(&msg); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); diff --git a/src/swig-0_27_7/version_wrap.cxx b/src/swig-0_27_7/version_wrap.cxx index f5f35efc..c25a7f90 100644 --- a/src/swig-0_27_7/version_wrap.cxx +++ b/src/swig-0_27_7/version_wrap.cxx @@ -4190,16 +4190,10 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4217,11 +4211,28 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static void _set_python_exception() { try { throw; @@ -4229,7 +4240,7 @@ static void _set_python_exception() { catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - utf8_to_wcp(&msg, false); + wcp_to_utf8(&msg); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); diff --git a/src/swig-0_27_7/xmp_wrap.cxx b/src/swig-0_27_7/xmp_wrap.cxx index d1bd1e2b..30e2902a 100644 --- a/src/swig-0_27_7/xmp_wrap.cxx +++ b/src/swig-0_27_7/xmp_wrap.cxx @@ -4238,16 +4238,10 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4265,11 +4259,28 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static void _set_python_exception() { try { throw; @@ -4277,7 +4288,7 @@ static void _set_python_exception() { catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - utf8_to_wcp(&msg, false); + wcp_to_utf8(&msg); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); diff --git a/src/swig-0_28_3/basicio_wrap.cxx b/src/swig-0_28_3/basicio_wrap.cxx index 2b2ed8a1..cf74b4bf 100644 --- a/src/swig-0_28_3/basicio_wrap.cxx +++ b/src/swig-0_28_3/basicio_wrap.cxx @@ -4201,16 +4201,10 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4228,11 +4222,28 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static void _set_python_exception() { try { throw; @@ -5792,7 +5803,7 @@ SWIGINTERN PyObject *_wrap_BasicIo_path(PyObject *self, PyObject *args) { { std::string copy = *result; #ifdef _WIN32 - if (utf8_to_wcp(©, false) < 0) { + if (wcp_to_utf8(©) < 0) { SWIG_exception_fail(SWIG_ValueError, "failed to transcode result"); } #endif diff --git a/src/swig-0_28_3/datasets_wrap.cxx b/src/swig-0_28_3/datasets_wrap.cxx index 0f8e68af..82f349a2 100644 --- a/src/swig-0_28_3/datasets_wrap.cxx +++ b/src/swig-0_28_3/datasets_wrap.cxx @@ -4222,16 +4222,10 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4249,11 +4243,28 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static void _set_python_exception() { try { throw; diff --git a/src/swig-0_28_3/easyaccess_wrap.cxx b/src/swig-0_28_3/easyaccess_wrap.cxx index dc975d72..ed08ab02 100644 --- a/src/swig-0_28_3/easyaccess_wrap.cxx +++ b/src/swig-0_28_3/easyaccess_wrap.cxx @@ -4178,16 +4178,10 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4205,11 +4199,28 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static void _set_python_exception() { try { throw; diff --git a/src/swig-0_28_3/error_wrap.cxx b/src/swig-0_28_3/error_wrap.cxx index bb7c1323..e41bfa9b 100644 --- a/src/swig-0_28_3/error_wrap.cxx +++ b/src/swig-0_28_3/error_wrap.cxx @@ -4149,16 +4149,10 @@ static PyObject* exiv2_module = NULL; #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4176,15 +4170,32 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static PyObject* logger = NULL; static void log_to_python(int level, const char* msg) { std::string copy = msg; - utf8_to_wcp(©, false); + wcp_to_utf8(©); Py_ssize_t len = copy.size(); while (len > 0 && copy[len-1] == '\n') len--; diff --git a/src/swig-0_28_3/exif_wrap.cxx b/src/swig-0_28_3/exif_wrap.cxx index a3714137..646fb638 100644 --- a/src/swig-0_28_3/exif_wrap.cxx +++ b/src/swig-0_28_3/exif_wrap.cxx @@ -4238,16 +4238,10 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4265,11 +4259,28 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static void _set_python_exception() { try { throw; @@ -8855,7 +8866,7 @@ SWIGINTERN PyObject *_wrap_ExifThumbC_writeFile(PyObject *self, PyObject *args) } { #ifdef _WIN32 - if (utf8_to_wcp(arg2, true) < 0) { + if (utf8_to_wcp(arg2) < 0) { SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); } #endif @@ -9069,7 +9080,7 @@ SWIGINTERN PyObject *_wrap_ExifThumb_setJpegThumbnail__SWIG_0(PyObject *self, Py arg5 = static_cast< uint16_t >(val5); { #ifdef _WIN32 - if (utf8_to_wcp(arg2, true) < 0) { + if (utf8_to_wcp(arg2) < 0) { SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); } #endif @@ -9204,7 +9215,7 @@ SWIGINTERN PyObject *_wrap_ExifThumb_setJpegThumbnail__SWIG_2(PyObject *self, Py } { #ifdef _WIN32 - if (utf8_to_wcp(arg2, true) < 0) { + if (utf8_to_wcp(arg2) < 0) { SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); } #endif diff --git a/src/swig-0_28_3/image_wrap.cxx b/src/swig-0_28_3/image_wrap.cxx index 85ebfa70..8fb69724 100644 --- a/src/swig-0_28_3/image_wrap.cxx +++ b/src/swig-0_28_3/image_wrap.cxx @@ -4251,16 +4251,10 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4278,11 +4272,28 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static void _set_python_exception() { try { throw; @@ -6342,7 +6353,7 @@ SWIGINTERN PyObject *_wrap_ImageFactory_createIo__SWIG_0(PyObject *self, Py_ssiz } { #ifdef _WIN32 - if (utf8_to_wcp(arg1, true) < 0) { + if (utf8_to_wcp(arg1) < 0) { SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); } #endif @@ -6400,7 +6411,7 @@ SWIGINTERN PyObject *_wrap_ImageFactory_open__SWIG_0(PyObject *self, Py_ssize_t } { #ifdef _WIN32 - if (utf8_to_wcp(arg1, true) < 0) { + if (utf8_to_wcp(arg1) < 0) { SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); } #endif @@ -6550,7 +6561,7 @@ SWIGINTERN PyObject *_wrap_ImageFactory_create__SWIG_0(PyObject *self, Py_ssize_ } { #ifdef _WIN32 - if (utf8_to_wcp(arg2, true) < 0) { + if (utf8_to_wcp(arg2) < 0) { SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); } #endif @@ -6673,7 +6684,7 @@ SWIGINTERN PyObject *_wrap_ImageFactory_getType__SWIG_0(PyObject *self, Py_ssize } { #ifdef _WIN32 - if (utf8_to_wcp(arg1, true) < 0) { + if (utf8_to_wcp(arg1) < 0) { SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); } #endif diff --git a/src/swig-0_28_3/iptc_wrap.cxx b/src/swig-0_28_3/iptc_wrap.cxx index 266c64a4..ac30d003 100644 --- a/src/swig-0_28_3/iptc_wrap.cxx +++ b/src/swig-0_28_3/iptc_wrap.cxx @@ -4236,16 +4236,10 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4263,11 +4257,28 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static void _set_python_exception() { try { throw; diff --git a/src/swig-0_28_3/metadatum_wrap.cxx b/src/swig-0_28_3/metadatum_wrap.cxx index 0ac31978..820541b7 100644 --- a/src/swig-0_28_3/metadatum_wrap.cxx +++ b/src/swig-0_28_3/metadatum_wrap.cxx @@ -4222,16 +4222,10 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4249,11 +4243,28 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static void _set_python_exception() { try { throw; diff --git a/src/swig-0_28_3/preview_wrap.cxx b/src/swig-0_28_3/preview_wrap.cxx index a54273ca..4ac0e578 100644 --- a/src/swig-0_28_3/preview_wrap.cxx +++ b/src/swig-0_28_3/preview_wrap.cxx @@ -4406,16 +4406,10 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4433,11 +4427,28 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static void _set_python_exception() { try { throw; @@ -6388,7 +6399,7 @@ SWIGINTERN PyObject *_wrap_PreviewImage_writeFile(PyObject *self, PyObject *args } { #ifdef _WIN32 - if (utf8_to_wcp(arg2, true) < 0) { + if (utf8_to_wcp(arg2) < 0) { SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); } #endif @@ -6452,7 +6463,7 @@ SWIGINTERN PyObject *_wrap_PreviewImage_extension(PyObject *self, PyObject *args result = ((Exiv2::PreviewImage const *)arg1)->extension(); { #ifdef _WIN32 - if (utf8_to_wcp(&result, false) < 0) { + if (wcp_to_utf8(&result) < 0) { SWIG_exception_fail(SWIG_ValueError, "failed to transcode result"); } #endif diff --git a/src/swig-0_28_3/properties_wrap.cxx b/src/swig-0_28_3/properties_wrap.cxx index b5b85d45..dcab1cbb 100644 --- a/src/swig-0_28_3/properties_wrap.cxx +++ b/src/swig-0_28_3/properties_wrap.cxx @@ -4224,16 +4224,10 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4251,11 +4245,28 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static void _set_python_exception() { try { throw; diff --git a/src/swig-0_28_3/tags_wrap.cxx b/src/swig-0_28_3/tags_wrap.cxx index c34aa9ed..e2c1360d 100644 --- a/src/swig-0_28_3/tags_wrap.cxx +++ b/src/swig-0_28_3/tags_wrap.cxx @@ -4224,16 +4224,10 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4251,11 +4245,28 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static void _set_python_exception() { try { throw; diff --git a/src/swig-0_28_3/types_wrap.cxx b/src/swig-0_28_3/types_wrap.cxx index 7569ad2d..106d5823 100644 --- a/src/swig-0_28_3/types_wrap.cxx +++ b/src/swig-0_28_3/types_wrap.cxx @@ -4210,16 +4210,10 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4237,11 +4231,28 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static void _set_python_exception() { try { throw; diff --git a/src/swig-0_28_3/value_wrap.cxx b/src/swig-0_28_3/value_wrap.cxx index 9afc3fc7..5306e69b 100644 --- a/src/swig-0_28_3/value_wrap.cxx +++ b/src/swig-0_28_3/value_wrap.cxx @@ -4394,16 +4394,10 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4421,11 +4415,28 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static void _set_python_exception() { try { throw; diff --git a/src/swig-0_28_3/version_wrap.cxx b/src/swig-0_28_3/version_wrap.cxx index c13df2fa..0a39af67 100644 --- a/src/swig-0_28_3/version_wrap.cxx +++ b/src/swig-0_28_3/version_wrap.cxx @@ -4190,16 +4190,10 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4217,11 +4211,28 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static void _set_python_exception() { try { throw; diff --git a/src/swig-0_28_3/xmp_wrap.cxx b/src/swig-0_28_3/xmp_wrap.cxx index e344c9dc..e4ca5694 100644 --- a/src/swig-0_28_3/xmp_wrap.cxx +++ b/src/swig-0_28_3/xmp_wrap.cxx @@ -4238,16 +4238,10 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { #include #endif -static int utf8_to_wcp(std::string *str, bool to_cp) { #ifdef _WIN32 - UINT cp_in = CP_UTF8; - UINT cp_out = GetACP(); +static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - if (!to_cp) { - cp_in = cp_out; - cp_out = CP_UTF8; - } int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) @@ -4265,11 +4259,28 @@ static int utf8_to_wcp(std::string *str, bool to_cp) { if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return -1; + return 0; +}; +#endif + +static int utf8_to_wcp(std::string *str) { +#ifdef _WIN32 + return _transcode(str, CP_UTF8, GetACP()); +#else + return 0; #endif +}; + +static int wcp_to_utf8(std::string *str) { +#ifdef _WIN32 + return _transcode(str, GetACP(), CP_UTF8); +#else return 0; +#endif }; + static void _set_python_exception() { try { throw; From 055f296130c39a71d06e8e958639826e3d377cdf Mon Sep 17 00:00:00 2001 From: Jim Easterbrook Date: Wed, 18 Sep 2024 11:41:23 +0100 Subject: [PATCH 05/10] Improved error handling in Windows CP<->utf8 --- src/interface/error.i | 3 ++- src/interface/shared/exception.i | 3 ++- src/interface/shared/windows_cp.i | 8 +++---- src/interface/shared/windows_path.i | 18 ++++++++++----- src/swig-0_27_7/basicio_wrap.cxx | 17 ++++++++------ src/swig-0_27_7/datasets_wrap.cxx | 11 ++++----- src/swig-0_27_7/easyaccess_wrap.cxx | 11 ++++----- src/swig-0_27_7/error_wrap.cxx | 11 ++++----- src/swig-0_27_7/exif_wrap.cxx | 29 +++++++++++++++--------- src/swig-0_27_7/image_wrap.cxx | 35 ++++++++++++++++++----------- src/swig-0_27_7/iptc_wrap.cxx | 11 ++++----- src/swig-0_27_7/metadatum_wrap.cxx | 11 ++++----- src/swig-0_27_7/preview_wrap.cxx | 23 +++++++++++-------- src/swig-0_27_7/properties_wrap.cxx | 11 ++++----- src/swig-0_27_7/tags_wrap.cxx | 11 ++++----- src/swig-0_27_7/types_wrap.cxx | 11 ++++----- src/swig-0_27_7/value_wrap.cxx | 11 ++++----- src/swig-0_27_7/version_wrap.cxx | 11 ++++----- src/swig-0_27_7/xmp_wrap.cxx | 11 ++++----- src/swig-0_28_3/basicio_wrap.cxx | 15 ++++++++----- src/swig-0_28_3/datasets_wrap.cxx | 9 ++++---- src/swig-0_28_3/easyaccess_wrap.cxx | 9 ++++---- src/swig-0_28_3/error_wrap.cxx | 11 ++++----- src/swig-0_28_3/exif_wrap.cxx | 27 +++++++++++++--------- src/swig-0_28_3/image_wrap.cxx | 33 +++++++++++++++++---------- src/swig-0_28_3/iptc_wrap.cxx | 9 ++++---- src/swig-0_28_3/metadatum_wrap.cxx | 9 ++++---- src/swig-0_28_3/preview_wrap.cxx | 21 ++++++++++------- src/swig-0_28_3/properties_wrap.cxx | 9 ++++---- src/swig-0_28_3/tags_wrap.cxx | 9 ++++---- src/swig-0_28_3/types_wrap.cxx | 9 ++++---- src/swig-0_28_3/value_wrap.cxx | 9 ++++---- src/swig-0_28_3/version_wrap.cxx | 9 ++++---- src/swig-0_28_3/xmp_wrap.cxx | 9 ++++---- 34 files changed, 266 insertions(+), 188 deletions(-) diff --git a/src/interface/error.i b/src/interface/error.i index 83fd2645..a8d07b28 100644 --- a/src/interface/error.i +++ b/src/interface/error.i @@ -39,7 +39,8 @@ static PyObject* logger = NULL; static void log_to_python(int level, const char* msg) { std::string copy = msg; - wcp_to_utf8(©); + if (wcp_to_utf8(©)) + copy = msg; Py_ssize_t len = copy.size(); while (len > 0 && copy[len-1] == '\n') len--; diff --git a/src/interface/shared/exception.i b/src/interface/shared/exception.i index e7c3b657..9dff3c6d 100644 --- a/src/interface/shared/exception.i +++ b/src/interface/shared/exception.i @@ -47,7 +47,8 @@ static void _set_python_exception() { #if EXIV2_VERSION_HEX < 0x001c0000 catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - wcp_to_utf8(&msg); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); diff --git a/src/interface/shared/windows_cp.i b/src/interface/shared/windows_cp.i index 4bd6ad16..709774d7 100644 --- a/src/interface/shared/windows_cp.i +++ b/src/interface/shared/windows_cp.i @@ -29,20 +29,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif diff --git a/src/interface/shared/windows_path.i b/src/interface/shared/windows_path.i index 8b4a82ad..d36e2696 100644 --- a/src/interface/shared/windows_path.i +++ b/src/interface/shared/windows_path.i @@ -22,8 +22,10 @@ %define WINDOWS_PATH(signature) %typemap(check, fragment="utf8_to_wcp") signature { %#ifdef _WIN32 - if (utf8_to_wcp($1) < 0) { - SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); + int error = utf8_to_wcp($1); + if (error) { + PyErr_SetFromWindowsErr(error); + SWIG_fail; } %#endif } @@ -33,8 +35,10 @@ %define WINDOWS_PATH_OUT(function) %typemap(out, fragment="utf8_to_wcp") std::string function { %#ifdef _WIN32 - if (wcp_to_utf8(&$1) < 0) { - SWIG_exception_fail(SWIG_ValueError, "failed to transcode result"); + int error = wcp_to_utf8(&$1); + if (error) { + PyErr_SetFromWindowsErr(error); + SWIG_fail; } %#endif $result = SWIG_FromCharPtrAndSize($1.data(), $1.size()); @@ -42,8 +46,10 @@ %typemap(out, fragment="utf8_to_wcp") const std::string& function { std::string copy = *$1; %#ifdef _WIN32 - if (wcp_to_utf8(©) < 0) { - SWIG_exception_fail(SWIG_ValueError, "failed to transcode result"); + int error = wcp_to_utf8(©); + if (error) { + PyErr_SetFromWindowsErr(error); + SWIG_fail; } %#endif $result = SWIG_FromCharPtrAndSize(copy.data(), copy.size()); diff --git a/src/swig-0_27_7/basicio_wrap.cxx b/src/swig-0_27_7/basicio_wrap.cxx index 8f6ba533..8c87bd21 100644 --- a/src/swig-0_27_7/basicio_wrap.cxx +++ b/src/swig-0_27_7/basicio_wrap.cxx @@ -4207,20 +4207,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4250,7 +4250,8 @@ static void _set_python_exception() { catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - wcp_to_utf8(&msg); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); @@ -5535,8 +5536,10 @@ SWIGINTERN PyObject *_wrap_BasicIo_path(PyObject *self, PyObject *args) { result = ((Exiv2::BasicIo const *)arg1)->path(); { #ifdef _WIN32 - if (wcp_to_utf8(&result) < 0) { - SWIG_exception_fail(SWIG_ValueError, "failed to transcode result"); + int error = wcp_to_utf8(&result); + if (error) { + PyErr_SetFromWindowsErr(error); + SWIG_fail; } #endif resultobj = SWIG_FromCharPtrAndSize((&result)->data(), (&result)->size()); diff --git a/src/swig-0_27_7/datasets_wrap.cxx b/src/swig-0_27_7/datasets_wrap.cxx index aa2f908b..4a95551e 100644 --- a/src/swig-0_27_7/datasets_wrap.cxx +++ b/src/swig-0_27_7/datasets_wrap.cxx @@ -4229,20 +4229,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4272,7 +4272,8 @@ static void _set_python_exception() { catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - wcp_to_utf8(&msg); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); diff --git a/src/swig-0_27_7/easyaccess_wrap.cxx b/src/swig-0_27_7/easyaccess_wrap.cxx index c5e77087..7d7fa761 100644 --- a/src/swig-0_27_7/easyaccess_wrap.cxx +++ b/src/swig-0_27_7/easyaccess_wrap.cxx @@ -4185,20 +4185,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4228,7 +4228,8 @@ static void _set_python_exception() { catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - wcp_to_utf8(&msg); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); diff --git a/src/swig-0_27_7/error_wrap.cxx b/src/swig-0_27_7/error_wrap.cxx index aeda023c..e68c3554 100644 --- a/src/swig-0_27_7/error_wrap.cxx +++ b/src/swig-0_27_7/error_wrap.cxx @@ -4156,20 +4156,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4195,7 +4195,8 @@ static int wcp_to_utf8(std::string *str) { static PyObject* logger = NULL; static void log_to_python(int level, const char* msg) { std::string copy = msg; - wcp_to_utf8(©); + if (wcp_to_utf8(©)) + copy = msg; Py_ssize_t len = copy.size(); while (len > 0 && copy[len-1] == '\n') len--; diff --git a/src/swig-0_27_7/exif_wrap.cxx b/src/swig-0_27_7/exif_wrap.cxx index d63f9cb8..dd10981b 100644 --- a/src/swig-0_27_7/exif_wrap.cxx +++ b/src/swig-0_27_7/exif_wrap.cxx @@ -4245,20 +4245,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4288,7 +4288,8 @@ static void _set_python_exception() { catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - wcp_to_utf8(&msg); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); @@ -8662,8 +8663,10 @@ SWIGINTERN PyObject *_wrap_ExifThumbC_writeFile(PyObject *self, PyObject *args) } { #ifdef _WIN32 - if (utf8_to_wcp(arg2) < 0) { - SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); + int error = utf8_to_wcp(arg2); + if (error) { + PyErr_SetFromWindowsErr(error); + SWIG_fail; } #endif } @@ -8876,8 +8879,10 @@ SWIGINTERN PyObject *_wrap_ExifThumb_setJpegThumbnail__SWIG_0(PyObject *self, Py arg5 = static_cast< uint16_t >(val5); { #ifdef _WIN32 - if (utf8_to_wcp(arg2) < 0) { - SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); + int error = utf8_to_wcp(arg2); + if (error) { + PyErr_SetFromWindowsErr(error); + SWIG_fail; } #endif } @@ -9011,8 +9016,10 @@ SWIGINTERN PyObject *_wrap_ExifThumb_setJpegThumbnail__SWIG_2(PyObject *self, Py } { #ifdef _WIN32 - if (utf8_to_wcp(arg2) < 0) { - SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); + int error = utf8_to_wcp(arg2); + if (error) { + PyErr_SetFromWindowsErr(error); + SWIG_fail; } #endif } diff --git a/src/swig-0_27_7/image_wrap.cxx b/src/swig-0_27_7/image_wrap.cxx index dd431a56..71847a2f 100644 --- a/src/swig-0_27_7/image_wrap.cxx +++ b/src/swig-0_27_7/image_wrap.cxx @@ -4258,20 +4258,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4301,7 +4301,8 @@ static void _set_python_exception() { catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - wcp_to_utf8(&msg); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); @@ -6353,8 +6354,10 @@ SWIGINTERN PyObject *_wrap_ImageFactory_createIo__SWIG_0(PyObject *self, Py_ssiz } { #ifdef _WIN32 - if (utf8_to_wcp(arg1) < 0) { - SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); + int error = utf8_to_wcp(arg1); + if (error) { + PyErr_SetFromWindowsErr(error); + SWIG_fail; } #endif } @@ -6411,8 +6414,10 @@ SWIGINTERN PyObject *_wrap_ImageFactory_open__SWIG_0(PyObject *self, Py_ssize_t } { #ifdef _WIN32 - if (utf8_to_wcp(arg1) < 0) { - SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); + int error = utf8_to_wcp(arg1); + if (error) { + PyErr_SetFromWindowsErr(error); + SWIG_fail; } #endif } @@ -6561,8 +6566,10 @@ SWIGINTERN PyObject *_wrap_ImageFactory_create__SWIG_0(PyObject *self, Py_ssize_ } { #ifdef _WIN32 - if (utf8_to_wcp(arg2) < 0) { - SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); + int error = utf8_to_wcp(arg2); + if (error) { + PyErr_SetFromWindowsErr(error); + SWIG_fail; } #endif } @@ -6680,8 +6687,10 @@ SWIGINTERN PyObject *_wrap_ImageFactory_getType__SWIG_0(PyObject *self, Py_ssize } { #ifdef _WIN32 - if (utf8_to_wcp(arg1) < 0) { - SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); + int error = utf8_to_wcp(arg1); + if (error) { + PyErr_SetFromWindowsErr(error); + SWIG_fail; } #endif } diff --git a/src/swig-0_27_7/iptc_wrap.cxx b/src/swig-0_27_7/iptc_wrap.cxx index d643dfc2..cf623858 100644 --- a/src/swig-0_27_7/iptc_wrap.cxx +++ b/src/swig-0_27_7/iptc_wrap.cxx @@ -4243,20 +4243,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4286,7 +4286,8 @@ static void _set_python_exception() { catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - wcp_to_utf8(&msg); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); diff --git a/src/swig-0_27_7/metadatum_wrap.cxx b/src/swig-0_27_7/metadatum_wrap.cxx index 0778e3c6..81acba67 100644 --- a/src/swig-0_27_7/metadatum_wrap.cxx +++ b/src/swig-0_27_7/metadatum_wrap.cxx @@ -4229,20 +4229,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4272,7 +4272,8 @@ static void _set_python_exception() { catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - wcp_to_utf8(&msg); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); diff --git a/src/swig-0_27_7/preview_wrap.cxx b/src/swig-0_27_7/preview_wrap.cxx index bfba5d8a..9e9e8aab 100644 --- a/src/swig-0_27_7/preview_wrap.cxx +++ b/src/swig-0_27_7/preview_wrap.cxx @@ -4413,20 +4413,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4456,7 +4456,8 @@ static void _set_python_exception() { catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - wcp_to_utf8(&msg); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); @@ -6399,8 +6400,10 @@ SWIGINTERN PyObject *_wrap_PreviewImage_writeFile(PyObject *self, PyObject *args } { #ifdef _WIN32 - if (utf8_to_wcp(arg2) < 0) { - SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); + int error = utf8_to_wcp(arg2); + if (error) { + PyErr_SetFromWindowsErr(error); + SWIG_fail; } #endif } @@ -6463,8 +6466,10 @@ SWIGINTERN PyObject *_wrap_PreviewImage_extension(PyObject *self, PyObject *args result = ((Exiv2::PreviewImage const *)arg1)->extension(); { #ifdef _WIN32 - if (wcp_to_utf8(&result) < 0) { - SWIG_exception_fail(SWIG_ValueError, "failed to transcode result"); + int error = wcp_to_utf8(&result); + if (error) { + PyErr_SetFromWindowsErr(error); + SWIG_fail; } #endif resultobj = SWIG_FromCharPtrAndSize((&result)->data(), (&result)->size()); diff --git a/src/swig-0_27_7/properties_wrap.cxx b/src/swig-0_27_7/properties_wrap.cxx index 78b12d1e..58c1329c 100644 --- a/src/swig-0_27_7/properties_wrap.cxx +++ b/src/swig-0_27_7/properties_wrap.cxx @@ -4231,20 +4231,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4274,7 +4274,8 @@ static void _set_python_exception() { catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - wcp_to_utf8(&msg); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); diff --git a/src/swig-0_27_7/tags_wrap.cxx b/src/swig-0_27_7/tags_wrap.cxx index 21f19d50..993a2bb4 100644 --- a/src/swig-0_27_7/tags_wrap.cxx +++ b/src/swig-0_27_7/tags_wrap.cxx @@ -4231,20 +4231,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4274,7 +4274,8 @@ static void _set_python_exception() { catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - wcp_to_utf8(&msg); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); diff --git a/src/swig-0_27_7/types_wrap.cxx b/src/swig-0_27_7/types_wrap.cxx index f2f267cd..33a39aba 100644 --- a/src/swig-0_27_7/types_wrap.cxx +++ b/src/swig-0_27_7/types_wrap.cxx @@ -4217,20 +4217,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4260,7 +4260,8 @@ static void _set_python_exception() { catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - wcp_to_utf8(&msg); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); diff --git a/src/swig-0_27_7/value_wrap.cxx b/src/swig-0_27_7/value_wrap.cxx index d491aec9..13fa1f8c 100644 --- a/src/swig-0_27_7/value_wrap.cxx +++ b/src/swig-0_27_7/value_wrap.cxx @@ -4401,20 +4401,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4444,7 +4444,8 @@ static void _set_python_exception() { catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - wcp_to_utf8(&msg); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); diff --git a/src/swig-0_27_7/version_wrap.cxx b/src/swig-0_27_7/version_wrap.cxx index c25a7f90..2b851ae7 100644 --- a/src/swig-0_27_7/version_wrap.cxx +++ b/src/swig-0_27_7/version_wrap.cxx @@ -4197,20 +4197,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4240,7 +4240,8 @@ static void _set_python_exception() { catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - wcp_to_utf8(&msg); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); diff --git a/src/swig-0_27_7/xmp_wrap.cxx b/src/swig-0_27_7/xmp_wrap.cxx index 30e2902a..562bd3bb 100644 --- a/src/swig-0_27_7/xmp_wrap.cxx +++ b/src/swig-0_27_7/xmp_wrap.cxx @@ -4245,20 +4245,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4288,7 +4288,8 @@ static void _set_python_exception() { catch(Exiv2::AnyError const& e) { std::string msg = e.what(); - wcp_to_utf8(&msg); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); diff --git a/src/swig-0_28_3/basicio_wrap.cxx b/src/swig-0_28_3/basicio_wrap.cxx index cf74b4bf..5dcea839 100644 --- a/src/swig-0_28_3/basicio_wrap.cxx +++ b/src/swig-0_28_3/basicio_wrap.cxx @@ -4208,20 +4208,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4258,6 +4258,7 @@ static void _set_python_exception() { + catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); @@ -5803,8 +5804,10 @@ SWIGINTERN PyObject *_wrap_BasicIo_path(PyObject *self, PyObject *args) { { std::string copy = *result; #ifdef _WIN32 - if (wcp_to_utf8(©) < 0) { - SWIG_exception_fail(SWIG_ValueError, "failed to transcode result"); + int error = wcp_to_utf8(©); + if (error) { + PyErr_SetFromWindowsErr(error); + SWIG_fail; } #endif resultobj = SWIG_FromCharPtrAndSize(copy.data(), copy.size()); diff --git a/src/swig-0_28_3/datasets_wrap.cxx b/src/swig-0_28_3/datasets_wrap.cxx index 82f349a2..654183d4 100644 --- a/src/swig-0_28_3/datasets_wrap.cxx +++ b/src/swig-0_28_3/datasets_wrap.cxx @@ -4229,20 +4229,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4279,6 +4279,7 @@ static void _set_python_exception() { + catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/easyaccess_wrap.cxx b/src/swig-0_28_3/easyaccess_wrap.cxx index ed08ab02..4ef1eee1 100644 --- a/src/swig-0_28_3/easyaccess_wrap.cxx +++ b/src/swig-0_28_3/easyaccess_wrap.cxx @@ -4185,20 +4185,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4235,6 +4235,7 @@ static void _set_python_exception() { + catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/error_wrap.cxx b/src/swig-0_28_3/error_wrap.cxx index e41bfa9b..7f3be71b 100644 --- a/src/swig-0_28_3/error_wrap.cxx +++ b/src/swig-0_28_3/error_wrap.cxx @@ -4156,20 +4156,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4195,7 +4195,8 @@ static int wcp_to_utf8(std::string *str) { static PyObject* logger = NULL; static void log_to_python(int level, const char* msg) { std::string copy = msg; - wcp_to_utf8(©); + if (wcp_to_utf8(©)) + copy = msg; Py_ssize_t len = copy.size(); while (len > 0 && copy[len-1] == '\n') len--; diff --git a/src/swig-0_28_3/exif_wrap.cxx b/src/swig-0_28_3/exif_wrap.cxx index 646fb638..397d3a61 100644 --- a/src/swig-0_28_3/exif_wrap.cxx +++ b/src/swig-0_28_3/exif_wrap.cxx @@ -4245,20 +4245,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4295,6 +4295,7 @@ static void _set_python_exception() { + catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); @@ -8866,8 +8867,10 @@ SWIGINTERN PyObject *_wrap_ExifThumbC_writeFile(PyObject *self, PyObject *args) } { #ifdef _WIN32 - if (utf8_to_wcp(arg2) < 0) { - SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); + int error = utf8_to_wcp(arg2); + if (error) { + PyErr_SetFromWindowsErr(error); + SWIG_fail; } #endif } @@ -9080,8 +9083,10 @@ SWIGINTERN PyObject *_wrap_ExifThumb_setJpegThumbnail__SWIG_0(PyObject *self, Py arg5 = static_cast< uint16_t >(val5); { #ifdef _WIN32 - if (utf8_to_wcp(arg2) < 0) { - SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); + int error = utf8_to_wcp(arg2); + if (error) { + PyErr_SetFromWindowsErr(error); + SWIG_fail; } #endif } @@ -9215,8 +9220,10 @@ SWIGINTERN PyObject *_wrap_ExifThumb_setJpegThumbnail__SWIG_2(PyObject *self, Py } { #ifdef _WIN32 - if (utf8_to_wcp(arg2) < 0) { - SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); + int error = utf8_to_wcp(arg2); + if (error) { + PyErr_SetFromWindowsErr(error); + SWIG_fail; } #endif } diff --git a/src/swig-0_28_3/image_wrap.cxx b/src/swig-0_28_3/image_wrap.cxx index 8fb69724..6979b9e9 100644 --- a/src/swig-0_28_3/image_wrap.cxx +++ b/src/swig-0_28_3/image_wrap.cxx @@ -4258,20 +4258,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4308,6 +4308,7 @@ static void _set_python_exception() { + catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); @@ -6353,8 +6354,10 @@ SWIGINTERN PyObject *_wrap_ImageFactory_createIo__SWIG_0(PyObject *self, Py_ssiz } { #ifdef _WIN32 - if (utf8_to_wcp(arg1) < 0) { - SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); + int error = utf8_to_wcp(arg1); + if (error) { + PyErr_SetFromWindowsErr(error); + SWIG_fail; } #endif } @@ -6411,8 +6414,10 @@ SWIGINTERN PyObject *_wrap_ImageFactory_open__SWIG_0(PyObject *self, Py_ssize_t } { #ifdef _WIN32 - if (utf8_to_wcp(arg1) < 0) { - SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); + int error = utf8_to_wcp(arg1); + if (error) { + PyErr_SetFromWindowsErr(error); + SWIG_fail; } #endif } @@ -6561,8 +6566,10 @@ SWIGINTERN PyObject *_wrap_ImageFactory_create__SWIG_0(PyObject *self, Py_ssize_ } { #ifdef _WIN32 - if (utf8_to_wcp(arg2) < 0) { - SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); + int error = utf8_to_wcp(arg2); + if (error) { + PyErr_SetFromWindowsErr(error); + SWIG_fail; } #endif } @@ -6684,8 +6691,10 @@ SWIGINTERN PyObject *_wrap_ImageFactory_getType__SWIG_0(PyObject *self, Py_ssize } { #ifdef _WIN32 - if (utf8_to_wcp(arg1) < 0) { - SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); + int error = utf8_to_wcp(arg1); + if (error) { + PyErr_SetFromWindowsErr(error); + SWIG_fail; } #endif } diff --git a/src/swig-0_28_3/iptc_wrap.cxx b/src/swig-0_28_3/iptc_wrap.cxx index ac30d003..0205dbbc 100644 --- a/src/swig-0_28_3/iptc_wrap.cxx +++ b/src/swig-0_28_3/iptc_wrap.cxx @@ -4243,20 +4243,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4293,6 +4293,7 @@ static void _set_python_exception() { + catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/metadatum_wrap.cxx b/src/swig-0_28_3/metadatum_wrap.cxx index 820541b7..cffbe382 100644 --- a/src/swig-0_28_3/metadatum_wrap.cxx +++ b/src/swig-0_28_3/metadatum_wrap.cxx @@ -4229,20 +4229,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4279,6 +4279,7 @@ static void _set_python_exception() { + catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/preview_wrap.cxx b/src/swig-0_28_3/preview_wrap.cxx index 4ac0e578..ad131615 100644 --- a/src/swig-0_28_3/preview_wrap.cxx +++ b/src/swig-0_28_3/preview_wrap.cxx @@ -4413,20 +4413,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4463,6 +4463,7 @@ static void _set_python_exception() { + catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); @@ -6399,8 +6400,10 @@ SWIGINTERN PyObject *_wrap_PreviewImage_writeFile(PyObject *self, PyObject *args } { #ifdef _WIN32 - if (utf8_to_wcp(arg2) < 0) { - SWIG_exception_fail(SWIG_ValueError, "failed to transcode path"); + int error = utf8_to_wcp(arg2); + if (error) { + PyErr_SetFromWindowsErr(error); + SWIG_fail; } #endif } @@ -6463,8 +6466,10 @@ SWIGINTERN PyObject *_wrap_PreviewImage_extension(PyObject *self, PyObject *args result = ((Exiv2::PreviewImage const *)arg1)->extension(); { #ifdef _WIN32 - if (wcp_to_utf8(&result) < 0) { - SWIG_exception_fail(SWIG_ValueError, "failed to transcode result"); + int error = wcp_to_utf8(&result); + if (error) { + PyErr_SetFromWindowsErr(error); + SWIG_fail; } #endif resultobj = SWIG_FromCharPtrAndSize((&result)->data(), (&result)->size()); diff --git a/src/swig-0_28_3/properties_wrap.cxx b/src/swig-0_28_3/properties_wrap.cxx index dcab1cbb..3168d9fc 100644 --- a/src/swig-0_28_3/properties_wrap.cxx +++ b/src/swig-0_28_3/properties_wrap.cxx @@ -4231,20 +4231,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4281,6 +4281,7 @@ static void _set_python_exception() { + catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/tags_wrap.cxx b/src/swig-0_28_3/tags_wrap.cxx index e2c1360d..61650def 100644 --- a/src/swig-0_28_3/tags_wrap.cxx +++ b/src/swig-0_28_3/tags_wrap.cxx @@ -4231,20 +4231,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4281,6 +4281,7 @@ static void _set_python_exception() { + catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/types_wrap.cxx b/src/swig-0_28_3/types_wrap.cxx index 106d5823..126d57c6 100644 --- a/src/swig-0_28_3/types_wrap.cxx +++ b/src/swig-0_28_3/types_wrap.cxx @@ -4217,20 +4217,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4267,6 +4267,7 @@ static void _set_python_exception() { + catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/value_wrap.cxx b/src/swig-0_28_3/value_wrap.cxx index 5306e69b..ee90c14b 100644 --- a/src/swig-0_28_3/value_wrap.cxx +++ b/src/swig-0_28_3/value_wrap.cxx @@ -4401,20 +4401,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4451,6 +4451,7 @@ static void _set_python_exception() { + catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/version_wrap.cxx b/src/swig-0_28_3/version_wrap.cxx index 0a39af67..0a9a56c9 100644 --- a/src/swig-0_28_3/version_wrap.cxx +++ b/src/swig-0_28_3/version_wrap.cxx @@ -4197,20 +4197,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4247,6 +4247,7 @@ static void _set_python_exception() { + catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/xmp_wrap.cxx b/src/swig-0_28_3/xmp_wrap.cxx index e4ca5694..cdb9a621 100644 --- a/src/swig-0_28_3/xmp_wrap.cxx +++ b/src/swig-0_28_3/xmp_wrap.cxx @@ -4245,20 +4245,20 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), NULL, 0); if (!size) - return -1; + return GetLastError(); std::wstring wide_str; wide_str.resize(size); if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), &wide_str[0], size)) - return -1; + return GetLastError(); size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) - return -1; + return GetLastError(); str->resize(size); if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) - return -1; + return GetLastError(); return 0; }; #endif @@ -4295,6 +4295,7 @@ static void _set_python_exception() { + catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); From f594ef5a1925499774e9db9aaa5976cbf0ecb10d Mon Sep 17 00:00:00 2001 From: Jim Easterbrook Date: Wed, 18 Sep 2024 12:09:57 +0100 Subject: [PATCH 06/10] Windows CP transcodes may not be null terminated --- src/interface/error.i | 2 +- src/interface/shared/exception.i | 3 ++- src/swig-0_27_7/basicio_wrap.cxx | 3 ++- src/swig-0_27_7/datasets_wrap.cxx | 3 ++- src/swig-0_27_7/easyaccess_wrap.cxx | 3 ++- src/swig-0_27_7/error_wrap.cxx | 2 +- src/swig-0_27_7/exif_wrap.cxx | 3 ++- src/swig-0_27_7/image_wrap.cxx | 3 ++- src/swig-0_27_7/iptc_wrap.cxx | 3 ++- src/swig-0_27_7/metadatum_wrap.cxx | 3 ++- src/swig-0_27_7/preview_wrap.cxx | 3 ++- src/swig-0_27_7/properties_wrap.cxx | 3 ++- src/swig-0_27_7/tags_wrap.cxx | 3 ++- src/swig-0_27_7/types_wrap.cxx | 3 ++- src/swig-0_27_7/value_wrap.cxx | 3 ++- src/swig-0_27_7/version_wrap.cxx | 3 ++- src/swig-0_27_7/xmp_wrap.cxx | 3 ++- src/swig-0_28_3/basicio_wrap.cxx | 1 + src/swig-0_28_3/datasets_wrap.cxx | 1 + src/swig-0_28_3/easyaccess_wrap.cxx | 1 + src/swig-0_28_3/error_wrap.cxx | 2 +- src/swig-0_28_3/exif_wrap.cxx | 1 + src/swig-0_28_3/image_wrap.cxx | 1 + src/swig-0_28_3/iptc_wrap.cxx | 1 + src/swig-0_28_3/metadatum_wrap.cxx | 1 + src/swig-0_28_3/preview_wrap.cxx | 1 + src/swig-0_28_3/properties_wrap.cxx | 1 + src/swig-0_28_3/tags_wrap.cxx | 1 + src/swig-0_28_3/types_wrap.cxx | 1 + src/swig-0_28_3/value_wrap.cxx | 1 + src/swig-0_28_3/version_wrap.cxx | 1 + src/swig-0_28_3/xmp_wrap.cxx | 1 + 32 files changed, 47 insertions(+), 18 deletions(-) diff --git a/src/interface/error.i b/src/interface/error.i index a8d07b28..d28cf131 100644 --- a/src/interface/error.i +++ b/src/interface/error.i @@ -46,7 +46,7 @@ static void log_to_python(int level, const char* msg) { len--; PyGILState_STATE gstate = PyGILState_Ensure(); PyObject* res = PyObject_CallMethod( - logger, "log", "(is#)", (level + 1) * 10, copy.c_str(), len); + logger, "log", "(is#)", (level + 1) * 10, copy.data(), len); Py_XDECREF(res); PyGILState_Release(gstate); }; diff --git a/src/interface/shared/exception.i b/src/interface/shared/exception.i index 9dff3c6d..5af38c46 100644 --- a/src/interface/shared/exception.i +++ b/src/interface/shared/exception.i @@ -50,7 +50,8 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); + "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), + msg.data(), msg.size()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_27_7/basicio_wrap.cxx b/src/swig-0_27_7/basicio_wrap.cxx index 8c87bd21..e6683159 100644 --- a/src/swig-0_27_7/basicio_wrap.cxx +++ b/src/swig-0_27_7/basicio_wrap.cxx @@ -4253,7 +4253,8 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); + "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), + msg.data(), msg.size()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_27_7/datasets_wrap.cxx b/src/swig-0_27_7/datasets_wrap.cxx index 4a95551e..663524e8 100644 --- a/src/swig-0_27_7/datasets_wrap.cxx +++ b/src/swig-0_27_7/datasets_wrap.cxx @@ -4275,7 +4275,8 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); + "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), + msg.data(), msg.size()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_27_7/easyaccess_wrap.cxx b/src/swig-0_27_7/easyaccess_wrap.cxx index 7d7fa761..e438e6f6 100644 --- a/src/swig-0_27_7/easyaccess_wrap.cxx +++ b/src/swig-0_27_7/easyaccess_wrap.cxx @@ -4231,7 +4231,8 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); + "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), + msg.data(), msg.size()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_27_7/error_wrap.cxx b/src/swig-0_27_7/error_wrap.cxx index e68c3554..5f6b91bd 100644 --- a/src/swig-0_27_7/error_wrap.cxx +++ b/src/swig-0_27_7/error_wrap.cxx @@ -4202,7 +4202,7 @@ static void log_to_python(int level, const char* msg) { len--; PyGILState_STATE gstate = PyGILState_Ensure(); PyObject* res = PyObject_CallMethod( - logger, "log", "(is#)", (level + 1) * 10, copy.c_str(), len); + logger, "log", "(is#)", (level + 1) * 10, copy.data(), len); Py_XDECREF(res); PyGILState_Release(gstate); }; diff --git a/src/swig-0_27_7/exif_wrap.cxx b/src/swig-0_27_7/exif_wrap.cxx index dd10981b..63bb8e62 100644 --- a/src/swig-0_27_7/exif_wrap.cxx +++ b/src/swig-0_27_7/exif_wrap.cxx @@ -4291,7 +4291,8 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); + "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), + msg.data(), msg.size()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_27_7/image_wrap.cxx b/src/swig-0_27_7/image_wrap.cxx index 71847a2f..083f2df5 100644 --- a/src/swig-0_27_7/image_wrap.cxx +++ b/src/swig-0_27_7/image_wrap.cxx @@ -4304,7 +4304,8 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); + "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), + msg.data(), msg.size()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_27_7/iptc_wrap.cxx b/src/swig-0_27_7/iptc_wrap.cxx index cf623858..2243c598 100644 --- a/src/swig-0_27_7/iptc_wrap.cxx +++ b/src/swig-0_27_7/iptc_wrap.cxx @@ -4289,7 +4289,8 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); + "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), + msg.data(), msg.size()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_27_7/metadatum_wrap.cxx b/src/swig-0_27_7/metadatum_wrap.cxx index 81acba67..0854f23c 100644 --- a/src/swig-0_27_7/metadatum_wrap.cxx +++ b/src/swig-0_27_7/metadatum_wrap.cxx @@ -4275,7 +4275,8 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); + "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), + msg.data(), msg.size()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_27_7/preview_wrap.cxx b/src/swig-0_27_7/preview_wrap.cxx index 9e9e8aab..a3c043c6 100644 --- a/src/swig-0_27_7/preview_wrap.cxx +++ b/src/swig-0_27_7/preview_wrap.cxx @@ -4459,7 +4459,8 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); + "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), + msg.data(), msg.size()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_27_7/properties_wrap.cxx b/src/swig-0_27_7/properties_wrap.cxx index 58c1329c..e6b3f262 100644 --- a/src/swig-0_27_7/properties_wrap.cxx +++ b/src/swig-0_27_7/properties_wrap.cxx @@ -4277,7 +4277,8 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); + "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), + msg.data(), msg.size()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_27_7/tags_wrap.cxx b/src/swig-0_27_7/tags_wrap.cxx index 993a2bb4..1814f205 100644 --- a/src/swig-0_27_7/tags_wrap.cxx +++ b/src/swig-0_27_7/tags_wrap.cxx @@ -4277,7 +4277,8 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); + "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), + msg.data(), msg.size()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_27_7/types_wrap.cxx b/src/swig-0_27_7/types_wrap.cxx index 33a39aba..a77dca4f 100644 --- a/src/swig-0_27_7/types_wrap.cxx +++ b/src/swig-0_27_7/types_wrap.cxx @@ -4263,7 +4263,8 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); + "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), + msg.data(), msg.size()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_27_7/value_wrap.cxx b/src/swig-0_27_7/value_wrap.cxx index 13fa1f8c..5c8c76d6 100644 --- a/src/swig-0_27_7/value_wrap.cxx +++ b/src/swig-0_27_7/value_wrap.cxx @@ -4447,7 +4447,8 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); + "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), + msg.data(), msg.size()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_27_7/version_wrap.cxx b/src/swig-0_27_7/version_wrap.cxx index 2b851ae7..7fbb75f0 100644 --- a/src/swig-0_27_7/version_wrap.cxx +++ b/src/swig-0_27_7/version_wrap.cxx @@ -4243,7 +4243,8 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); + "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), + msg.data(), msg.size()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_27_7/xmp_wrap.cxx b/src/swig-0_27_7/xmp_wrap.cxx index 562bd3bb..745d2b2d 100644 --- a/src/swig-0_27_7/xmp_wrap.cxx +++ b/src/swig-0_27_7/xmp_wrap.cxx @@ -4291,7 +4291,8 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); + "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), + msg.data(), msg.size()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_28_3/basicio_wrap.cxx b/src/swig-0_28_3/basicio_wrap.cxx index 5dcea839..ae5e0c79 100644 --- a/src/swig-0_28_3/basicio_wrap.cxx +++ b/src/swig-0_28_3/basicio_wrap.cxx @@ -4259,6 +4259,7 @@ static void _set_python_exception() { + catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/datasets_wrap.cxx b/src/swig-0_28_3/datasets_wrap.cxx index 654183d4..e5e11500 100644 --- a/src/swig-0_28_3/datasets_wrap.cxx +++ b/src/swig-0_28_3/datasets_wrap.cxx @@ -4280,6 +4280,7 @@ static void _set_python_exception() { + catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/easyaccess_wrap.cxx b/src/swig-0_28_3/easyaccess_wrap.cxx index 4ef1eee1..b2c9a72c 100644 --- a/src/swig-0_28_3/easyaccess_wrap.cxx +++ b/src/swig-0_28_3/easyaccess_wrap.cxx @@ -4236,6 +4236,7 @@ static void _set_python_exception() { + catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/error_wrap.cxx b/src/swig-0_28_3/error_wrap.cxx index 7f3be71b..af2bb1e3 100644 --- a/src/swig-0_28_3/error_wrap.cxx +++ b/src/swig-0_28_3/error_wrap.cxx @@ -4202,7 +4202,7 @@ static void log_to_python(int level, const char* msg) { len--; PyGILState_STATE gstate = PyGILState_Ensure(); PyObject* res = PyObject_CallMethod( - logger, "log", "(is#)", (level + 1) * 10, copy.c_str(), len); + logger, "log", "(is#)", (level + 1) * 10, copy.data(), len); Py_XDECREF(res); PyGILState_Release(gstate); }; diff --git a/src/swig-0_28_3/exif_wrap.cxx b/src/swig-0_28_3/exif_wrap.cxx index 397d3a61..3c59454a 100644 --- a/src/swig-0_28_3/exif_wrap.cxx +++ b/src/swig-0_28_3/exif_wrap.cxx @@ -4296,6 +4296,7 @@ static void _set_python_exception() { + catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/image_wrap.cxx b/src/swig-0_28_3/image_wrap.cxx index 6979b9e9..0ff537c2 100644 --- a/src/swig-0_28_3/image_wrap.cxx +++ b/src/swig-0_28_3/image_wrap.cxx @@ -4309,6 +4309,7 @@ static void _set_python_exception() { + catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/iptc_wrap.cxx b/src/swig-0_28_3/iptc_wrap.cxx index 0205dbbc..8219a34f 100644 --- a/src/swig-0_28_3/iptc_wrap.cxx +++ b/src/swig-0_28_3/iptc_wrap.cxx @@ -4294,6 +4294,7 @@ static void _set_python_exception() { + catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/metadatum_wrap.cxx b/src/swig-0_28_3/metadatum_wrap.cxx index cffbe382..cb9e02a4 100644 --- a/src/swig-0_28_3/metadatum_wrap.cxx +++ b/src/swig-0_28_3/metadatum_wrap.cxx @@ -4280,6 +4280,7 @@ static void _set_python_exception() { + catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/preview_wrap.cxx b/src/swig-0_28_3/preview_wrap.cxx index ad131615..8d0410e5 100644 --- a/src/swig-0_28_3/preview_wrap.cxx +++ b/src/swig-0_28_3/preview_wrap.cxx @@ -4464,6 +4464,7 @@ static void _set_python_exception() { + catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/properties_wrap.cxx b/src/swig-0_28_3/properties_wrap.cxx index 3168d9fc..369d1f5e 100644 --- a/src/swig-0_28_3/properties_wrap.cxx +++ b/src/swig-0_28_3/properties_wrap.cxx @@ -4282,6 +4282,7 @@ static void _set_python_exception() { + catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/tags_wrap.cxx b/src/swig-0_28_3/tags_wrap.cxx index 61650def..fa3adc3e 100644 --- a/src/swig-0_28_3/tags_wrap.cxx +++ b/src/swig-0_28_3/tags_wrap.cxx @@ -4282,6 +4282,7 @@ static void _set_python_exception() { + catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/types_wrap.cxx b/src/swig-0_28_3/types_wrap.cxx index 126d57c6..17ec8aed 100644 --- a/src/swig-0_28_3/types_wrap.cxx +++ b/src/swig-0_28_3/types_wrap.cxx @@ -4268,6 +4268,7 @@ static void _set_python_exception() { + catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/value_wrap.cxx b/src/swig-0_28_3/value_wrap.cxx index ee90c14b..e122282b 100644 --- a/src/swig-0_28_3/value_wrap.cxx +++ b/src/swig-0_28_3/value_wrap.cxx @@ -4452,6 +4452,7 @@ static void _set_python_exception() { + catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/version_wrap.cxx b/src/swig-0_28_3/version_wrap.cxx index 0a9a56c9..5b6637dc 100644 --- a/src/swig-0_28_3/version_wrap.cxx +++ b/src/swig-0_28_3/version_wrap.cxx @@ -4248,6 +4248,7 @@ static void _set_python_exception() { + catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/xmp_wrap.cxx b/src/swig-0_28_3/xmp_wrap.cxx index cdb9a621..e2f8be3d 100644 --- a/src/swig-0_28_3/xmp_wrap.cxx +++ b/src/swig-0_28_3/xmp_wrap.cxx @@ -4296,6 +4296,7 @@ static void _set_python_exception() { + catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); From f2112c3bc4af0bb8d5ebac2ab331d98d822898ee Mon Sep 17 00:00:00 2001 From: Jim Easterbrook Date: Wed, 18 Sep 2024 12:59:33 +0100 Subject: [PATCH 07/10] Use NULL terminated strings in Windows CP stuff --- src/interface/shared/exception.i | 3 +-- src/interface/shared/windows_cp.i | 10 ++++------ src/swig-0_27_7/basicio_wrap.cxx | 13 +++++-------- src/swig-0_27_7/datasets_wrap.cxx | 13 +++++-------- src/swig-0_27_7/easyaccess_wrap.cxx | 13 +++++-------- src/swig-0_27_7/error_wrap.cxx | 10 ++++------ src/swig-0_27_7/exif_wrap.cxx | 13 +++++-------- src/swig-0_27_7/image_wrap.cxx | 13 +++++-------- src/swig-0_27_7/iptc_wrap.cxx | 13 +++++-------- src/swig-0_27_7/metadatum_wrap.cxx | 13 +++++-------- src/swig-0_27_7/preview_wrap.cxx | 13 +++++-------- src/swig-0_27_7/properties_wrap.cxx | 13 +++++-------- src/swig-0_27_7/tags_wrap.cxx | 13 +++++-------- src/swig-0_27_7/types_wrap.cxx | 13 +++++-------- src/swig-0_27_7/value_wrap.cxx | 13 +++++-------- src/swig-0_27_7/version_wrap.cxx | 13 +++++-------- src/swig-0_27_7/xmp_wrap.cxx | 13 +++++-------- src/swig-0_28_3/basicio_wrap.cxx | 11 ++++------- src/swig-0_28_3/datasets_wrap.cxx | 11 ++++------- src/swig-0_28_3/easyaccess_wrap.cxx | 11 ++++------- src/swig-0_28_3/error_wrap.cxx | 10 ++++------ src/swig-0_28_3/exif_wrap.cxx | 11 ++++------- src/swig-0_28_3/image_wrap.cxx | 11 ++++------- src/swig-0_28_3/iptc_wrap.cxx | 11 ++++------- src/swig-0_28_3/metadatum_wrap.cxx | 11 ++++------- src/swig-0_28_3/preview_wrap.cxx | 11 ++++------- src/swig-0_28_3/properties_wrap.cxx | 11 ++++------- src/swig-0_28_3/tags_wrap.cxx | 11 ++++------- src/swig-0_28_3/types_wrap.cxx | 11 ++++------- src/swig-0_28_3/value_wrap.cxx | 11 ++++------- src/swig-0_28_3/version_wrap.cxx | 11 ++++------- src/swig-0_28_3/xmp_wrap.cxx | 11 ++++------- 32 files changed, 139 insertions(+), 230 deletions(-) diff --git a/src/interface/shared/exception.i b/src/interface/shared/exception.i index 5af38c46..9dff3c6d 100644 --- a/src/interface/shared/exception.i +++ b/src/interface/shared/exception.i @@ -50,8 +50,7 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), - msg.data(), msg.size()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/interface/shared/windows_cp.i b/src/interface/shared/windows_cp.i index 709774d7..9a8b99ee 100644 --- a/src/interface/shared/windows_cp.i +++ b/src/interface/shared/windows_cp.i @@ -26,21 +26,19 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; diff --git a/src/swig-0_27_7/basicio_wrap.cxx b/src/swig-0_27_7/basicio_wrap.cxx index e6683159..c1561d35 100644 --- a/src/swig-0_27_7/basicio_wrap.cxx +++ b/src/swig-0_27_7/basicio_wrap.cxx @@ -4204,21 +4204,19 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4253,8 +4251,7 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), - msg.data(), msg.size()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_27_7/datasets_wrap.cxx b/src/swig-0_27_7/datasets_wrap.cxx index 663524e8..dc64f2f6 100644 --- a/src/swig-0_27_7/datasets_wrap.cxx +++ b/src/swig-0_27_7/datasets_wrap.cxx @@ -4226,21 +4226,19 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4275,8 +4273,7 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), - msg.data(), msg.size()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_27_7/easyaccess_wrap.cxx b/src/swig-0_27_7/easyaccess_wrap.cxx index e438e6f6..1fd966d1 100644 --- a/src/swig-0_27_7/easyaccess_wrap.cxx +++ b/src/swig-0_27_7/easyaccess_wrap.cxx @@ -4182,21 +4182,19 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4231,8 +4229,7 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), - msg.data(), msg.size()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_27_7/error_wrap.cxx b/src/swig-0_27_7/error_wrap.cxx index 5f6b91bd..1b1043e7 100644 --- a/src/swig-0_27_7/error_wrap.cxx +++ b/src/swig-0_27_7/error_wrap.cxx @@ -4153,21 +4153,19 @@ static PyObject* exiv2_module = NULL; static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; diff --git a/src/swig-0_27_7/exif_wrap.cxx b/src/swig-0_27_7/exif_wrap.cxx index 63bb8e62..06e23f73 100644 --- a/src/swig-0_27_7/exif_wrap.cxx +++ b/src/swig-0_27_7/exif_wrap.cxx @@ -4242,21 +4242,19 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4291,8 +4289,7 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), - msg.data(), msg.size()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_27_7/image_wrap.cxx b/src/swig-0_27_7/image_wrap.cxx index 083f2df5..2a74cf8e 100644 --- a/src/swig-0_27_7/image_wrap.cxx +++ b/src/swig-0_27_7/image_wrap.cxx @@ -4255,21 +4255,19 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4304,8 +4302,7 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), - msg.data(), msg.size()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_27_7/iptc_wrap.cxx b/src/swig-0_27_7/iptc_wrap.cxx index 2243c598..6f20bd0f 100644 --- a/src/swig-0_27_7/iptc_wrap.cxx +++ b/src/swig-0_27_7/iptc_wrap.cxx @@ -4240,21 +4240,19 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4289,8 +4287,7 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), - msg.data(), msg.size()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_27_7/metadatum_wrap.cxx b/src/swig-0_27_7/metadatum_wrap.cxx index 0854f23c..2c1576f6 100644 --- a/src/swig-0_27_7/metadatum_wrap.cxx +++ b/src/swig-0_27_7/metadatum_wrap.cxx @@ -4226,21 +4226,19 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4275,8 +4273,7 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), - msg.data(), msg.size()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_27_7/preview_wrap.cxx b/src/swig-0_27_7/preview_wrap.cxx index a3c043c6..69854b0a 100644 --- a/src/swig-0_27_7/preview_wrap.cxx +++ b/src/swig-0_27_7/preview_wrap.cxx @@ -4410,21 +4410,19 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4459,8 +4457,7 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), - msg.data(), msg.size()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_27_7/properties_wrap.cxx b/src/swig-0_27_7/properties_wrap.cxx index e6b3f262..675a9e49 100644 --- a/src/swig-0_27_7/properties_wrap.cxx +++ b/src/swig-0_27_7/properties_wrap.cxx @@ -4228,21 +4228,19 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4277,8 +4275,7 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), - msg.data(), msg.size()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_27_7/tags_wrap.cxx b/src/swig-0_27_7/tags_wrap.cxx index 1814f205..cad6e68a 100644 --- a/src/swig-0_27_7/tags_wrap.cxx +++ b/src/swig-0_27_7/tags_wrap.cxx @@ -4228,21 +4228,19 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4277,8 +4275,7 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), - msg.data(), msg.size()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_27_7/types_wrap.cxx b/src/swig-0_27_7/types_wrap.cxx index a77dca4f..49568af3 100644 --- a/src/swig-0_27_7/types_wrap.cxx +++ b/src/swig-0_27_7/types_wrap.cxx @@ -4214,21 +4214,19 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4263,8 +4261,7 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), - msg.data(), msg.size()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_27_7/value_wrap.cxx b/src/swig-0_27_7/value_wrap.cxx index 5c8c76d6..097879a3 100644 --- a/src/swig-0_27_7/value_wrap.cxx +++ b/src/swig-0_27_7/value_wrap.cxx @@ -4398,21 +4398,19 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4447,8 +4445,7 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), - msg.data(), msg.size()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_27_7/version_wrap.cxx b/src/swig-0_27_7/version_wrap.cxx index 7fbb75f0..9f43f1d1 100644 --- a/src/swig-0_27_7/version_wrap.cxx +++ b/src/swig-0_27_7/version_wrap.cxx @@ -4194,21 +4194,19 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4243,8 +4241,7 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), - msg.data(), msg.size()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_27_7/xmp_wrap.cxx b/src/swig-0_27_7/xmp_wrap.cxx index 745d2b2d..3956ef16 100644 --- a/src/swig-0_27_7/xmp_wrap.cxx +++ b/src/swig-0_27_7/xmp_wrap.cxx @@ -4242,21 +4242,19 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4291,8 +4289,7 @@ static void _set_python_exception() { if (wcp_to_utf8(&msg)) msg = e.what(); PyObject* args = Py_BuildValue( - "Ns#", py_from_enum((Exiv2::ErrorCode)e.code()), - msg.data(), msg.size()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_28_3/basicio_wrap.cxx b/src/swig-0_28_3/basicio_wrap.cxx index ae5e0c79..e17653c9 100644 --- a/src/swig-0_28_3/basicio_wrap.cxx +++ b/src/swig-0_28_3/basicio_wrap.cxx @@ -4205,21 +4205,19 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4259,7 +4257,6 @@ static void _set_python_exception() { - catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/datasets_wrap.cxx b/src/swig-0_28_3/datasets_wrap.cxx index e5e11500..a1b86654 100644 --- a/src/swig-0_28_3/datasets_wrap.cxx +++ b/src/swig-0_28_3/datasets_wrap.cxx @@ -4226,21 +4226,19 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4280,7 +4278,6 @@ static void _set_python_exception() { - catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/easyaccess_wrap.cxx b/src/swig-0_28_3/easyaccess_wrap.cxx index b2c9a72c..1a9e95ef 100644 --- a/src/swig-0_28_3/easyaccess_wrap.cxx +++ b/src/swig-0_28_3/easyaccess_wrap.cxx @@ -4182,21 +4182,19 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4236,7 +4234,6 @@ static void _set_python_exception() { - catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/error_wrap.cxx b/src/swig-0_28_3/error_wrap.cxx index af2bb1e3..c359a900 100644 --- a/src/swig-0_28_3/error_wrap.cxx +++ b/src/swig-0_28_3/error_wrap.cxx @@ -4153,21 +4153,19 @@ static PyObject* exiv2_module = NULL; static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; diff --git a/src/swig-0_28_3/exif_wrap.cxx b/src/swig-0_28_3/exif_wrap.cxx index 3c59454a..bf05d0bd 100644 --- a/src/swig-0_28_3/exif_wrap.cxx +++ b/src/swig-0_28_3/exif_wrap.cxx @@ -4242,21 +4242,19 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4296,7 +4294,6 @@ static void _set_python_exception() { - catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/image_wrap.cxx b/src/swig-0_28_3/image_wrap.cxx index 0ff537c2..0528e4e3 100644 --- a/src/swig-0_28_3/image_wrap.cxx +++ b/src/swig-0_28_3/image_wrap.cxx @@ -4255,21 +4255,19 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4309,7 +4307,6 @@ static void _set_python_exception() { - catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/iptc_wrap.cxx b/src/swig-0_28_3/iptc_wrap.cxx index 8219a34f..39c3d54a 100644 --- a/src/swig-0_28_3/iptc_wrap.cxx +++ b/src/swig-0_28_3/iptc_wrap.cxx @@ -4240,21 +4240,19 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4294,7 +4292,6 @@ static void _set_python_exception() { - catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/metadatum_wrap.cxx b/src/swig-0_28_3/metadatum_wrap.cxx index cb9e02a4..a2c73ed0 100644 --- a/src/swig-0_28_3/metadatum_wrap.cxx +++ b/src/swig-0_28_3/metadatum_wrap.cxx @@ -4226,21 +4226,19 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4280,7 +4278,6 @@ static void _set_python_exception() { - catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/preview_wrap.cxx b/src/swig-0_28_3/preview_wrap.cxx index 8d0410e5..e4f2c45e 100644 --- a/src/swig-0_28_3/preview_wrap.cxx +++ b/src/swig-0_28_3/preview_wrap.cxx @@ -4410,21 +4410,19 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4464,7 +4462,6 @@ static void _set_python_exception() { - catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/properties_wrap.cxx b/src/swig-0_28_3/properties_wrap.cxx index 369d1f5e..042f35d5 100644 --- a/src/swig-0_28_3/properties_wrap.cxx +++ b/src/swig-0_28_3/properties_wrap.cxx @@ -4228,21 +4228,19 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4282,7 +4280,6 @@ static void _set_python_exception() { - catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/tags_wrap.cxx b/src/swig-0_28_3/tags_wrap.cxx index fa3adc3e..c7bba8a9 100644 --- a/src/swig-0_28_3/tags_wrap.cxx +++ b/src/swig-0_28_3/tags_wrap.cxx @@ -4228,21 +4228,19 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4282,7 +4280,6 @@ static void _set_python_exception() { - catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/types_wrap.cxx b/src/swig-0_28_3/types_wrap.cxx index 17ec8aed..825e3a2c 100644 --- a/src/swig-0_28_3/types_wrap.cxx +++ b/src/swig-0_28_3/types_wrap.cxx @@ -4214,21 +4214,19 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4268,7 +4266,6 @@ static void _set_python_exception() { - catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/value_wrap.cxx b/src/swig-0_28_3/value_wrap.cxx index e122282b..168c4417 100644 --- a/src/swig-0_28_3/value_wrap.cxx +++ b/src/swig-0_28_3/value_wrap.cxx @@ -4398,21 +4398,19 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4452,7 +4450,6 @@ static void _set_python_exception() { - catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/version_wrap.cxx b/src/swig-0_28_3/version_wrap.cxx index 5b6637dc..7db5a5f9 100644 --- a/src/swig-0_28_3/version_wrap.cxx +++ b/src/swig-0_28_3/version_wrap.cxx @@ -4194,21 +4194,19 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4248,7 +4246,6 @@ static void _set_python_exception() { - catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); diff --git a/src/swig-0_28_3/xmp_wrap.cxx b/src/swig-0_28_3/xmp_wrap.cxx index e2f8be3d..f7bffb6f 100644 --- a/src/swig-0_28_3/xmp_wrap.cxx +++ b/src/swig-0_28_3/xmp_wrap.cxx @@ -4242,21 +4242,19 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), - &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4296,7 +4294,6 @@ static void _set_python_exception() { - catch(Exiv2::Error const& e) { PyObject* args = Py_BuildValue( "Ns", py_from_enum(e.code()), e.what()); From 247b89a2f4dcae7db0fd5770f67e8ca0e693be40 Mon Sep 17 00:00:00 2001 From: Jim Easterbrook Date: Wed, 18 Sep 2024 13:35:38 +0100 Subject: [PATCH 08/10] Don't assume exiv2 0.28.x has utf-8 error messages --- src/interface/shared/exception.i | 5 ++++- src/interface/shared/windows_cp.i | 10 ++++++---- src/swig-0_27_7/basicio_wrap.cxx | 13 +++++++++---- src/swig-0_27_7/datasets_wrap.cxx | 13 +++++++++---- src/swig-0_27_7/easyaccess_wrap.cxx | 13 +++++++++---- src/swig-0_27_7/error_wrap.cxx | 10 ++++++---- src/swig-0_27_7/exif_wrap.cxx | 13 +++++++++---- src/swig-0_27_7/image_wrap.cxx | 13 +++++++++---- src/swig-0_27_7/iptc_wrap.cxx | 13 +++++++++---- src/swig-0_27_7/metadatum_wrap.cxx | 13 +++++++++---- src/swig-0_27_7/preview_wrap.cxx | 13 +++++++++---- src/swig-0_27_7/properties_wrap.cxx | 13 +++++++++---- src/swig-0_27_7/tags_wrap.cxx | 13 +++++++++---- src/swig-0_27_7/types_wrap.cxx | 13 +++++++++---- src/swig-0_27_7/value_wrap.cxx | 13 +++++++++---- src/swig-0_27_7/version_wrap.cxx | 13 +++++++++---- src/swig-0_27_7/xmp_wrap.cxx | 13 +++++++++---- src/swig-0_28_3/basicio_wrap.cxx | 15 ++++++++++----- src/swig-0_28_3/datasets_wrap.cxx | 15 ++++++++++----- src/swig-0_28_3/easyaccess_wrap.cxx | 15 ++++++++++----- src/swig-0_28_3/error_wrap.cxx | 10 ++++++---- src/swig-0_28_3/exif_wrap.cxx | 15 ++++++++++----- src/swig-0_28_3/image_wrap.cxx | 15 ++++++++++----- src/swig-0_28_3/iptc_wrap.cxx | 15 ++++++++++----- src/swig-0_28_3/metadatum_wrap.cxx | 15 ++++++++++----- src/swig-0_28_3/preview_wrap.cxx | 15 ++++++++++----- src/swig-0_28_3/properties_wrap.cxx | 15 ++++++++++----- src/swig-0_28_3/tags_wrap.cxx | 15 ++++++++++----- src/swig-0_28_3/types_wrap.cxx | 15 ++++++++++----- src/swig-0_28_3/value_wrap.cxx | 15 ++++++++++----- src/swig-0_28_3/version_wrap.cxx | 15 ++++++++++----- src/swig-0_28_3/xmp_wrap.cxx | 15 ++++++++++----- 32 files changed, 288 insertions(+), 139 deletions(-) diff --git a/src/interface/shared/exception.i b/src/interface/shared/exception.i index 9dff3c6d..eb237e13 100644 --- a/src/interface/shared/exception.i +++ b/src/interface/shared/exception.i @@ -56,8 +56,11 @@ static void _set_python_exception() { } #else catch(Exiv2::Error const& e) { + std::string msg = e.what(); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum(e.code()), e.what()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/interface/shared/windows_cp.i b/src/interface/shared/windows_cp.i index 9a8b99ee..709774d7 100644 --- a/src/interface/shared/windows_cp.i +++ b/src/interface/shared/windows_cp.i @@ -26,19 +26,21 @@ static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; diff --git a/src/swig-0_27_7/basicio_wrap.cxx b/src/swig-0_27_7/basicio_wrap.cxx index c1561d35..cbf13b96 100644 --- a/src/swig-0_27_7/basicio_wrap.cxx +++ b/src/swig-0_27_7/basicio_wrap.cxx @@ -4204,19 +4204,21 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4263,6 +4265,9 @@ static void _set_python_exception() { + + + /*@SWIG:/usr/local/share/swig/4.2.1/typemaps/exception.swg,59,SWIG_CATCH_STDEXCEPT@*/ /* catching std::exception */ catch (std::invalid_argument& e) { SWIG_exception_fail(SWIG_ValueError, e.what() ); diff --git a/src/swig-0_27_7/datasets_wrap.cxx b/src/swig-0_27_7/datasets_wrap.cxx index dc64f2f6..0d6a612e 100644 --- a/src/swig-0_27_7/datasets_wrap.cxx +++ b/src/swig-0_27_7/datasets_wrap.cxx @@ -4226,19 +4226,21 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4285,6 +4287,9 @@ static void _set_python_exception() { + + + /*@SWIG:/usr/local/share/swig/4.2.1/typemaps/exception.swg,59,SWIG_CATCH_STDEXCEPT@*/ /* catching std::exception */ catch (std::invalid_argument& e) { SWIG_exception_fail(SWIG_ValueError, e.what() ); diff --git a/src/swig-0_27_7/easyaccess_wrap.cxx b/src/swig-0_27_7/easyaccess_wrap.cxx index 1fd966d1..cf47c977 100644 --- a/src/swig-0_27_7/easyaccess_wrap.cxx +++ b/src/swig-0_27_7/easyaccess_wrap.cxx @@ -4182,19 +4182,21 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4241,6 +4243,9 @@ static void _set_python_exception() { + + + /*@SWIG:/usr/local/share/swig/4.2.1/typemaps/exception.swg,59,SWIG_CATCH_STDEXCEPT@*/ /* catching std::exception */ catch (std::invalid_argument& e) { SWIG_exception_fail(SWIG_ValueError, e.what() ); diff --git a/src/swig-0_27_7/error_wrap.cxx b/src/swig-0_27_7/error_wrap.cxx index 1b1043e7..5f6b91bd 100644 --- a/src/swig-0_27_7/error_wrap.cxx +++ b/src/swig-0_27_7/error_wrap.cxx @@ -4153,19 +4153,21 @@ static PyObject* exiv2_module = NULL; static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; diff --git a/src/swig-0_27_7/exif_wrap.cxx b/src/swig-0_27_7/exif_wrap.cxx index 06e23f73..5e93c161 100644 --- a/src/swig-0_27_7/exif_wrap.cxx +++ b/src/swig-0_27_7/exif_wrap.cxx @@ -4242,19 +4242,21 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4301,6 +4303,9 @@ static void _set_python_exception() { + + + /*@SWIG:/usr/local/share/swig/4.2.1/typemaps/exception.swg,59,SWIG_CATCH_STDEXCEPT@*/ /* catching std::exception */ catch (std::invalid_argument& e) { SWIG_exception_fail(SWIG_ValueError, e.what() ); diff --git a/src/swig-0_27_7/image_wrap.cxx b/src/swig-0_27_7/image_wrap.cxx index 2a74cf8e..ad8f2f63 100644 --- a/src/swig-0_27_7/image_wrap.cxx +++ b/src/swig-0_27_7/image_wrap.cxx @@ -4255,19 +4255,21 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4314,6 +4316,9 @@ static void _set_python_exception() { + + + /*@SWIG:/usr/local/share/swig/4.2.1/typemaps/exception.swg,59,SWIG_CATCH_STDEXCEPT@*/ /* catching std::exception */ catch (std::invalid_argument& e) { SWIG_exception_fail(SWIG_ValueError, e.what() ); diff --git a/src/swig-0_27_7/iptc_wrap.cxx b/src/swig-0_27_7/iptc_wrap.cxx index 6f20bd0f..afce7de5 100644 --- a/src/swig-0_27_7/iptc_wrap.cxx +++ b/src/swig-0_27_7/iptc_wrap.cxx @@ -4240,19 +4240,21 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4299,6 +4301,9 @@ static void _set_python_exception() { + + + /*@SWIG:/usr/local/share/swig/4.2.1/typemaps/exception.swg,59,SWIG_CATCH_STDEXCEPT@*/ /* catching std::exception */ catch (std::invalid_argument& e) { SWIG_exception_fail(SWIG_ValueError, e.what() ); diff --git a/src/swig-0_27_7/metadatum_wrap.cxx b/src/swig-0_27_7/metadatum_wrap.cxx index 2c1576f6..edd8a604 100644 --- a/src/swig-0_27_7/metadatum_wrap.cxx +++ b/src/swig-0_27_7/metadatum_wrap.cxx @@ -4226,19 +4226,21 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4285,6 +4287,9 @@ static void _set_python_exception() { + + + /*@SWIG:/usr/local/share/swig/4.2.1/typemaps/exception.swg,59,SWIG_CATCH_STDEXCEPT@*/ /* catching std::exception */ catch (std::invalid_argument& e) { SWIG_exception_fail(SWIG_ValueError, e.what() ); diff --git a/src/swig-0_27_7/preview_wrap.cxx b/src/swig-0_27_7/preview_wrap.cxx index 69854b0a..45be809e 100644 --- a/src/swig-0_27_7/preview_wrap.cxx +++ b/src/swig-0_27_7/preview_wrap.cxx @@ -4410,19 +4410,21 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4469,6 +4471,9 @@ static void _set_python_exception() { + + + /*@SWIG:/usr/local/share/swig/4.2.1/typemaps/exception.swg,59,SWIG_CATCH_STDEXCEPT@*/ /* catching std::exception */ catch (std::invalid_argument& e) { SWIG_exception_fail(SWIG_ValueError, e.what() ); diff --git a/src/swig-0_27_7/properties_wrap.cxx b/src/swig-0_27_7/properties_wrap.cxx index 675a9e49..10c36ab5 100644 --- a/src/swig-0_27_7/properties_wrap.cxx +++ b/src/swig-0_27_7/properties_wrap.cxx @@ -4228,19 +4228,21 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4287,6 +4289,9 @@ static void _set_python_exception() { + + + /*@SWIG:/usr/local/share/swig/4.2.1/typemaps/exception.swg,59,SWIG_CATCH_STDEXCEPT@*/ /* catching std::exception */ catch (std::invalid_argument& e) { SWIG_exception_fail(SWIG_ValueError, e.what() ); diff --git a/src/swig-0_27_7/tags_wrap.cxx b/src/swig-0_27_7/tags_wrap.cxx index cad6e68a..6e7c83f3 100644 --- a/src/swig-0_27_7/tags_wrap.cxx +++ b/src/swig-0_27_7/tags_wrap.cxx @@ -4228,19 +4228,21 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4287,6 +4289,9 @@ static void _set_python_exception() { + + + /*@SWIG:/usr/local/share/swig/4.2.1/typemaps/exception.swg,59,SWIG_CATCH_STDEXCEPT@*/ /* catching std::exception */ catch (std::invalid_argument& e) { SWIG_exception_fail(SWIG_ValueError, e.what() ); diff --git a/src/swig-0_27_7/types_wrap.cxx b/src/swig-0_27_7/types_wrap.cxx index 49568af3..2cb304dd 100644 --- a/src/swig-0_27_7/types_wrap.cxx +++ b/src/swig-0_27_7/types_wrap.cxx @@ -4214,19 +4214,21 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4273,6 +4275,9 @@ static void _set_python_exception() { + + + /*@SWIG:/usr/local/share/swig/4.2.1/typemaps/exception.swg,59,SWIG_CATCH_STDEXCEPT@*/ /* catching std::exception */ catch (std::invalid_argument& e) { SWIG_exception_fail(SWIG_ValueError, e.what() ); diff --git a/src/swig-0_27_7/value_wrap.cxx b/src/swig-0_27_7/value_wrap.cxx index 097879a3..46325b8a 100644 --- a/src/swig-0_27_7/value_wrap.cxx +++ b/src/swig-0_27_7/value_wrap.cxx @@ -4398,19 +4398,21 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4457,6 +4459,9 @@ static void _set_python_exception() { + + + /*@SWIG:/usr/local/share/swig/4.2.1/typemaps/exception.swg,59,SWIG_CATCH_STDEXCEPT@*/ /* catching std::exception */ catch (std::invalid_argument& e) { SWIG_exception_fail(SWIG_ValueError, e.what() ); diff --git a/src/swig-0_27_7/version_wrap.cxx b/src/swig-0_27_7/version_wrap.cxx index 9f43f1d1..07a0a57a 100644 --- a/src/swig-0_27_7/version_wrap.cxx +++ b/src/swig-0_27_7/version_wrap.cxx @@ -4194,19 +4194,21 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4253,6 +4255,9 @@ static void _set_python_exception() { + + + /*@SWIG:/usr/local/share/swig/4.2.1/typemaps/exception.swg,59,SWIG_CATCH_STDEXCEPT@*/ /* catching std::exception */ catch (std::invalid_argument& e) { SWIG_exception_fail(SWIG_ValueError, e.what() ); diff --git a/src/swig-0_27_7/xmp_wrap.cxx b/src/swig-0_27_7/xmp_wrap.cxx index 3956ef16..3714cdb7 100644 --- a/src/swig-0_27_7/xmp_wrap.cxx +++ b/src/swig-0_27_7/xmp_wrap.cxx @@ -4242,19 +4242,21 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4301,6 +4303,9 @@ static void _set_python_exception() { + + + /*@SWIG:/usr/local/share/swig/4.2.1/typemaps/exception.swg,59,SWIG_CATCH_STDEXCEPT@*/ /* catching std::exception */ catch (std::invalid_argument& e) { SWIG_exception_fail(SWIG_ValueError, e.what() ); diff --git a/src/swig-0_28_3/basicio_wrap.cxx b/src/swig-0_28_3/basicio_wrap.cxx index e17653c9..c5a2c596 100644 --- a/src/swig-0_28_3/basicio_wrap.cxx +++ b/src/swig-0_28_3/basicio_wrap.cxx @@ -4205,19 +4205,21 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4258,8 +4260,11 @@ static void _set_python_exception() { catch(Exiv2::Error const& e) { + std::string msg = e.what(); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum(e.code()), e.what()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_28_3/datasets_wrap.cxx b/src/swig-0_28_3/datasets_wrap.cxx index a1b86654..c1c7432b 100644 --- a/src/swig-0_28_3/datasets_wrap.cxx +++ b/src/swig-0_28_3/datasets_wrap.cxx @@ -4226,19 +4226,21 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4279,8 +4281,11 @@ static void _set_python_exception() { catch(Exiv2::Error const& e) { + std::string msg = e.what(); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum(e.code()), e.what()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_28_3/easyaccess_wrap.cxx b/src/swig-0_28_3/easyaccess_wrap.cxx index 1a9e95ef..aa1cc6cb 100644 --- a/src/swig-0_28_3/easyaccess_wrap.cxx +++ b/src/swig-0_28_3/easyaccess_wrap.cxx @@ -4182,19 +4182,21 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4235,8 +4237,11 @@ static void _set_python_exception() { catch(Exiv2::Error const& e) { + std::string msg = e.what(); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum(e.code()), e.what()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_28_3/error_wrap.cxx b/src/swig-0_28_3/error_wrap.cxx index c359a900..af2bb1e3 100644 --- a/src/swig-0_28_3/error_wrap.cxx +++ b/src/swig-0_28_3/error_wrap.cxx @@ -4153,19 +4153,21 @@ static PyObject* exiv2_module = NULL; static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; diff --git a/src/swig-0_28_3/exif_wrap.cxx b/src/swig-0_28_3/exif_wrap.cxx index bf05d0bd..b5b028e1 100644 --- a/src/swig-0_28_3/exif_wrap.cxx +++ b/src/swig-0_28_3/exif_wrap.cxx @@ -4242,19 +4242,21 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4295,8 +4297,11 @@ static void _set_python_exception() { catch(Exiv2::Error const& e) { + std::string msg = e.what(); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum(e.code()), e.what()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_28_3/image_wrap.cxx b/src/swig-0_28_3/image_wrap.cxx index 0528e4e3..cb8eb054 100644 --- a/src/swig-0_28_3/image_wrap.cxx +++ b/src/swig-0_28_3/image_wrap.cxx @@ -4255,19 +4255,21 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4308,8 +4310,11 @@ static void _set_python_exception() { catch(Exiv2::Error const& e) { + std::string msg = e.what(); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum(e.code()), e.what()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_28_3/iptc_wrap.cxx b/src/swig-0_28_3/iptc_wrap.cxx index 39c3d54a..015f806f 100644 --- a/src/swig-0_28_3/iptc_wrap.cxx +++ b/src/swig-0_28_3/iptc_wrap.cxx @@ -4240,19 +4240,21 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4293,8 +4295,11 @@ static void _set_python_exception() { catch(Exiv2::Error const& e) { + std::string msg = e.what(); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum(e.code()), e.what()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_28_3/metadatum_wrap.cxx b/src/swig-0_28_3/metadatum_wrap.cxx index a2c73ed0..22d2124c 100644 --- a/src/swig-0_28_3/metadatum_wrap.cxx +++ b/src/swig-0_28_3/metadatum_wrap.cxx @@ -4226,19 +4226,21 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4279,8 +4281,11 @@ static void _set_python_exception() { catch(Exiv2::Error const& e) { + std::string msg = e.what(); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum(e.code()), e.what()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_28_3/preview_wrap.cxx b/src/swig-0_28_3/preview_wrap.cxx index e4f2c45e..d7bc1b4c 100644 --- a/src/swig-0_28_3/preview_wrap.cxx +++ b/src/swig-0_28_3/preview_wrap.cxx @@ -4410,19 +4410,21 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4463,8 +4465,11 @@ static void _set_python_exception() { catch(Exiv2::Error const& e) { + std::string msg = e.what(); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum(e.code()), e.what()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_28_3/properties_wrap.cxx b/src/swig-0_28_3/properties_wrap.cxx index 042f35d5..15b0aba2 100644 --- a/src/swig-0_28_3/properties_wrap.cxx +++ b/src/swig-0_28_3/properties_wrap.cxx @@ -4228,19 +4228,21 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4281,8 +4283,11 @@ static void _set_python_exception() { catch(Exiv2::Error const& e) { + std::string msg = e.what(); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum(e.code()), e.what()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_28_3/tags_wrap.cxx b/src/swig-0_28_3/tags_wrap.cxx index c7bba8a9..75b5a03c 100644 --- a/src/swig-0_28_3/tags_wrap.cxx +++ b/src/swig-0_28_3/tags_wrap.cxx @@ -4228,19 +4228,21 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4281,8 +4283,11 @@ static void _set_python_exception() { catch(Exiv2::Error const& e) { + std::string msg = e.what(); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum(e.code()), e.what()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_28_3/types_wrap.cxx b/src/swig-0_28_3/types_wrap.cxx index 825e3a2c..3000c42a 100644 --- a/src/swig-0_28_3/types_wrap.cxx +++ b/src/swig-0_28_3/types_wrap.cxx @@ -4214,19 +4214,21 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4267,8 +4269,11 @@ static void _set_python_exception() { catch(Exiv2::Error const& e) { + std::string msg = e.what(); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum(e.code()), e.what()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_28_3/value_wrap.cxx b/src/swig-0_28_3/value_wrap.cxx index 168c4417..66cc558b 100644 --- a/src/swig-0_28_3/value_wrap.cxx +++ b/src/swig-0_28_3/value_wrap.cxx @@ -4398,19 +4398,21 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4451,8 +4453,11 @@ static void _set_python_exception() { catch(Exiv2::Error const& e) { + std::string msg = e.what(); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum(e.code()), e.what()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_28_3/version_wrap.cxx b/src/swig-0_28_3/version_wrap.cxx index 7db5a5f9..bd3a7841 100644 --- a/src/swig-0_28_3/version_wrap.cxx +++ b/src/swig-0_28_3/version_wrap.cxx @@ -4194,19 +4194,21 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4247,8 +4249,11 @@ static void _set_python_exception() { catch(Exiv2::Error const& e) { + std::string msg = e.what(); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum(e.code()), e.what()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } diff --git a/src/swig-0_28_3/xmp_wrap.cxx b/src/swig-0_28_3/xmp_wrap.cxx index f7bffb6f..36bed8ed 100644 --- a/src/swig-0_28_3/xmp_wrap.cxx +++ b/src/swig-0_28_3/xmp_wrap.cxx @@ -4242,19 +4242,21 @@ static PyObject* py_from_enum(Exiv2::ErrorCode value) { static int _transcode(std::string *str, UINT cp_in, UINT cp_out) { if (cp_out == cp_in) return 0; - int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, NULL, 0); + int size = MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + NULL, 0); if (!size) return GetLastError(); std::wstring wide_str; wide_str.resize(size); - if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], -1, &wide_str[0], size)) + if (!MultiByteToWideChar(cp_in, 0, &(*str)[0], (int)str->size(), + &wide_str[0], size)) return GetLastError(); - size = WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + size = WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), NULL, 0, NULL, NULL); if (!size) return GetLastError(); str->resize(size); - if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], -1, + if (!WideCharToMultiByte(cp_out, 0, &wide_str[0], (int)wide_str.size(), &(*str)[0], size, NULL, NULL)) return GetLastError(); return 0; @@ -4295,8 +4297,11 @@ static void _set_python_exception() { catch(Exiv2::Error const& e) { + std::string msg = e.what(); + if (wcp_to_utf8(&msg)) + msg = e.what(); PyObject* args = Py_BuildValue( - "Ns", py_from_enum(e.code()), e.what()); + "Ns", py_from_enum((Exiv2::ErrorCode)e.code()), msg.c_str()); PyErr_SetObject(PyExc_Exiv2Error, args); Py_DECREF(args); } From 4b8165d51f62a14f59231b63d77c7d2f57838c3e Mon Sep 17 00:00:00 2001 From: Jim Easterbrook Date: Thu, 19 Sep 2024 08:12:34 +0100 Subject: [PATCH 09/10] Increment version number --- README.rst | 2 +- src/doc/requirements.txt | 2 +- src/swig-0_27_7/__init__.py | 4 ++-- src/swig-0_28_3/__init__.py | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.rst b/README.rst index 60ff9dbf..1c4208e2 100644 --- a/README.rst +++ b/README.rst @@ -1,4 +1,4 @@ -python-exiv2 v\ 0.17.0 +python-exiv2 v\ 0.17.1 ====================== python-exiv2 is a low level interface (or binding) to the exiv2_ C++ library. diff --git a/src/doc/requirements.txt b/src/doc/requirements.txt index 306fadde..cd43bb2b 100644 --- a/src/doc/requirements.txt +++ b/src/doc/requirements.txt @@ -1,3 +1,3 @@ -exiv2 <= 0.17.0 +exiv2 <= 0.17.1 sphinx == 7.2.6 sphinx-rtd-theme == 2.0.0 diff --git a/src/swig-0_27_7/__init__.py b/src/swig-0_27_7/__init__.py index 62863e28..7374b9ee 100644 --- a/src/swig-0_27_7/__init__.py +++ b/src/swig-0_27_7/__init__.py @@ -20,9 +20,9 @@ def __init__(self, code, message): self.message = message #: python-exiv2 version as a string -__version__ = "0.17.0" +__version__ = "0.17.1" #: python-exiv2 version as a tuple of ints -__version_tuple__ = tuple((0, 17, 0)) +__version_tuple__ = tuple((0, 17, 1)) __all__ = ["Exiv2Error"] from exiv2.basicio import * diff --git a/src/swig-0_28_3/__init__.py b/src/swig-0_28_3/__init__.py index 62863e28..7374b9ee 100644 --- a/src/swig-0_28_3/__init__.py +++ b/src/swig-0_28_3/__init__.py @@ -20,9 +20,9 @@ def __init__(self, code, message): self.message = message #: python-exiv2 version as a string -__version__ = "0.17.0" +__version__ = "0.17.1" #: python-exiv2 version as a tuple of ints -__version_tuple__ = tuple((0, 17, 0)) +__version_tuple__ = tuple((0, 17, 1)) __all__ = ["Exiv2Error"] from exiv2.basicio import * From 3a4bd4ede7f885742851b6535c8773d1bde90d36 Mon Sep 17 00:00:00 2001 From: Jim Easterbrook Date: Thu, 19 Sep 2024 08:12:54 +0100 Subject: [PATCH 10/10] Update change log --- CHANGELOG.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 700a8158..5dda9436 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -16,6 +16,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . +Changes in v0.17.1: + 1/ Fix crash when using localised exceptions on Windows. + Changes in v0.17.0: 1/ API change: derived classes of BasicIo are omitted from Python. 2/ Binary wheels incorporate libexiv2 v0.28.3.