mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-06 20:10:08 +01:00
remove more Python2 hybridation
This commit is contained in:
committed by
Scott Talbert
parent
0257f755cf
commit
323e78c085
@@ -24,7 +24,7 @@ except ImportError:
|
||||
if hasattr(sys, "frozen"):
|
||||
import os, win32api
|
||||
dllpath = os.path.join(win32api.GetSystemDirectory(), 'MFC71.DLL')
|
||||
if sys.version[:3] >= '2.4' and not os.path.exists(dllpath):
|
||||
if not os.path.exists(dllpath):
|
||||
message = "%s not found" % dllpath
|
||||
else:
|
||||
raise # original error message
|
||||
|
||||
@@ -2594,16 +2594,7 @@ SWITCHER_TEXT_MARGIN_Y = 1
|
||||
if __name__ == '__main__':
|
||||
# Easy image extraction.
|
||||
import sys
|
||||
if sys.version_info[0] == 2:
|
||||
PY2 = True
|
||||
PY3 = False
|
||||
elif sys.version_info[0] == 3:
|
||||
PY2 = False
|
||||
PY3 = True
|
||||
if PY2:
|
||||
answer = int(raw_input('Enter 1 to extract all bitmaps: '))
|
||||
elif PY3:
|
||||
answer = int(input('Enter 1 to extract all bitmaps: '))
|
||||
answer = int(input('Enter 1 to extract all bitmaps: '))
|
||||
if answer == 1:
|
||||
app = wx.App(0)
|
||||
import os
|
||||
@@ -2622,7 +2613,4 @@ if __name__ == '__main__':
|
||||
except Exception:
|
||||
pass
|
||||
app.MainLoop()
|
||||
if PY2:
|
||||
raw_input('Press Enter To Exit.')
|
||||
elif PY3:
|
||||
input('Press Enter To Exit.')
|
||||
input('Press Enter To Exit.')
|
||||
|
||||
@@ -1008,12 +1008,9 @@ class SlicesShell(editwindow.EditWindow):
|
||||
"""Execute the user's PYTHONSTARTUP script if they have one."""
|
||||
if startupScript and os.path.isfile(startupScript):
|
||||
text = 'Startup script executed: ' + startupScript
|
||||
if PY3:
|
||||
self.push('print(%r)' % text)
|
||||
self.push('with open(%r, "r") as f:\n'
|
||||
' exec(f.read())\n' % (startupScript))
|
||||
else:
|
||||
self.push('print(%r); execfile(%r)' % (text, startupScript))
|
||||
self.push('print(%r)' % text)
|
||||
self.push('with open(%r, "r") as f:\n'
|
||||
' exec(f.read())\n' % (startupScript))
|
||||
self.interp.startupScript = startupScript
|
||||
else:
|
||||
self.push('')
|
||||
|
||||
@@ -8,8 +8,6 @@ import os
|
||||
import unittest
|
||||
from wx.py import introspect
|
||||
|
||||
PY3 = sys.version_info[0] == 3
|
||||
|
||||
"""
|
||||
These unittest methods are preferred:
|
||||
-------------------------------------
|
||||
@@ -394,21 +392,6 @@ class GetBaseObjectTestCase(unittest.TestCase):
|
||||
# Class with no init.
|
||||
(Bar, Bar, 0),
|
||||
]
|
||||
if not PY3:
|
||||
values.extend([
|
||||
# Byte-compiled code.
|
||||
(ham.func_code, ham.func_code, 0),
|
||||
# Class with init.
|
||||
(Foo, Foo.__init__.im_func, 1),
|
||||
# Bound method.
|
||||
(spam.foo, spam.foo.im_func, 1),
|
||||
# Bound method with self named something else (spam).
|
||||
(spam.bar, spam.bar.im_func, 1),
|
||||
# Unbound method. (Do not drop the self argument.)
|
||||
(eggs, eggs.im_func, 0),
|
||||
# Callable instance.
|
||||
(spam, spam.__call__.im_func, 1),
|
||||
])
|
||||
for object, baseObject, dropSelf in values:
|
||||
result = introspect.getBaseObject(object)
|
||||
self.assertEqual(result, (baseObject, dropSelf))
|
||||
@@ -674,16 +657,6 @@ class GetAttributeNamesTestCase(GetAttributeTestCase):
|
||||
# BrokenStr instance.
|
||||
brokenStr,
|
||||
]
|
||||
if not PY3:
|
||||
self.items.extend([
|
||||
long(123),
|
||||
unicode(""),
|
||||
xrange(0),
|
||||
# Byte-compiled code.
|
||||
ham.func_code,
|
||||
# Buffer.
|
||||
buffer(''),
|
||||
])
|
||||
|
||||
def tearDown(self):
|
||||
self.items = None
|
||||
@@ -829,34 +802,11 @@ class Q(P):
|
||||
|
||||
class GetConstructorTestCase(unittest.TestCase):
|
||||
|
||||
@unittest.skipIf(PY3, "Python2 specific test")
|
||||
def test_getConstructor(self):
|
||||
args = ('self', 'a', 'b', 'args', 'kwargs')
|
||||
varnames = introspect.getConstructor(O).func_code.co_varnames
|
||||
self.assertEqual(varnames, args)
|
||||
varnames = introspect.getConstructor(P).func_code.co_varnames
|
||||
self.assertEqual(varnames, args)
|
||||
args = ('self', 'c', 'd')
|
||||
varnames = introspect.getConstructor(Q).func_code.co_varnames
|
||||
self.assertEqual(varnames, args)
|
||||
|
||||
def test_getConstructor_None(self):
|
||||
values = (N, 1, 'spam', {}, [], (), dir)
|
||||
for value in values:
|
||||
self.assertEqual(introspect.getConstructor(N), None)
|
||||
|
||||
@unittest.skipIf(PY3, "Python2 specific test")
|
||||
def test_getConstructor_MultipleInheritance(self):
|
||||
# Test old style inheritance rules.
|
||||
args = ('self', 'a')
|
||||
varnames = introspect.getConstructor(D1).func_code.co_varnames
|
||||
self.assertEqual(varnames, args)
|
||||
if 'object' in __builtins__:
|
||||
# Test new style inheritance rules as well.
|
||||
args = ('self', 'b')
|
||||
varnames = introspect.getConstructor(D2).func_code.co_varnames
|
||||
self.assertEqual(varnames, args)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
@@ -46,8 +46,6 @@ from cpython.buffer cimport (
|
||||
Py_buffer, PyObject_CheckBuffer, PyObject_GetBuffer, PyBUF_SIMPLE,
|
||||
PyBuffer_Release)
|
||||
|
||||
PY2 = sys.version_info[0] == 2
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Replicate the C enums and values for Python, dropping the leading 'N'
|
||||
|
||||
|
||||
@@ -198,10 +198,7 @@ def img2py(image_file, python_file,
|
||||
while data:
|
||||
part = data[:72]
|
||||
data = data[72:]
|
||||
if sys.version > '3':
|
||||
output = ' %s' % part
|
||||
else:
|
||||
output = ' "%s"' % part
|
||||
output = ' %s' % part
|
||||
if not data:
|
||||
output += ")"
|
||||
lines.append(output)
|
||||
|
||||
Reference in New Issue
Block a user