Skip to content

Commit ea7689a

Browse files
Reenable exception handler for metadatum methods
Needed as the iterator versions now throw an exception if the iterator is invalid.
1 parent f80d693 commit ea7689a

File tree

7 files changed

+217
-28
lines changed

7 files changed

+217
-28
lines changed

src/interface/metadatum.i

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// python-exiv2 - Python interface to libexiv2
22
// http://github.com/jim-easterbrook/python-exiv2
3-
// Copyright (C) 2021-24 Jim Easterbrook [email protected]
3+
// Copyright (C) 2021-25 Jim Easterbrook [email protected]
44
//
55
// This program is free software: you can redistribute it and/or modify
66
// it under the terms of the GNU General Public License as published by
@@ -61,9 +61,6 @@ EXTEND_KEY(Exiv2::Key);
6161
%define EXTEND_METADATUM(datum_type)
6262
// Ignore overloaded default parameter version
6363
%ignore datum_type::write(std::ostream &) const;
64-
// Turn off exception checking for methods that are guaranteed not to throw
65-
%noexception datum_type::count;
66-
%noexception datum_type::size;
6764
// Keep a reference to Metadatum when calling value()
6865
KEEP_REFERENCE(const Exiv2::Value&)
6966
// Keep a reference to any object that returns a reference to a datum.

src/swig-0_27_7/exif_wrap.cxx

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6570,7 +6570,15 @@ SWIGINTERN PyObject *_wrap_ExifData_iterator_count(PyObject *self, PyObject *arg
65706570
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ExifData_iterator_count" "', argument " "1"" of type '" "ExifData_iterator const *""'");
65716571
}
65726572
arg1 = reinterpret_cast< ExifData_iterator * >(argp1);
6573-
result = (long)(*arg1)->count();
6573+
{
6574+
try {
6575+
result = (long)(*arg1)->count();
6576+
}
6577+
catch(std::exception const& e) {
6578+
_set_python_exception();
6579+
SWIG_fail;
6580+
}
6581+
}
65746582
resultobj = SWIG_From_long(static_cast< long >(result));
65756583
return resultobj;
65766584
fail:
@@ -6591,7 +6599,15 @@ SWIGINTERN PyObject *_wrap_ExifData_iterator_size(PyObject *self, PyObject *args
65916599
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ExifData_iterator_size" "', argument " "1"" of type '" "ExifData_iterator const *""'");
65926600
}
65936601
arg1 = reinterpret_cast< ExifData_iterator * >(argp1);
6594-
result = (long)(*arg1)->size();
6602+
{
6603+
try {
6604+
result = (long)(*arg1)->size();
6605+
}
6606+
catch(std::exception const& e) {
6607+
_set_python_exception();
6608+
SWIG_fail;
6609+
}
6610+
}
65956611
resultobj = SWIG_From_long(static_cast< long >(result));
65966612
return resultobj;
65976613
fail:
@@ -8021,7 +8037,15 @@ SWIGINTERN PyObject *_wrap_Exifdatum_count(PyObject *self, PyObject *args) {
80218037
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Exifdatum_count" "', argument " "1"" of type '" "Exiv2::Exifdatum const *""'");
80228038
}
80238039
arg1 = reinterpret_cast< Exiv2::Exifdatum * >(argp1);
8024-
result = (long)((Exiv2::Exifdatum const *)arg1)->count();
8040+
{
8041+
try {
8042+
result = (long)((Exiv2::Exifdatum const *)arg1)->count();
8043+
}
8044+
catch(std::exception const& e) {
8045+
_set_python_exception();
8046+
SWIG_fail;
8047+
}
8048+
}
80258049
resultobj = SWIG_From_long(static_cast< long >(result));
80268050
return resultobj;
80278051
fail:
@@ -8042,7 +8066,15 @@ SWIGINTERN PyObject *_wrap_Exifdatum_size(PyObject *self, PyObject *args) {
80428066
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Exifdatum_size" "', argument " "1"" of type '" "Exiv2::Exifdatum const *""'");
80438067
}
80448068
arg1 = reinterpret_cast< Exiv2::Exifdatum * >(argp1);
8045-
result = (long)((Exiv2::Exifdatum const *)arg1)->size();
8069+
{
8070+
try {
8071+
result = (long)((Exiv2::Exifdatum const *)arg1)->size();
8072+
}
8073+
catch(std::exception const& e) {
8074+
_set_python_exception();
8075+
SWIG_fail;
8076+
}
8077+
}
80468078
resultobj = SWIG_From_long(static_cast< long >(result));
80478079
return resultobj;
80488080
fail:

src/swig-0_27_7/iptc_wrap.cxx

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6456,7 +6456,15 @@ SWIGINTERN PyObject *_wrap_IptcData_iterator_count(PyObject *self, PyObject *arg
64566456
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IptcData_iterator_count" "', argument " "1"" of type '" "IptcData_iterator const *""'");
64576457
}
64586458
arg1 = reinterpret_cast< IptcData_iterator * >(argp1);
6459-
result = (long)(*arg1)->count();
6459+
{
6460+
try {
6461+
result = (long)(*arg1)->count();
6462+
}
6463+
catch(std::exception const& e) {
6464+
_set_python_exception();
6465+
SWIG_fail;
6466+
}
6467+
}
64606468
resultobj = SWIG_From_long(static_cast< long >(result));
64616469
return resultobj;
64626470
fail:
@@ -6477,7 +6485,15 @@ SWIGINTERN PyObject *_wrap_IptcData_iterator_size(PyObject *self, PyObject *args
64776485
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IptcData_iterator_size" "', argument " "1"" of type '" "IptcData_iterator const *""'");
64786486
}
64796487
arg1 = reinterpret_cast< IptcData_iterator * >(argp1);
6480-
result = (long)(*arg1)->size();
6488+
{
6489+
try {
6490+
result = (long)(*arg1)->size();
6491+
}
6492+
catch(std::exception const& e) {
6493+
_set_python_exception();
6494+
SWIG_fail;
6495+
}
6496+
}
64816497
resultobj = SWIG_From_long(static_cast< long >(result));
64826498
return resultobj;
64836499
fail:
@@ -7796,7 +7812,15 @@ SWIGINTERN PyObject *_wrap_Iptcdatum_count(PyObject *self, PyObject *args) {
77967812
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Iptcdatum_count" "', argument " "1"" of type '" "Exiv2::Iptcdatum const *""'");
77977813
}
77987814
arg1 = reinterpret_cast< Exiv2::Iptcdatum * >(argp1);
7799-
result = (long)((Exiv2::Iptcdatum const *)arg1)->count();
7815+
{
7816+
try {
7817+
result = (long)((Exiv2::Iptcdatum const *)arg1)->count();
7818+
}
7819+
catch(std::exception const& e) {
7820+
_set_python_exception();
7821+
SWIG_fail;
7822+
}
7823+
}
78007824
resultobj = SWIG_From_long(static_cast< long >(result));
78017825
return resultobj;
78027826
fail:
@@ -7817,7 +7841,15 @@ SWIGINTERN PyObject *_wrap_Iptcdatum_size(PyObject *self, PyObject *args) {
78177841
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Iptcdatum_size" "', argument " "1"" of type '" "Exiv2::Iptcdatum const *""'");
78187842
}
78197843
arg1 = reinterpret_cast< Exiv2::Iptcdatum * >(argp1);
7820-
result = (long)((Exiv2::Iptcdatum const *)arg1)->size();
7844+
{
7845+
try {
7846+
result = (long)((Exiv2::Iptcdatum const *)arg1)->size();
7847+
}
7848+
catch(std::exception const& e) {
7849+
_set_python_exception();
7850+
SWIG_fail;
7851+
}
7852+
}
78217853
resultobj = SWIG_From_long(static_cast< long >(result));
78227854
return resultobj;
78237855
fail:

src/swig-0_27_7/xmp_wrap.cxx

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6398,7 +6398,15 @@ SWIGINTERN PyObject *_wrap_XmpData_iterator_count(PyObject *self, PyObject *args
63986398
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XmpData_iterator_count" "', argument " "1"" of type '" "XmpData_iterator const *""'");
63996399
}
64006400
arg1 = reinterpret_cast< XmpData_iterator * >(argp1);
6401-
result = (long)(*arg1)->count();
6401+
{
6402+
try {
6403+
result = (long)(*arg1)->count();
6404+
}
6405+
catch(std::exception const& e) {
6406+
_set_python_exception();
6407+
SWIG_fail;
6408+
}
6409+
}
64026410
resultobj = SWIG_From_long(static_cast< long >(result));
64036411
return resultobj;
64046412
fail:
@@ -6419,7 +6427,15 @@ SWIGINTERN PyObject *_wrap_XmpData_iterator_size(PyObject *self, PyObject *args)
64196427
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XmpData_iterator_size" "', argument " "1"" of type '" "XmpData_iterator const *""'");
64206428
}
64216429
arg1 = reinterpret_cast< XmpData_iterator * >(argp1);
6422-
result = (long)(*arg1)->size();
6430+
{
6431+
try {
6432+
result = (long)(*arg1)->size();
6433+
}
6434+
catch(std::exception const& e) {
6435+
_set_python_exception();
6436+
SWIG_fail;
6437+
}
6438+
}
64236439
resultobj = SWIG_From_long(static_cast< long >(result));
64246440
return resultobj;
64256441
fail:
@@ -7680,7 +7696,15 @@ SWIGINTERN PyObject *_wrap_Xmpdatum_count(PyObject *self, PyObject *args) {
76807696
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Xmpdatum_count" "', argument " "1"" of type '" "Exiv2::Xmpdatum const *""'");
76817697
}
76827698
arg1 = reinterpret_cast< Exiv2::Xmpdatum * >(argp1);
7683-
result = (long)((Exiv2::Xmpdatum const *)arg1)->count();
7699+
{
7700+
try {
7701+
result = (long)((Exiv2::Xmpdatum const *)arg1)->count();
7702+
}
7703+
catch(std::exception const& e) {
7704+
_set_python_exception();
7705+
SWIG_fail;
7706+
}
7707+
}
76847708
resultobj = SWIG_From_long(static_cast< long >(result));
76857709
return resultobj;
76867710
fail:
@@ -7701,7 +7725,15 @@ SWIGINTERN PyObject *_wrap_Xmpdatum_size(PyObject *self, PyObject *args) {
77017725
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Xmpdatum_size" "', argument " "1"" of type '" "Exiv2::Xmpdatum const *""'");
77027726
}
77037727
arg1 = reinterpret_cast< Exiv2::Xmpdatum * >(argp1);
7704-
result = (long)((Exiv2::Xmpdatum const *)arg1)->size();
7728+
{
7729+
try {
7730+
result = (long)((Exiv2::Xmpdatum const *)arg1)->size();
7731+
}
7732+
catch(std::exception const& e) {
7733+
_set_python_exception();
7734+
SWIG_fail;
7735+
}
7736+
}
77057737
resultobj = SWIG_From_long(static_cast< long >(result));
77067738
return resultobj;
77077739
fail:

src/swig-0_28_5/exif_wrap.cxx

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6635,7 +6635,15 @@ SWIGINTERN PyObject *_wrap_ExifData_iterator_count(PyObject *self, PyObject *arg
66356635
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ExifData_iterator_count" "', argument " "1"" of type '" "ExifData_iterator const *""'");
66366636
}
66376637
arg1 = reinterpret_cast< ExifData_iterator * >(argp1);
6638-
result = (*arg1)->count();
6638+
{
6639+
try {
6640+
result = (*arg1)->count();
6641+
}
6642+
catch(std::exception const& e) {
6643+
_set_python_exception();
6644+
SWIG_fail;
6645+
}
6646+
}
66396647
resultobj = SWIG_From_size_t(static_cast< size_t >(result));
66406648
return resultobj;
66416649
fail:
@@ -6656,7 +6664,15 @@ SWIGINTERN PyObject *_wrap_ExifData_iterator_size(PyObject *self, PyObject *args
66566664
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ExifData_iterator_size" "', argument " "1"" of type '" "ExifData_iterator const *""'");
66576665
}
66586666
arg1 = reinterpret_cast< ExifData_iterator * >(argp1);
6659-
result = (*arg1)->size();
6667+
{
6668+
try {
6669+
result = (*arg1)->size();
6670+
}
6671+
catch(std::exception const& e) {
6672+
_set_python_exception();
6673+
SWIG_fail;
6674+
}
6675+
}
66606676
resultobj = SWIG_From_size_t(static_cast< size_t >(result));
66616677
return resultobj;
66626678
fail:
@@ -8158,7 +8174,15 @@ SWIGINTERN PyObject *_wrap_Exifdatum_count(PyObject *self, PyObject *args) {
81588174
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Exifdatum_count" "', argument " "1"" of type '" "Exiv2::Exifdatum const *""'");
81598175
}
81608176
arg1 = reinterpret_cast< Exiv2::Exifdatum * >(argp1);
8161-
result = ((Exiv2::Exifdatum const *)arg1)->count();
8177+
{
8178+
try {
8179+
result = ((Exiv2::Exifdatum const *)arg1)->count();
8180+
}
8181+
catch(std::exception const& e) {
8182+
_set_python_exception();
8183+
SWIG_fail;
8184+
}
8185+
}
81628186
resultobj = SWIG_From_size_t(static_cast< size_t >(result));
81638187
return resultobj;
81648188
fail:
@@ -8179,7 +8203,15 @@ SWIGINTERN PyObject *_wrap_Exifdatum_size(PyObject *self, PyObject *args) {
81798203
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Exifdatum_size" "', argument " "1"" of type '" "Exiv2::Exifdatum const *""'");
81808204
}
81818205
arg1 = reinterpret_cast< Exiv2::Exifdatum * >(argp1);
8182-
result = ((Exiv2::Exifdatum const *)arg1)->size();
8206+
{
8207+
try {
8208+
result = ((Exiv2::Exifdatum const *)arg1)->size();
8209+
}
8210+
catch(std::exception const& e) {
8211+
_set_python_exception();
8212+
SWIG_fail;
8213+
}
8214+
}
81838215
resultobj = SWIG_From_size_t(static_cast< size_t >(result));
81848216
return resultobj;
81858217
fail:

src/swig-0_28_5/iptc_wrap.cxx

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6528,7 +6528,15 @@ SWIGINTERN PyObject *_wrap_IptcData_iterator_count(PyObject *self, PyObject *arg
65286528
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IptcData_iterator_count" "', argument " "1"" of type '" "IptcData_iterator const *""'");
65296529
}
65306530
arg1 = reinterpret_cast< IptcData_iterator * >(argp1);
6531-
result = (*arg1)->count();
6531+
{
6532+
try {
6533+
result = (*arg1)->count();
6534+
}
6535+
catch(std::exception const& e) {
6536+
_set_python_exception();
6537+
SWIG_fail;
6538+
}
6539+
}
65326540
resultobj = SWIG_From_size_t(static_cast< size_t >(result));
65336541
return resultobj;
65346542
fail:
@@ -6549,7 +6557,15 @@ SWIGINTERN PyObject *_wrap_IptcData_iterator_size(PyObject *self, PyObject *args
65496557
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IptcData_iterator_size" "', argument " "1"" of type '" "IptcData_iterator const *""'");
65506558
}
65516559
arg1 = reinterpret_cast< IptcData_iterator * >(argp1);
6552-
result = (*arg1)->size();
6560+
{
6561+
try {
6562+
result = (*arg1)->size();
6563+
}
6564+
catch(std::exception const& e) {
6565+
_set_python_exception();
6566+
SWIG_fail;
6567+
}
6568+
}
65536569
resultobj = SWIG_From_size_t(static_cast< size_t >(result));
65546570
return resultobj;
65556571
fail:
@@ -7940,7 +7956,15 @@ SWIGINTERN PyObject *_wrap_Iptcdatum_count(PyObject *self, PyObject *args) {
79407956
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Iptcdatum_count" "', argument " "1"" of type '" "Exiv2::Iptcdatum const *""'");
79417957
}
79427958
arg1 = reinterpret_cast< Exiv2::Iptcdatum * >(argp1);
7943-
result = ((Exiv2::Iptcdatum const *)arg1)->count();
7959+
{
7960+
try {
7961+
result = ((Exiv2::Iptcdatum const *)arg1)->count();
7962+
}
7963+
catch(std::exception const& e) {
7964+
_set_python_exception();
7965+
SWIG_fail;
7966+
}
7967+
}
79447968
resultobj = SWIG_From_size_t(static_cast< size_t >(result));
79457969
return resultobj;
79467970
fail:
@@ -7961,7 +7985,15 @@ SWIGINTERN PyObject *_wrap_Iptcdatum_size(PyObject *self, PyObject *args) {
79617985
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Iptcdatum_size" "', argument " "1"" of type '" "Exiv2::Iptcdatum const *""'");
79627986
}
79637987
arg1 = reinterpret_cast< Exiv2::Iptcdatum * >(argp1);
7964-
result = ((Exiv2::Iptcdatum const *)arg1)->size();
7988+
{
7989+
try {
7990+
result = ((Exiv2::Iptcdatum const *)arg1)->size();
7991+
}
7992+
catch(std::exception const& e) {
7993+
_set_python_exception();
7994+
SWIG_fail;
7995+
}
7996+
}
79657997
resultobj = SWIG_From_size_t(static_cast< size_t >(result));
79667998
return resultobj;
79677999
fail:

0 commit comments

Comments
 (0)