Bugs item #1530559, was opened at 2006-07-28 14:07 Message generated for change (Comment added) made by collinwinter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1530559&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: Python 2.5 >Status: Open >Resolution: None Priority: 9 Private: No Submitted By: Joe Wreschnig (piman) Assigned to: Bob Ippolito (etrepum) Summary: struct.pack raises TypeError where it used to convert Initial Comment: [EMAIL PROTECTED]:~$ python2.4 -c "import struct; struct.pack('>H', 1.0)" [EMAIL PROTECTED]:~$ python2.5 -c "import struct; struct.pack('>H', 1.0)" Traceback (most recent call last): File "<string>", line 1, in <module> File "/usr/lib/python2.5/struct.py", line 63, in pack return o.pack(*args) TypeError: unsupported operand type(s) for &: 'float' and 'long' This might have appeared as part of the struct optimizations; if struct isn't going to convert anymore for performance reasons, I think this should be mentioned in the release notes. Though personally I would prefer struct go back to converting its arguments. ---------------------------------------------------------------------- >Comment By: Collin Winter (collinwinter) Date: 2007-03-29 18:48 Message: Logged In: YES user_id=1344176 Originator: NO Reopening. The test case added in r51119 (specifically, test_1530559() and its infrastructure) doesn't work. The check_float_coerce() function is overwritten by a later assignment, meaning that test_1530559() calls the wrong function. Actually making it call the right check_float_coerce() function results in a NameError ("global name 'func' is not defined"). The reason the test currently passes is because check_float_coerce() is effectively an alias for deprecated_err(). test_1530559() passes deprecated_err() a string as its first argument; when deprecated_err() tries to call the string, a TypeError results. deprecated_err() traps the TypeError and so everything appears from the outside to have gone smoothly. If the test is tweaked so that struct.pack() is actually invoked with the proper arguments, it fails to raise the expected error on float coercion. ---------------------------------------------------------------------- Comment By: Neal Norwitz (nnorwitz) Date: 2006-08-11 00:27 Message: Logged In: YES user_id=33168 This patch (or some variant) was checked in as 51119 ---------------------------------------------------------------------- Comment By: Bob Ippolito (etrepum) Date: 2006-08-02 22:10 Message: Logged In: YES user_id=139309 I've attached a patch which should resolve this issue. ---------------------------------------------------------------------- Comment By: Neal Norwitz (nnorwitz) Date: 2006-07-28 23:21 Message: Logged In: YES user_id=33168 I'd like to see a deprecation warning so old code continues to work. struct is way to loose and needs to be tightened up, but that might not fully happen until py3k. ---------------------------------------------------------------------- Comment By: Georg Brandl (gbrandl) Date: 2006-07-28 15:44 Message: Logged In: YES user_id=849994 I think that's a question for python-dev. ---------------------------------------------------------------------- Comment By: Bob Ippolito (etrepum) Date: 2006-07-28 15:31 Message: Logged In: YES user_id=139309 That wasn't really intentional, but the old behavior looks a bit suspect: $ python2.4 -c "import struct; print repr(struct.pack('>H', 1.6))" '\x00\x01' We could change it to check for floats and do a DeprecationWarning? ---------------------------------------------------------------------- Comment By: Georg Brandl (gbrandl) Date: 2006-07-28 14:51 Message: Logged In: YES user_id=849994 Bob? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1530559&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com