NaN 根据 Python 启动给出错误?
我正在使用 Python4Delphi 将 Python 嵌入到 Delphi 程序中。版本:Python 2.6.4、Delphi 2009、Windows XP。
导入 json
时,Delphi 程序因 EInvalidOp 崩溃。 行
NaN, PosInf, NegInf = float('nan'), float('inf'), float('-inf')
我跟踪它到json.decoder 中的
。果然,命令 float('nan')
在嵌入 Delphi 程序的 Python 中运行时会引发 EInvalidOp
。当在命令行 Python 中执行时(相同的安装),它只返回 nan。
你知道Python标准启动和嵌入式启动之间有什么区别可能会导致这样的错误吗?
I am using Python4Delphi to embed Python in a Delphi program. Versions: Python 2.6.4, Delphi 2009, Windows XP.
The Delphi program crashes with EInvalidOp when importing json
. I tracked it to the line
NaN, PosInf, NegInf = float('nan'), float('inf'), float('-inf')
in json.decoder
.
Sure enough, the command float('nan')
raises an EInvalidOp
when run inside Python embedded in the Delphi program. When executed in the command line Python (same installation) it simply returns nan
.
Any idea what is the difference between the Python standard startup and that of the embedded one that may result in such an error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这很可能是因为 Python 使用了与 Python 不同的 8087 控制字 (CW) 设置德尔福。
尝试这种代码:
请参阅我的 有关 Delphi 中的 8087 CW 的博客文章,了解 133F 美元价值的更详细说明。
它需要
T8087Precision
类型的 JCL (位于Jcl8087
单元)。——杰罗恩
This is most likely that Python uses a different 8087 control word (CW) setting than Delphi.
Try this kind of code:
See my blog article on the 8087 CW in Delphi for a more detailed explanation of the $133F value.
It needs the JCL for the
T8087Precision
type (which is in theJcl8087
unit).--jeroen
我使用以下内容:
$1332 是 delphi 的默认值。
$1232 是处理 Python Issue 9980 的值。
I use the following:
$1332 is the delphi default.
$1232 is the value to deal with Python Issue 9980.