Date: Fri, 16 Jun 2006 05:50:34 +0000 (UTC) From: Joseph Koshy <jkoshy@FreeBSD.org> To: FreeBSD-gnats-submit@FreeBSD.org Subject: ports/99009: py-yaml ZeroDivisionError exception Message-ID: <20060616055034.1604D16A47C@hub.freebsd.org> Resent-Message-ID: <200606160600.k5G60bwl070039@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 99009 >Category: ports >Synopsis: py24-yaml fails to load >Confidential: no >Severity: critical >Priority: high >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Jun 16 06:00:35 GMT 2006 >Closed-Date: >Last-Modified: >Originator: Joseph Koshy >Release: FreeBSD 7.0-CURRENT i386 >Organization: The FreeBSD Project >Environment: System: FreeBSD orthanc-5 7.0-CURRENT FreeBSD 7.0-CURRENT #23: Mon Jun 5 05:25:05 IST 2006 root@orthanc-5:/home/obj-current/home/src-current/sys/FCPI-OPT i386 >Description: Python throws a ZeroDivisionError exception when the yaml library is used. >How-To-Repeat: Try 'import yaml' in Python. % python Python 2.4.2 (#2, Feb 20 2006, 21:55:20) [GCC 2.95.4 20020320 [FreeBSD]] on freebsd4 Type "help", "copyright", "credits" or "license" for more information. >>> import yaml Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/local/lib/python2.4/site-packages/yaml/__init__.py", line 8, in ? from loader import * File "/usr/local/lib/python2.4/site-packages/yaml/loader.py", line 8, in ? from constructor import * File "/usr/local/lib/python2.4/site-packages/yaml/constructor.py", line 187, in ? class SafeConstructor(BaseConstructor): File "/usr/local/lib/python2.4/site-packages/yaml/constructor.py", line 235, in SafeConstructor nan_value = inf_value/inf_value ZeroDivisionError: float division >Fix: The following patch from the Py-Yaml website fixes the problem. Index: pyyaml/trunk/lib/yaml/constructor.py =================================================================== --- pyyaml/trunk/lib/yaml/constructor.py (revision 147) +++ pyyaml/trunk/lib/yaml/constructor.py (revision 168) @@ -232,5 +232,7 @@ return sign*int(value) - inf_value = 1e300000 + inf_value = 1e300 + while repr(inf_value) != repr(inf_value*inf_value): + inf_value *= inf_value nan_value = inf_value/inf_value Index: pyyaml/trunk/lib/yaml/representer.py =================================================================== --- pyyaml/trunk/lib/yaml/representer.py (revision 152) +++ pyyaml/trunk/lib/yaml/representer.py (revision 168) @@ -193,7 +193,12 @@ return self.represent_scalar(u'tag:yaml.org,2002:int', unicode(data)) - repr_pos_inf = repr(1e300000) - repr_neg_inf = repr(-1e300000) - repr_nan = repr(1e300000/1e300000) + inf_value = 1e300 + while repr(inf_value) != repr(inf_value*inf_value): + inf_value *= inf_value + nan_value = inf_value/inf_value + + repr_pos_inf = repr(inf_value) + repr_neg_inf = repr(-inf_value) + repr_nan = repr(inf_value/inf_value) def represent_float(self, data): >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060616055034.1604D16A47C>