[Python-modules-commits] [mutagen] 01/11: Import mutagen_1.33.2.orig.tar.gz
Tristan Seligmann
mithrandi at moszumanska.debian.org
Sat Jul 16 16:29:58 UTC 2016
This is an automated email from the git hooks/post-receive script.
mithrandi pushed a commit to branch master
in repository mutagen.
commit ffdba0c7efe4bedb0f42e4c7ab3e159d20330384
Author: Tristan Seligmann <mithrandi at debian.org>
Date: Sat Jul 16 17:43:13 2016 +0200
Import mutagen_1.33.2.orig.tar.gz
---
NEWS | 6 ++++++
PKG-INFO | 2 +-
mutagen/__init__.py | 2 +-
mutagen/_util.py | 5 ++---
mutagen/apev2.py | 6 ++++--
tests/test___init__.py | 3 +--
tests/test__util.py | 34 ++++++++++++++++++++++++----------
7 files changed, 39 insertions(+), 19 deletions(-)
diff --git a/NEWS b/NEWS
index 96b9dbd..8313e8f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,9 @@
+1.33.2 - 2016.07.05
+-------------------
+
+* Fix loading of small ogg/apev2 files (1.33 regression)
+
+
1.33.1 - 2016.06.29
-------------------
diff --git a/PKG-INFO b/PKG-INFO
index 9d4d18d..12d386d 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: mutagen
-Version: 1.33.1
+Version: 1.33.2
Summary: read and write audio tags for many formats
Home-page: https://github.com/quodlibet/mutagen
Author: Michael Urman
diff --git a/mutagen/__init__.py b/mutagen/__init__.py
index 0152048..765f215 100644
--- a/mutagen/__init__.py
+++ b/mutagen/__init__.py
@@ -24,7 +24,7 @@ from mutagen._util import MutagenError
from mutagen._file import FileType, StreamInfo, File
from mutagen._tags import Tags, Metadata, PaddingInfo
-version = (1, 33, 1)
+version = (1, 33, 2)
"""Version tuple."""
version_string = ".".join(map(str, version))
diff --git a/mutagen/_util.py b/mutagen/_util.py
index c63374e..5afc5bc 100644
--- a/mutagen/_util.py
+++ b/mutagen/_util.py
@@ -452,7 +452,7 @@ _fill_cdata(cdata)
def get_size(fileobj):
- """Returns the size from the current position to the end of the file.
+ """Returns the size of the file.
The position when passed in will be preserved if no error occurs.
In case of an error raises IOError.
@@ -480,8 +480,7 @@ def seek_end(fileobj, offset):
if offset < 0:
raise ValueError
- size = fileobj.tell() + get_size(fileobj)
- if size < offset:
+ if get_size(fileobj) < offset:
fileobj.seek(0, 0)
else:
fileobj.seek(-offset, 2)
diff --git a/mutagen/apev2.py b/mutagen/apev2.py
index 7a9a336..cbcd04f 100644
--- a/mutagen/apev2.py
+++ b/mutagen/apev2.py
@@ -37,8 +37,8 @@ from collections import MutableSequence
from ._compat import (cBytesIO, PY3, text_type, PY2, reraise, swap_to_string,
xrange)
from mutagen import Metadata, FileType, StreamInfo
-from mutagen._util import (DictMixin, cdata, delete_bytes, total_ordering,
- MutagenError, loadfile, convert_error, seek_end)
+from mutagen._util import DictMixin, cdata, delete_bytes, total_ordering, \
+ MutagenError, loadfile, convert_error, seek_end, get_size
def is_valid_apev2_key(key):
@@ -139,6 +139,8 @@ class _APEv2Data(object):
# Check for an APEv2 tag followed by an ID3v1 tag at the end.
try:
+ if get_size(fileobj) < 128:
+ raise IOError
fileobj.seek(-128, 2)
if fileobj.read(3) == b"TAG":
diff --git a/tests/test___init__.py b/tests/test___init__.py
index df03b12..8ebb6b5 100644
--- a/tests/test___init__.py
+++ b/tests/test___init__.py
@@ -252,8 +252,7 @@ class TestFileObj(object):
elif whence == 1:
final_position = self._fileobj.tell() + offset
elif whence == 2:
- size = self._fileobj.tell() + get_size(self._fileobj)
- final_position = size + offset
+ final_position = get_size(self._fileobj) + offset
assert final_position >= 0, final_position
return self._fileobj.seek(offset, whence)
diff --git a/tests/test__util.py b/tests/test__util.py
index 6731a17..edb988d 100644
--- a/tests/test__util.py
+++ b/tests/test__util.py
@@ -514,17 +514,31 @@ class Tenum(TestCase):
class Tseek_end(TestCase):
+ def file(self, contents):
+ import tempfile
+ temp = tempfile.TemporaryFile()
+ temp.write(contents)
+ temp.flush()
+ temp.seek(0)
+ return temp
+
def test_seek_end(self):
- f = cBytesIO(b"foo")
- seek_end(f, 2)
- self.assertEqual(f.tell(), 1)
- seek_end(f, 3)
- self.assertEqual(f.tell(), 0)
- seek_end(f, 4)
- self.assertEqual(f.tell(), 0)
- seek_end(f, 0)
- self.assertEqual(f.tell(), 3)
- self.assertRaises(ValueError, seek_end, f, -1)
+ with self.file(b"foo") as f:
+ seek_end(f, 2)
+ self.assertEqual(f.tell(), 1)
+ seek_end(f, 3)
+ self.assertEqual(f.tell(), 0)
+ seek_end(f, 4)
+ self.assertEqual(f.tell(), 0)
+ seek_end(f, 0)
+ self.assertEqual(f.tell(), 3)
+ self.assertRaises(ValueError, seek_end, f, -1)
+
+ def test_seek_end_pos(self):
+ with self.file(b"foo") as f:
+ f.seek(10)
+ seek_end(f, 10)
+ self.assertEqual(f.tell(), 0)
class Tget_size(TestCase):
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/mutagen.git
More information about the Python-modules-commits
mailing list