|
116 | 116 | raise ImportError(missingwx) |
117 | 117 |
|
118 | 118 | # Some early versions of wxversion lack AlreadyImportedError. |
119 | | -if hasattr(wxversion, 'AlreadyImportedError'): |
120 | | - try: |
121 | | - wxversion.ensureMinimal('2.8') |
122 | | - except wxversion.AlreadyImportedError: |
123 | | - pass |
124 | | -else: |
125 | | - warnings.warn( |
126 | | - "Update your wxversion.py to one including AlreadyImportedError") |
127 | | - try: |
128 | | - wxversion.ensureMinimal('2.8') |
129 | | - except wxversion.VersionError: |
130 | | - pass |
| 119 | +# It was added around 2.8.4? |
| 120 | +try: |
| 121 | + _wx_ensure_failed = wxversion.AlreadyImportedError |
| 122 | +except AttributeError: |
| 123 | + _wx_ensure_failed = wxversion.VersionError |
| 124 | + |
| 125 | +try: |
| 126 | + wxversion.ensureMinimal('2.8') |
| 127 | +except _wx_ensure_failed: |
| 128 | + pass |
| 129 | +# We don't really want to pass in case of VersionError, but when |
| 130 | +# AlreadyImportedError is not available, we have to. |
131 | 131 |
|
132 | 132 | try: |
133 | 133 | import wx |
134 | 134 | backend_version = wx.VERSION_STRING |
135 | 135 | except ImportError: |
136 | 136 | raise ImportError(missingwx) |
137 | 137 |
|
138 | | -# Extra version check in case wxversion is broken: |
| 138 | +# Extra version check in case wxversion lacks AlreadyImportedError; |
| 139 | +# then VersionError might have been raised and ignored when |
| 140 | +# there really *is* a problem with the version. |
139 | 141 | major, minor = [int(n) for n in backend_version.split('.')[:2]] |
140 | 142 | if major < 2 or (major < 3 and minor < 8): |
| 143 | + print " wxPython version %s was imported." % backend_version |
141 | 144 | raise ImportError(missingwx) |
142 | 145 |
|
143 | 146 |
|
|
0 commit comments