deprecated python 2.5

John Machin sjmachin at lexicon.net
Tue Sep 12 06:43:42 EDT 2006


bussiere maillist wrote:
> DeprecationWarning: struct integer overflow masking is deprecated
>   return struct.pack('>H', ~value)
>  i didn't understand if someone have some explanation
> and what uses instead.

Which 2.5 are you using? Mine (2.5c1, win32) gives me *TWO* messages,
the second of which hints at the obvious remedy:

| DOS prompt>\python25\python
| Python 2.5c1 (r25c1:51305, Aug 17 2006, 10:41:11) [MSC v.1310 32 bit
(Intel)] on
|  win32
| Type "help", "copyright", "credits" or "license" for more
information.
| >>> import struct
| >>> struct.pack('>H', 1)
| '\x00\x01'
| >>> struct.pack('>H', ~1)
| __main__:1: DeprecationWarning: struct integer overflow masking is
deprecated
| __main__:1: DeprecationWarning: 'H' format requires 0 <= number <=
65535
| '\xff\xfe'
| >>> ^Z
|
| DOS prompt>\python25\python
| Python 2.5c1 (r25c1:51305, Aug 17 2006, 10:41:11) [MSC v.1310 32 bit
(Intel)] on
|  win32
| Type "help", "copyright", "credits" or "license" for more
information.
| >>> import struct
| >>> struct.pack('>H', (~1) & 0xffff)
| '\xff\xfe'
| >>>

HTH,
John




More information about the Python-list mailing list