473,769 Members | 5,846 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python 2.4 does not marshal infinity floating point properly under Win32

Hi all,

When using Python 2.4.x on a Win32 box,
marshal.loads(m arshal.dumps(1e 66666)) returns 1.0 instead of infinity
as it should and does under Python 2.5 (also running on Win32 ).

This problem was reported in another thread here by Peter Hansen
http://groups-beta.google.com/group/...16739705c9304f

Is this considered an important enough bug to fix it in Python 2.4?

The following script exercise the problem when executed::

#---------------------------test_marshal.py--------------------------------------------------
import marshal

INFINITY = 1e66666
inf = 1e300 * 1e300
nan = inf - inf
def show(title, msg):
print '%-10s : ' % title,
msg2 = ''
count = 0
for chr in msg:
count += 1
val = ord(chr)
print hex(val),
if 31 < val < 128:
msg2 += chr
else:
msg2 += '.'
print ' ' * (9-count), ' : ', msg2

show('Nan', marshal.dumps(n an))
show('Infinity' , marshal.dumps(I NFINITY))
show('Infinity' , marshal.dumps(i nf))
show('Infinity' , marshal.dumps(1 e666))

val = marshal.loads(m arshal.dumps(1e 666))
print val
val = marshal.loads(m arshal.dumps(IN FINITY))
print val
assert val==INFINITY
#-------------------------------------------------------------------------------------------------------

When running the script on Win32 box with Python 2.4.3 or 2.4.4 I get::

D:\dev\python\t est>t_marshal
Nan : 0x66 0x7 0x2d 0x31 0x2e 0x23 0x49 0x4e 0x44 :
f.-1.#IND
Infinity : 0x66 0x6 0x31 0x2e 0x23 0x49 0x4e 0x46 : f.1.#INF
Infinity : 0x66 0x6 0x31 0x2e 0x23 0x49 0x4e 0x46 : f.1.#INF
Infinity : 0x66 0x6 0x31 0x2e 0x23 0x49 0x4e 0x46 : f.1.#INF
1.0
1.0
Traceback (most recent call last):
File "D:\dev\python\ test\t_marshal. py", line 33, in ?
assert val==INFINITY
AssertionError

But when running the same script on a Win32 box, using Python 2.5, I
get::

C:\dev\python\t est>t_marshal
Nan : 0x67 0x0 0x0 0x0 0x0 0x0 0x0 0xf8 0xff : g........
Infinity : 0x67 0x0 0x0 0x0 0x0 0x0 0x0 0xf0 0x7f : g.......¦
Infinity : 0x67 0x0 0x0 0x0 0x0 0x0 0x0 0xf0 0x7f : g.......¦
Infinity : 0x67 0x0 0x0 0x0 0x0 0x0 0x0 0xf0 0x7f : g.......¦
1.#INF
1.#INF
#-------------------------------------------------

--

Pierre Rouleau

Nov 30 '06 #1
2 1919
On 2006-11-30, Pierre Rouleau <pr*********@gm ail.comwrote:
When using Python 2.4.x on a Win32 box,
marshal.loads(m arshal.dumps(1e 66666)) returns 1.0 instead of infinity
as it should and does under Python 2.5 (also running on Win32 ).

This problem was reported in another thread here by Peter Hansen
http://groups-beta.google.com/group/...16739705c9304f

Is this considered an important enough bug to fix it in Python 2.4?
This must be at least the third thread on this topic so far
this week. And I didn't start _any_ of them (this week).

:)

--
Grant Edwards grante Yow! Imagine--a WORLD
at without POODLES...
visi.com
Nov 30 '06 #2
Pierre Rouleau schrieb:
Is this considered an important enough bug to fix it in Python 2.4?
To the contrary - it's not considered a bug at all. Python didn't
make any promises about "unregular" floating point values, so things
like that just may happen.

The fix that made Python offer stronger guarantees in 2.5 cannot
be ported back to 2.4, since it would break the marshal format of
that release.

Finally, it's not very likely that *any* additional 2.4.x releases
are made at all; only 2.5.x is still actively maintained.

Regards,
Martin
Nov 30 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
68761
by: Andreas Neudecker | last post by:
Hi. Is there anything like +infinity and -infinity available in Python, and can it be used in comparisons together with int or float numbers? Regards Andreas
89
5144
by: Radioactive Man | last post by:
In python 2.3 (IDLE 1.0.3) running under windows 95, I get the following types of errors whenever I do simple arithmetic: 1st example: >>> 12.10 + 8.30 20.399999999999999 >>> 1.1 - 0.2 0.90000000000000013
28
2680
by: Grant Edwards | last post by:
I finally figured out why one of my apps sometimes fails under Win32 when it always works fine under Linux: Under Win32, the pickle module only works with a subset of floating point values. In particular the if you try to dump/load an infinity or nan value, the load operation chokes: Under Linux: $ python
14
5948
by: Nils Grimsmo | last post by:
Why did round() change in Python 2.4? $ python2.3 Python 2.3.5 (#2, Jun 19 2005, 13:28:00) on linux2 >>> round(0.0225, 3) 0.023 >>> "%.3f" % round(0.0225, 3) '0.023' >>>
0
9586
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10043
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3956
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.