Skip to content

Commit 4f8cde5

Browse files
Undeprecate DataValue.copy
Unlike some other Value subtypes, DataValue doesn't expose its private data with a data() or similar method.
1 parent b5a458e commit 4f8cde5

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

src/interface/value.i

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,9 @@ VALUE_SUBCLASS(Exiv2::LangAltValue, LangAltValue)
495495
VALUE_SUBCLASS(Exiv2::XmpArrayValue, XmpArrayValue)
496496
VALUE_SUBCLASS(Exiv2::XmpTextValue, XmpTextValue)
497497

498+
// Undeprecate DataValue::copy - it's the only way to get the data
499+
EXCEPTION(Exiv2::DataValue::copy)
500+
498501
// Allow access to Exiv2::StringValueBase and Exiv2::XmpTextValue raw data
499502
%define RAW_STRING_DATA(class)
500503
RETURN_VIEW(const char* data, arg1->value_.size(), PyBUF_READ, class##::data)

src/swig-0_27_7/value_wrap.cxx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8722,8 +8722,6 @@ SWIGINTERN PyObject *_wrap_DataValue_copy(PyObject *self, PyObject *args) {
87228722
}
87238723
}
87248724
{
8725-
PyErr_WarnEx(PyExc_DeprecationWarning,
8726-
"Python scripts should not need to call ""Exiv2::DataValue::copy", 1);
87278725
try {
87288726
result = (long)((Exiv2::DataValue const *)arg1)->copy(arg2,arg3);
87298727
}

src/swig-0_28_5/value_wrap.cxx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8757,8 +8757,6 @@ SWIGINTERN PyObject *_wrap_DataValue_copy(PyObject *self, PyObject *args) {
87578757
}
87588758
}
87598759
{
8760-
PyErr_WarnEx(PyExc_DeprecationWarning,
8761-
"Python scripts should not need to call ""Exiv2::DataValue::copy", 1);
87628760
try {
87638761
result = ((Exiv2::DataValue const *)arg1)->copy(arg2,arg3);
87648762
}

tests/test_value.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,13 @@ def do_common_tests(self, value, type_id, string, data, sequence=None):
4242
self.assertIsInstance(result, type(value))
4343
self.assertEqual(str(result), str(value))
4444
result = bytearray(len(data))
45-
with self.assertWarns(DeprecationWarning):
46-
self.assertEqual(
47-
value.copy(result, exiv2.ByteOrder.littleEndian), len(result))
45+
if type_id in (exiv2.TypeId.undefined, exiv2.TypeId.unsignedByte):
46+
self.assertEqual(value.copy(
47+
result, exiv2.ByteOrder.littleEndian), len(result))
48+
else:
49+
with self.assertWarns(DeprecationWarning):
50+
self.assertEqual(value.copy(
51+
result, exiv2.ByteOrder.littleEndian), len(result))
4852
self.assertEqual(result, data)
4953
if sequence:
5054
self.check_result(value.count(), int, len(sequence))
@@ -322,8 +326,7 @@ def test_XmpTextValue(self):
322326
def test_DataValue(self):
323327
def check_data(value, data):
324328
copy = bytearray(len(data))
325-
with self.assertWarns(DeprecationWarning):
326-
self.assertEqual(value.copy(copy), len(data))
329+
self.assertEqual(value.copy(copy), len(data))
327330
self.assertEqual(copy, data)
328331

329332
data = bytes(random.choices(range(256), k=128))

0 commit comments

Comments
 (0)