Skip to content

Commit b2f1b03

Browse files
Adjust thread and exception wrappers in BasicIo
1 parent ad18355 commit b2f1b03

File tree

3 files changed

+25
-34
lines changed

3 files changed

+25
-34
lines changed

src/interface/basicio.i

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ UNIQUE_PTR(Exiv2::BasicIo);
6060
// Some calls don't raise exceptions
6161
%noexception Exiv2::BasicIo::eof;
6262
%noexception Exiv2::BasicIo::error;
63+
%noexception Exiv2::BasicIo::ioType;
6364
%noexception Exiv2::BasicIo::isopen;
6465
%noexception Exiv2::BasicIo::path;
6566

@@ -173,6 +174,8 @@ EXPOSE_OBJECT_BUFFER(Exiv2::BasicIo, true, true)
173174
A simple context manager for *mmap* / *munmap* data access. The
174175
*__enter__* method returns a :py:class:`memoryview` of the data."
175176
%ignore DataContext::DataContext;
177+
%thread DataContext::~DataContext;
178+
%thread DataContext::__exit__;
176179
%inline %{
177180
class DataContext {
178181
private:
@@ -184,9 +187,7 @@ public:
184187
parent(parent), isWriteable(isWriteable), mapped(false) {};
185188
~DataContext() {
186189
if (mapped) {
187-
SWIG_PYTHON_THREAD_BEGIN_ALLOW;
188190
parent->munmap();
189-
SWIG_PYTHON_THREAD_END_ALLOW;
190191
parent->close();
191192
}
192193
};
@@ -207,11 +208,9 @@ public:
207208
};
208209
bool __exit__(PyObject* exc_type, PyObject* exc_val, PyObject* exc_tb) {
209210
if (mapped) {
210-
SWIG_PYTHON_THREAD_BEGIN_ALLOW;
211211
parent->munmap();
212212
mapped = false;
213213
parent->close();
214-
SWIG_PYTHON_THREAD_END_ALLOW;
215214
}
216215
return false;
217216
};

src/swig-0_27_7/basicio_wrap.cxx

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4434,9 +4434,7 @@ class DataContext {
44344434
parent(parent), isWriteable(isWriteable), mapped(false) {};
44354435
~DataContext() {
44364436
if (mapped) {
4437-
SWIG_PYTHON_THREAD_BEGIN_ALLOW;
44384437
parent->munmap();
4439-
SWIG_PYTHON_THREAD_END_ALLOW;
44404438
parent->close();
44414439
}
44424440
};
@@ -4457,11 +4455,9 @@ class DataContext {
44574455
};
44584456
bool __exit__(PyObject* exc_type, PyObject* exc_val, PyObject* exc_tb) {
44594457
if (mapped) {
4460-
SWIG_PYTHON_THREAD_BEGIN_ALLOW;
44614458
parent->munmap();
44624459
mapped = false;
44634460
parent->close();
4464-
SWIG_PYTHON_THREAD_END_ALLOW;
44654461
}
44664462
return false;
44674463
};
@@ -4861,7 +4857,11 @@ SWIGINTERN PyObject *_wrap_delete_DataContext(PyObject *self, PyObject *args) {
48614857
arg1 = reinterpret_cast< DataContext * >(argp1);
48624858
{
48634859
try {
4864-
delete arg1;
4860+
{
4861+
SWIG_PYTHON_THREAD_BEGIN_ALLOW;
4862+
delete arg1;
4863+
SWIG_PYTHON_THREAD_END_ALLOW;
4864+
}
48654865
}
48664866
catch(std::exception const& e) {
48674867
_set_python_exception();
@@ -4928,7 +4928,11 @@ SWIGINTERN PyObject *_wrap_DataContext___exit__(PyObject *self, PyObject *args)
49284928
arg4 = obj3;
49294929
{
49304930
try {
4931-
result = (bool)(arg1)->__exit__(arg2,arg3,arg4);
4931+
{
4932+
SWIG_PYTHON_THREAD_BEGIN_ALLOW;
4933+
result = (bool)(arg1)->__exit__(arg2,arg3,arg4);
4934+
SWIG_PYTHON_THREAD_END_ALLOW;
4935+
}
49324936
}
49334937
catch(std::exception const& e) {
49344938
_set_python_exception();
@@ -5757,15 +5761,7 @@ SWIGINTERN PyObject *_wrap_BasicIo_ioType(PyObject *self, PyObject *args) {
57575761
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BasicIo_ioType" "', argument " "1"" of type '" "Exiv2::BasicIo *""'");
57585762
}
57595763
arg1 = reinterpret_cast< Exiv2::BasicIo * >(argp1);
5760-
{
5761-
try {
5762-
result = (char *)Exiv2_BasicIo_ioType(arg1);
5763-
}
5764-
catch(std::exception const& e) {
5765-
_set_python_exception();
5766-
SWIG_fail;
5767-
}
5768-
}
5764+
result = (char *)Exiv2_BasicIo_ioType(arg1);
57695765
resultobj = SWIG_FromCharPtr((const char *)result);
57705766
return resultobj;
57715767
fail:

src/swig-0_28_5/basicio_wrap.cxx

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4435,9 +4435,7 @@ class DataContext {
44354435
parent(parent), isWriteable(isWriteable), mapped(false) {};
44364436
~DataContext() {
44374437
if (mapped) {
4438-
SWIG_PYTHON_THREAD_BEGIN_ALLOW;
44394438
parent->munmap();
4440-
SWIG_PYTHON_THREAD_END_ALLOW;
44414439
parent->close();
44424440
}
44434441
};
@@ -4458,11 +4456,9 @@ class DataContext {
44584456
};
44594457
bool __exit__(PyObject* exc_type, PyObject* exc_val, PyObject* exc_tb) {
44604458
if (mapped) {
4461-
SWIG_PYTHON_THREAD_BEGIN_ALLOW;
44624459
parent->munmap();
44634460
mapped = false;
44644461
parent->close();
4465-
SWIG_PYTHON_THREAD_END_ALLOW;
44664462
}
44674463
return false;
44684464
};
@@ -4966,7 +4962,11 @@ SWIGINTERN PyObject *_wrap_delete_DataContext(PyObject *self, PyObject *args) {
49664962
arg1 = reinterpret_cast< DataContext * >(argp1);
49674963
{
49684964
try {
4969-
delete arg1;
4965+
{
4966+
SWIG_PYTHON_THREAD_BEGIN_ALLOW;
4967+
delete arg1;
4968+
SWIG_PYTHON_THREAD_END_ALLOW;
4969+
}
49704970
}
49714971
catch(std::exception const& e) {
49724972
_set_python_exception();
@@ -5033,7 +5033,11 @@ SWIGINTERN PyObject *_wrap_DataContext___exit__(PyObject *self, PyObject *args)
50335033
arg4 = obj3;
50345034
{
50355035
try {
5036-
result = (bool)(arg1)->__exit__(arg2,arg3,arg4);
5036+
{
5037+
SWIG_PYTHON_THREAD_BEGIN_ALLOW;
5038+
result = (bool)(arg1)->__exit__(arg2,arg3,arg4);
5039+
SWIG_PYTHON_THREAD_END_ALLOW;
5040+
}
50375041
}
50385042
catch(std::exception const& e) {
50395043
_set_python_exception();
@@ -6025,15 +6029,7 @@ SWIGINTERN PyObject *_wrap_BasicIo_ioType(PyObject *self, PyObject *args) {
60256029
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BasicIo_ioType" "', argument " "1"" of type '" "Exiv2::BasicIo *""'");
60266030
}
60276031
arg1 = reinterpret_cast< Exiv2::BasicIo * >(argp1);
6028-
{
6029-
try {
6030-
result = (char *)Exiv2_BasicIo_ioType(arg1);
6031-
}
6032-
catch(std::exception const& e) {
6033-
_set_python_exception();
6034-
SWIG_fail;
6035-
}
6036-
}
6032+
result = (char *)Exiv2_BasicIo_ioType(arg1);
60376033
resultobj = SWIG_FromCharPtr((const char *)result);
60386034
return resultobj;
60396035
fail:

0 commit comments

Comments
 (0)