您的位置:首页 > 编程语言 > Python开发

wxPython 2.8.7.1版本的一个严重BUG和解决方法

2008-05-24 23:38 435 查看
wxPython 2.8.7.1版本有一个严重BUG,运行wxPython脚本会出现如下错误:

F:/ddd.py:1: DeprecationWarning: The wxPython compatibility package is no longer
automatically generated or actively maintained. Please switch to the wx packag
e as soon as possible.
from wxPython.wx import *
Traceback (most recent call last):
File "F:/ddd.py", line 1, in <module>
from wxPython.wx import *
File "C:/Python25/Lib/site-packages/wx-2.8-msw-ansi/wxPython/__init__.py", lin
e 15, in <module>
import _wx
File "C:/Python25/Lib/site-packages/wx-2.8-msw-ansi/wxPython/_wx.py", line 8,
in <module>
from _misc import *
File "C:/Python25/Lib/site-packages/wx-2.8-msw-ansi/wxPython/_misc.py", line 4
56, in <module>
wxDateTime_GetNumberOfDaysinYear = wx._misc.DateTime_GetNumberOfDaysinYear
AttributeError: 'module' object has no attribute 'DateTime_GetNumberOfDaysinYear
'

原因是wxPython 2.8.7.1版本中有一个变量名的拼写错误,修改site-packages/wx-2.8-msw-ansi/wxPython目录下的
_misc.py文件,把其中下面这句:
wxDateTime_GetNumberOfDaysinYear = wx._misc.DateTime_GetNumberOfDaysinYear
修改为:
wxDateTime_GetNumberOfDaysInYear = wx._misc.DateTime_GetNumberOfDaysInYear
注意这里的In错误的写成in了,大写写成了小写。

可以参考下面sourceforge上wxPython项目的解释:

https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1845098&group_id=9863
[ 1845098 ] Get attribute error (2.8.7.1)
You may monitor this Tracker item after you log in (register an account, if you do not already have one)
Submitted By:
jvenable - jvenable
Date Submitted:
2007-12-05 12:19
Changed to Closed status by:
robind

Closed as of:
2008-05-12 13:09
Last Updated By:
robind - Comment added
Date Last Updated:
2008-05-12 13:09
Number of Comments:
1
Number of Attachments:
0
Category: (?)
wxPython specific
Group: (?)
None
Assigned To: (?)
Robin Dunn
Priority: (?)
5
Status: (?)
Closed
Resolution: (?)
Fixed
Summary: (?)
Get attribute error (2.8.7.1)
Private: (?)
No
wxPython 2.8.7.1
(wxMSW, ansi, wx-assertions-on, SWIG-1.3.29)
Running on Python 2.3.5

This line in _misc.py appears to be in error:

wxDateTime_GetNumberOfDaysinYear = wx._misc.DateTime_GetNumberOfDaysinYear

I believe it should be:

wxDateTime_GetNumberOfDaysInYear = wx._misc.DateTime_GetNumberOfDaysInYear

Note the capitalized "In"

I get an exception:

AttributeError: 'module' object has no attribute
'DateTime_GetNumberOfDaysinYear'

unless I change it.

Thanks,

John Venable
jrvenable@gmail.com
Followups:
Comments
Date: 2008-05-12 13:09Sender: robind

Logged In: YES user_id=53955Originator: NOThis has already been fixed in SVN for the next release. However, pleasenote the DeprecationWarning and don't use the wxPython package. The wxpackage should be used instead.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: