mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 16:20:11 -04:00
direct: fix various uses of types.MethodType in Python 3 (from #1000)
This commit is contained in:
parent
1cc82f47b6
commit
dae9e31223
@ -4,6 +4,7 @@ __all__ = ['State']
|
||||
|
||||
from direct.directnotify.DirectNotifyGlobal import directNotify
|
||||
from direct.showbase.DirectObject import DirectObject
|
||||
import sys
|
||||
|
||||
|
||||
class State(DirectObject):
|
||||
@ -32,6 +33,10 @@ class State(DirectObject):
|
||||
if type(enterFunc) == types.MethodType:
|
||||
if enterFunc.__func__ == oldFunction:
|
||||
# print 'found: ', enterFunc, oldFunction
|
||||
if sys.version_info >= (3, 0):
|
||||
state.setEnterFunc(types.MethodType(newFunction,
|
||||
enterFunc.__self__))
|
||||
else:
|
||||
state.setEnterFunc(types.MethodType(newFunction,
|
||||
enterFunc.__self__,
|
||||
enterFunc.__self__.__class__))
|
||||
@ -39,6 +44,10 @@ class State(DirectObject):
|
||||
if type(exitFunc) == types.MethodType:
|
||||
if exitFunc.__func__ == oldFunction:
|
||||
# print 'found: ', exitFunc, oldFunction
|
||||
if sys.version_info >= (3, 0):
|
||||
state.setExitFunc(types.MethodType(newFunction,
|
||||
exitFunc.__self__))
|
||||
else:
|
||||
state.setExitFunc(types.MethodType(newFunction,
|
||||
exitFunc.__self__,
|
||||
exitFunc.__self__.__class__))
|
||||
|
@ -7,6 +7,7 @@ from panda3d.direct import *
|
||||
from direct.showbase.MessengerGlobal import *
|
||||
from direct.directnotify.DirectNotifyGlobal import directNotify
|
||||
from . import Interval
|
||||
import sys
|
||||
|
||||
|
||||
#############################################################
|
||||
@ -36,6 +37,10 @@ class FunctionInterval(Interval.Interval):
|
||||
if type(ival.function) == types.MethodType:
|
||||
if ival.function.__func__ == oldFunction:
|
||||
# print 'found: ', ival.function, oldFunction
|
||||
if sys.version_info >= (3, 0):
|
||||
ival.function = types.MethodType(newFunction,
|
||||
ival.function.__self__)
|
||||
else:
|
||||
ival.function = types.MethodType(newFunction,
|
||||
ival.function.__self__,
|
||||
ival.function.__self__.__class__)
|
||||
|
@ -8,6 +8,7 @@ __all__ = ['Messenger']
|
||||
from .PythonUtil import *
|
||||
from direct.directnotify import DirectNotifyGlobal
|
||||
import types
|
||||
import sys
|
||||
|
||||
from direct.stdpy.threading import Lock
|
||||
|
||||
@ -464,6 +465,9 @@ class Messenger:
|
||||
# 'oldMethod: ' + repr(oldMethod) + '\n' +
|
||||
# 'newFunction: ' + repr(newFunction) + '\n')
|
||||
if (function == oldMethod):
|
||||
if sys.version_info >= (3, 0):
|
||||
newMethod = types.MethodType(newFunction, method.__self__)
|
||||
else:
|
||||
newMethod = types.MethodType(
|
||||
newFunction, method.__self__, method.__self__.__class__)
|
||||
params[0] = newMethod
|
||||
|
@ -1600,6 +1600,9 @@ def appendStr(obj, st):
|
||||
return s
|
||||
oldStr = Functor(stringer, str(obj))
|
||||
stringer = None
|
||||
if sys.version_info >= (3, 0):
|
||||
obj.__str__ = types.MethodType(Functor(appendedStr, oldStr, st), obj)
|
||||
else:
|
||||
obj.__str__ = types.MethodType(Functor(appendedStr, oldStr, st), obj, obj.__class__)
|
||||
appendedStr = None
|
||||
return obj
|
||||
|
@ -599,6 +599,10 @@ class TaskManager:
|
||||
else:
|
||||
function = method
|
||||
if (function == oldMethod):
|
||||
if sys.version_info >= (3, 0):
|
||||
newMethod = types.MethodType(newFunction,
|
||||
method.__self__)
|
||||
else:
|
||||
newMethod = types.MethodType(newFunction,
|
||||
method.__self__,
|
||||
method.__self__.__class__)
|
||||
|
Loading…
x
Reference in New Issue
Block a user