leosongwei / mutagen

Automatically exported from code.google.com/p/mutagen
GNU General Public License v2.0
0 stars 0 forks source link

DeprecationWarning:: _util.py:151 :: to_int_be = staticmethod(lambda data: struct.pack('>i', data)) #63

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When deleting tags from an ogg vorbis file, I am getting a 
DeprecationWarning in Python 2.5.2.  

Here is an example:

Python 2.5.2 (r252:60911, Jan 20 2010, 23:14:04) 
[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from mutagen.oggvorbis import OggVorbis
>>> ogg = OggVorbis('test.ogg')
>>> ogg['title']
[u'Christmas Waltz']
>>> ogg.delete()
/usr/lib/python2.5/site-packages/mutagen/_util.py:151: DeprecationWarning: 
'i' format requires -2147483648 <= number <= 2147483647
  to_int_be = staticmethod(lambda data: struct.pack('>i', data))
>>> ogg.tags
[]

The delete() still works - is just throwing that warning.

Thanks! 

Original issue reported on code.google.com by damont...@gmail.com on 9 May 2010 at 7:12

GoogleCodeExporter commented 9 years ago
How large is the ogg file you are trying to tag?

Original comment by joe.wreschnig@gmail.com on 17 May 2010 at 8:08

GoogleCodeExporter commented 9 years ago
Pretty small !  The one that is throwing the error is 188KB (19.55 seconds, 
96000 bps).

And, it seems that only this small file is causing the depreciation warning.  
At least, from my limited testing.  
save() throws the same warning.

Thanks

Original comment by damont...@gmail.com on 18 May 2010 at 12:36

GoogleCodeExporter commented 9 years ago
Can you attach the file or email to me (at gmail)? I'm having no luck figuring 
this out otherwise.

Original comment by joe.wreschnig@gmail.com on 13 Jul 2010 at 3:56

GoogleCodeExporter commented 9 years ago
Here, you can download the file at: 
https://thornomad.s3.amazonaws.com/mutagen/test.ogg

Also - this is only an issue with Python 2.5 ... 2.6 does not seem to have this 
issue.

Sorry for the delay.  

Original comment by damont...@gmail.com on 28 Jul 2010 at 10:43

GoogleCodeExporter commented 9 years ago
I'm unable to reproduce this at all in 2.5.4 or 2.6.5. I'm a little worried by 
the error, but I also know 2.6 made all those DeprecationWarnings into real 
errors, which means any failure / corruption should be much louder in the 
future, and so much more debuggable.

(I'm actually unable to cause that error in either version at all - passing 
invalid sizes in them triggers a different deprecation warning.)

Original comment by joe.wreschnig@gmail.com on 4 Aug 2010 at 9:16

GoogleCodeExporter commented 9 years ago
Interesting - I wonder what is making the difference between your machines and 
mine.  Again, is only 2.5 that throws the warning.

I just tried it again to make sure it wasn't just my imagination and here is 
the results:

Python 2.5.5 (r255:77872, Apr 21 2010, 08:40:04) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mutagen, urllib
>>> from mutagen.oggvorbis import OggVorbis
>>> mutagen.version
(1, 19, -1)
>>> file, _ = 
urllib.urlretrieve("https://thornomad.s3.amazonaws.com/mutagen/test.ogg")
>>> ogg = OggVorbis(file)
>>> ogg['title']
[u'Christmas Waltz']
>>> ogg.delete()
/usr/local/lib/python2.5/site-packages/mutagen/mutagen/mutagen/_util.py:151: 
DeprecationWarning: 'i' format requires -2147483648 <= number <= 2147483647
  to_int_be = staticmethod(lambda data: struct.pack('>i', data))
>>> ogg.tags
[]

Python 2.6.5+ (release26-maint, Jul  6 2010, 12:58:20) 
[GCC 4.4.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mutagen, urllib
>>> from mutagen.oggvorbis import OggVorbis
>>> mutagen.version
(1, 19, -1)
>>> file, _ = 
urllib.urlretrieve("https://thornomad.s3.amazonaws.com/mutagen/test.ogg")
>>> ogg = OggVorbis(file)
>>> ogg['title']
[u'Christmas Waltz']
>>> ogg.delete()
>>> ogg.tags
[]

I am using 2.6 now so it isn't a pressing issue for me - but I didn't know if 
it wasn't affecting other people.

Damon

Original comment by damont...@gmail.com on 17 Aug 2010 at 1:19

GoogleCodeExporter commented 9 years ago
If you want to track this down further, you might try forcing exceptions to try 
to get more specifics. Add something like
    import warnings
    warnings.simplefilter("error")
to the top of _util.py, and then once you know where it's called, a try/except 
around the call. In the except you can print out various relevant information, 
like repr(data).

Original comment by mur...@gmail.com on 17 Aug 2010 at 2:26

GoogleCodeExporter commented 9 years ago
Are you on a 64 bit machine? I am not.

Original comment by joe.wreschnig@gmail.com on 17 Aug 2010 at 10:12

GoogleCodeExporter commented 9 years ago
Yes - is 64-bit. Maybe that's the missing piece. I can try it on a 32-bit VM in 
the near future. 

Original comment by damont...@gmail.com on 18 Aug 2010 at 5:33

GoogleCodeExporter commented 9 years ago
All right - I can only reproduce the error on the 64-bit machine.  Works 
without a hitch on 2.5 on 32-bit linux.

Original comment by damont...@gmail.com on 21 Aug 2010 at 10:48

GoogleCodeExporter commented 9 years ago
Did anyone ever figure out why this was happening?

Original comment by joe.wreschnig@gmail.com on 17 Apr 2011 at 12:16

GoogleCodeExporter commented 9 years ago
Negative - other than it was only doing it with a 64-bit machine.  But I am not 
that well versed in Python.  Thanks for your help previously.

Original comment by damont...@gmail.com on 17 Apr 2011 at 12:24

GoogleCodeExporter commented 9 years ago
Patch attached.

Problem: As pointed out in the python docs [1], zlib.crc32 can return signed 
and unsigned int depending on version/platform (afaik 64bit, <=py2.5)

The patch forces the return value to unsigned (the first masking isn't needed, 
but makes it clearer).
The added test replaces zlib.crc32 with an int and an uint version to test if 
the output is the same.

[1] http://docs.python.org/library/zlib.html#zlib.crc32

Original comment by reiter.christoph@gmail.com on 14 Aug 2012 at 12:41

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by reiter.christoph@gmail.com on 14 Aug 2012 at 12:41

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r132.

Original comment by reiter.christoph@gmail.com on 17 Sep 2012 at 6:33