2002-07-25 21:06:42 -03:00
|
|
|
"""RPC Implemention, originally written for the Python Idle IDE
|
|
|
|
|
|
|
|
For security reasons, GvR requested that Idle's Python execution server process
|
|
|
|
connect to the Idle process, which listens for the connection. Since Idle has
|
|
|
|
has only one client per server, this was not a limitation.
|
|
|
|
|
|
|
|
+---------------------------------+ +-------------+
|
2008-05-11 23:31:37 -03:00
|
|
|
| socketserver.BaseRequestHandler | | SocketIO |
|
2002-07-25 21:06:42 -03:00
|
|
|
+---------------------------------+ +-------------+
|
|
|
|
^ | register() |
|
|
|
|
| | unregister()|
|
|
|
|
| +-------------+
|
|
|
|
| ^ ^
|
|
|
|
| | |
|
|
|
|
| + -------------------+ |
|
|
|
|
| | |
|
|
|
|
+-------------------------+ +-----------------+
|
|
|
|
| RPCHandler | | RPCClient |
|
|
|
|
| [attribute of RPCServer]| | |
|
|
|
|
+-------------------------+ +-----------------+
|
|
|
|
|
|
|
|
The RPCServer handler class is expected to provide register/unregister methods.
|
|
|
|
RPCHandler inherits the mix-in class SocketIO, which provides these methods.
|
|
|
|
|
|
|
|
See the Idle run.main() docstring for further information on how this was
|
|
|
|
accomplished in Idle.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
import sys
|
2003-05-08 17:26:55 -03:00
|
|
|
import os
|
2002-05-26 10:36:41 -03:00
|
|
|
import socket
|
|
|
|
import select
|
2008-05-11 23:31:37 -03:00
|
|
|
import socketserver
|
2002-05-26 10:36:41 -03:00
|
|
|
import struct
|
2007-07-19 21:22:32 -03:00
|
|
|
import pickle
|
2002-05-26 10:36:41 -03:00
|
|
|
import threading
|
2008-05-11 16:59:59 -03:00
|
|
|
import queue
|
2002-05-26 10:36:41 -03:00
|
|
|
import traceback
|
2008-05-11 05:55:36 -03:00
|
|
|
import copyreg
|
2002-05-26 10:36:41 -03:00
|
|
|
import types
|
|
|
|
import marshal
|
|
|
|
|
2003-05-08 17:26:55 -03:00
|
|
|
|
2002-05-26 10:36:41 -03:00
|
|
|
def unpickle_code(ms):
|
|
|
|
co = marshal.loads(ms)
|
|
|
|
assert isinstance(co, types.CodeType)
|
|
|
|
return co
|
|
|
|
|
|
|
|
def pickle_code(co):
|
|
|
|
assert isinstance(co, types.CodeType)
|
|
|
|
ms = marshal.dumps(co)
|
|
|
|
return unpickle_code, (ms,)
|
|
|
|
|
2002-08-25 11:08:07 -03:00
|
|
|
# XXX KBK 24Aug02 function pickling capability not used in Idle
|
|
|
|
# def unpickle_function(ms):
|
|
|
|
# return ms
|
2002-05-26 10:36:41 -03:00
|
|
|
|
2002-08-25 11:08:07 -03:00
|
|
|
# def pickle_function(fn):
|
|
|
|
# assert isinstance(fn, type.FunctionType)
|
2004-02-12 13:35:32 -04:00
|
|
|
# return repr(fn)
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2008-05-11 05:55:36 -03:00
|
|
|
copyreg.pickle(types.CodeType, pickle_code, unpickle_code)
|
|
|
|
# copyreg.pickle(types.FunctionType, pickle_function, unpickle_function)
|
2002-05-26 10:36:41 -03:00
|
|
|
|
|
|
|
BUFSIZE = 8*1024
|
2003-06-05 20:51:29 -03:00
|
|
|
LOCALHOST = '127.0.0.1'
|
2002-05-26 10:36:41 -03:00
|
|
|
|
2008-05-11 23:31:37 -03:00
|
|
|
class RPCServer(socketserver.TCPServer):
|
2002-05-26 10:36:41 -03:00
|
|
|
|
|
|
|
def __init__(self, addr, handlerclass=None):
|
|
|
|
if handlerclass is None:
|
|
|
|
handlerclass = RPCHandler
|
2008-05-11 23:31:37 -03:00
|
|
|
socketserver.TCPServer.__init__(self, addr, handlerclass)
|
2002-05-26 10:36:41 -03:00
|
|
|
|
2002-07-25 21:06:42 -03:00
|
|
|
def server_bind(self):
|
|
|
|
"Override TCPServer method, no bind() phase for connecting entity"
|
|
|
|
pass
|
|
|
|
|
|
|
|
def server_activate(self):
|
|
|
|
"""Override TCPServer method, connect() instead of listen()
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2002-07-25 21:06:42 -03:00
|
|
|
Due to the reversed connection, self.server_address is actually the
|
|
|
|
address of the Idle Client to which we are connecting.
|
|
|
|
|
|
|
|
"""
|
|
|
|
self.socket.connect(self.server_address)
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2002-07-25 21:06:42 -03:00
|
|
|
def get_request(self):
|
|
|
|
"Override TCPServer method, return already connected socket"
|
|
|
|
return self.socket, self.server_address
|
2002-05-26 10:36:41 -03:00
|
|
|
|
2003-02-17 14:57:16 -04:00
|
|
|
def handle_error(self, request, client_address):
|
2003-03-22 15:15:58 -04:00
|
|
|
"""Override TCPServer method
|
|
|
|
|
|
|
|
Error message goes to __stderr__. No error message if exiting
|
|
|
|
normally or socket raised EOF. Other exceptions not handled in
|
|
|
|
server code will cause os._exit.
|
|
|
|
|
|
|
|
"""
|
2003-02-17 14:57:16 -04:00
|
|
|
try:
|
|
|
|
raise
|
|
|
|
except SystemExit:
|
|
|
|
raise
|
2003-03-22 15:15:58 -04:00
|
|
|
except:
|
2003-03-22 16:11:14 -04:00
|
|
|
erf = sys.__stderr__
|
2007-02-09 01:37:30 -04:00
|
|
|
print('\n' + '-'*40, file=erf)
|
|
|
|
print('Unhandled server exception!', file=erf)
|
2008-11-28 21:48:47 -04:00
|
|
|
print('Thread: %s' % threading.current_thread().name, file=erf)
|
2007-02-09 01:37:30 -04:00
|
|
|
print('Client Address: ', client_address, file=erf)
|
|
|
|
print('Request: ', repr(request), file=erf)
|
2003-03-22 15:15:58 -04:00
|
|
|
traceback.print_exc(file=erf)
|
2007-02-09 01:37:30 -04:00
|
|
|
print('\n*** Unrecoverable, server exiting!', file=erf)
|
|
|
|
print('-'*40, file=erf)
|
2003-03-22 16:11:14 -04:00
|
|
|
os._exit(0)
|
2003-02-17 14:57:16 -04:00
|
|
|
|
2003-05-08 17:26:55 -03:00
|
|
|
#----------------- end class RPCServer --------------------
|
2003-02-17 14:57:16 -04:00
|
|
|
|
2002-05-26 10:36:41 -03:00
|
|
|
objecttable = {}
|
2008-05-11 16:59:59 -03:00
|
|
|
request_queue = queue.Queue(0)
|
|
|
|
response_queue = queue.Queue(0)
|
2003-05-08 17:26:55 -03:00
|
|
|
|
2002-05-26 10:36:41 -03:00
|
|
|
|
2004-12-21 18:10:32 -04:00
|
|
|
class SocketIO(object):
|
2002-05-26 10:36:41 -03:00
|
|
|
|
2003-01-24 23:26:35 -04:00
|
|
|
nextseq = 0
|
|
|
|
|
2002-05-26 10:36:41 -03:00
|
|
|
def __init__(self, sock, objtable=None, debugging=None):
|
2008-06-12 23:00:47 -03:00
|
|
|
self.sockthread = threading.current_thread()
|
2002-05-26 10:36:41 -03:00
|
|
|
if debugging is not None:
|
|
|
|
self.debugging = debugging
|
|
|
|
self.sock = sock
|
|
|
|
if objtable is None:
|
|
|
|
objtable = objecttable
|
|
|
|
self.objtable = objtable
|
|
|
|
self.responses = {}
|
|
|
|
self.cvars = {}
|
|
|
|
|
|
|
|
def close(self):
|
|
|
|
sock = self.sock
|
|
|
|
self.sock = None
|
|
|
|
if sock is not None:
|
|
|
|
sock.close()
|
|
|
|
|
2003-05-08 17:26:55 -03:00
|
|
|
def exithook(self):
|
|
|
|
"override for specific exit action"
|
|
|
|
os._exit()
|
|
|
|
|
2002-05-26 10:36:41 -03:00
|
|
|
def debug(self, *args):
|
|
|
|
if not self.debugging:
|
|
|
|
return
|
2008-11-28 21:48:47 -04:00
|
|
|
s = self.location + " " + str(threading.current_thread().name)
|
2002-05-26 10:36:41 -03:00
|
|
|
for a in args:
|
|
|
|
s = s + " " + str(a)
|
2007-02-09 01:37:30 -04:00
|
|
|
print(s, file=sys.__stderr__)
|
2002-05-26 10:36:41 -03:00
|
|
|
|
|
|
|
def register(self, oid, object):
|
|
|
|
self.objtable[oid] = object
|
|
|
|
|
|
|
|
def unregister(self, oid):
|
|
|
|
try:
|
|
|
|
del self.objtable[oid]
|
|
|
|
except KeyError:
|
|
|
|
pass
|
|
|
|
|
2003-05-08 17:26:55 -03:00
|
|
|
def localcall(self, seq, request):
|
2002-12-31 12:03:23 -04:00
|
|
|
self.debug("localcall:", request)
|
2002-05-26 10:36:41 -03:00
|
|
|
try:
|
|
|
|
how, (oid, methodname, args, kwargs) = request
|
|
|
|
except TypeError:
|
|
|
|
return ("ERROR", "Bad request format")
|
2006-08-22 12:45:46 -03:00
|
|
|
if oid not in self.objtable:
|
2004-02-12 13:35:32 -04:00
|
|
|
return ("ERROR", "Unknown object id: %r" % (oid,))
|
2002-05-26 10:36:41 -03:00
|
|
|
obj = self.objtable[oid]
|
|
|
|
if methodname == "__methods__":
|
|
|
|
methods = {}
|
|
|
|
_getmethods(obj, methods)
|
|
|
|
return ("OK", methods)
|
|
|
|
if methodname == "__attributes__":
|
|
|
|
attributes = {}
|
|
|
|
_getattributes(obj, attributes)
|
|
|
|
return ("OK", attributes)
|
|
|
|
if not hasattr(obj, methodname):
|
2004-02-12 13:35:32 -04:00
|
|
|
return ("ERROR", "Unsupported method name: %r" % (methodname,))
|
2002-05-26 10:36:41 -03:00
|
|
|
method = getattr(obj, methodname)
|
|
|
|
try:
|
2003-05-08 17:26:55 -03:00
|
|
|
if how == 'CALL':
|
|
|
|
ret = method(*args, **kwargs)
|
|
|
|
if isinstance(ret, RemoteObject):
|
|
|
|
ret = remoteref(ret)
|
|
|
|
return ("OK", ret)
|
|
|
|
elif how == 'QUEUE':
|
|
|
|
request_queue.put((seq, (method, args, kwargs)))
|
|
|
|
return("QUEUED", None)
|
|
|
|
else:
|
|
|
|
return ("ERROR", "Unsupported message type: %s" % how)
|
2003-02-17 14:57:16 -04:00
|
|
|
except SystemExit:
|
|
|
|
raise
|
2003-03-10 16:42:24 -04:00
|
|
|
except socket.error:
|
2003-05-08 17:26:55 -03:00
|
|
|
raise
|
2002-05-26 10:36:41 -03:00
|
|
|
except:
|
2004-12-23 00:39:55 -04:00
|
|
|
msg = "*** Internal Error: rpc.py:SocketIO.localcall()\n\n"\
|
|
|
|
" Object: %s \n Method: %s \n Args: %s\n"
|
2007-02-09 01:37:30 -04:00
|
|
|
print(msg % (oid, method, args), file=sys.__stderr__)
|
2003-02-27 19:04:17 -04:00
|
|
|
traceback.print_exc(file=sys.__stderr__)
|
2003-01-31 01:06:43 -04:00
|
|
|
return ("EXCEPTION", None)
|
|
|
|
|
2002-05-26 10:36:41 -03:00
|
|
|
def remotecall(self, oid, methodname, args, kwargs):
|
2003-02-17 14:57:16 -04:00
|
|
|
self.debug("remotecall:asynccall: ", oid, methodname)
|
2002-05-26 10:36:41 -03:00
|
|
|
seq = self.asynccall(oid, methodname, args, kwargs)
|
2002-12-06 17:45:24 -04:00
|
|
|
return self.asyncreturn(seq)
|
2002-05-26 10:36:41 -03:00
|
|
|
|
2003-05-08 17:26:55 -03:00
|
|
|
def remotequeue(self, oid, methodname, args, kwargs):
|
|
|
|
self.debug("remotequeue:asyncqueue: ", oid, methodname)
|
|
|
|
seq = self.asyncqueue(oid, methodname, args, kwargs)
|
|
|
|
return self.asyncreturn(seq)
|
|
|
|
|
2002-05-26 10:36:41 -03:00
|
|
|
def asynccall(self, oid, methodname, args, kwargs):
|
2003-05-08 17:26:55 -03:00
|
|
|
request = ("CALL", (oid, methodname, args, kwargs))
|
2003-01-24 23:26:35 -04:00
|
|
|
seq = self.newseq()
|
2008-06-12 23:00:47 -03:00
|
|
|
if threading.current_thread() != self.sockthread:
|
2003-05-08 17:26:55 -03:00
|
|
|
cvar = threading.Condition()
|
|
|
|
self.cvars[seq] = cvar
|
2003-01-24 23:26:35 -04:00
|
|
|
self.debug(("asynccall:%d:" % seq), oid, methodname, args, kwargs)
|
|
|
|
self.putmessage((seq, request))
|
2002-05-26 10:36:41 -03:00
|
|
|
return seq
|
|
|
|
|
2003-05-08 17:26:55 -03:00
|
|
|
def asyncqueue(self, oid, methodname, args, kwargs):
|
|
|
|
request = ("QUEUE", (oid, methodname, args, kwargs))
|
|
|
|
seq = self.newseq()
|
2008-06-12 23:00:47 -03:00
|
|
|
if threading.current_thread() != self.sockthread:
|
2003-05-08 17:26:55 -03:00
|
|
|
cvar = threading.Condition()
|
|
|
|
self.cvars[seq] = cvar
|
|
|
|
self.debug(("asyncqueue:%d:" % seq), oid, methodname, args, kwargs)
|
|
|
|
self.putmessage((seq, request))
|
|
|
|
return seq
|
|
|
|
|
2002-05-26 10:36:41 -03:00
|
|
|
def asyncreturn(self, seq):
|
2003-01-24 23:26:35 -04:00
|
|
|
self.debug("asyncreturn:%d:call getresponse(): " % seq)
|
2003-05-08 17:26:55 -03:00
|
|
|
response = self.getresponse(seq, wait=0.05)
|
2003-01-24 23:26:35 -04:00
|
|
|
self.debug(("asyncreturn:%d:response: " % seq), response)
|
2002-05-26 10:36:41 -03:00
|
|
|
return self.decoderesponse(response)
|
|
|
|
|
|
|
|
def decoderesponse(self, response):
|
|
|
|
how, what = response
|
|
|
|
if how == "OK":
|
|
|
|
return what
|
2003-05-08 17:26:55 -03:00
|
|
|
if how == "QUEUED":
|
|
|
|
return None
|
2002-05-26 10:36:41 -03:00
|
|
|
if how == "EXCEPTION":
|
2003-02-17 14:57:16 -04:00
|
|
|
self.debug("decoderesponse: EXCEPTION")
|
|
|
|
return None
|
2003-05-08 17:26:55 -03:00
|
|
|
if how == "EOF":
|
|
|
|
self.debug("decoderesponse: EOF")
|
|
|
|
self.decode_interrupthook()
|
|
|
|
return None
|
2002-05-26 10:36:41 -03:00
|
|
|
if how == "ERROR":
|
2002-12-31 12:03:23 -04:00
|
|
|
self.debug("decoderesponse: Internal ERROR:", what)
|
2007-08-22 22:06:15 -03:00
|
|
|
raise RuntimeError(what)
|
|
|
|
raise SystemError(how, what)
|
2002-05-26 10:36:41 -03:00
|
|
|
|
2003-05-08 17:26:55 -03:00
|
|
|
def decode_interrupthook(self):
|
|
|
|
""
|
|
|
|
raise EOFError
|
|
|
|
|
2002-05-26 10:36:41 -03:00
|
|
|
def mainloop(self):
|
2003-01-24 23:26:35 -04:00
|
|
|
"""Listen on socket until I/O not ready or EOF
|
|
|
|
|
2003-05-08 17:26:55 -03:00
|
|
|
pollresponse() will loop looking for seq number None, which
|
2003-03-12 16:52:00 -04:00
|
|
|
never comes, and exit on EOFError.
|
2003-01-24 23:26:35 -04:00
|
|
|
|
|
|
|
"""
|
2002-05-26 10:36:41 -03:00
|
|
|
try:
|
2003-05-08 17:26:55 -03:00
|
|
|
self.getresponse(myseq=None, wait=0.05)
|
2002-05-26 10:36:41 -03:00
|
|
|
except EOFError:
|
2003-05-08 17:26:55 -03:00
|
|
|
self.debug("mainloop:return")
|
|
|
|
return
|
2002-05-26 10:36:41 -03:00
|
|
|
|
2003-03-12 16:52:00 -04:00
|
|
|
def getresponse(self, myseq, wait):
|
|
|
|
response = self._getresponse(myseq, wait)
|
2002-05-26 10:36:41 -03:00
|
|
|
if response is not None:
|
|
|
|
how, what = response
|
|
|
|
if how == "OK":
|
|
|
|
response = how, self._proxify(what)
|
|
|
|
return response
|
|
|
|
|
|
|
|
def _proxify(self, obj):
|
|
|
|
if isinstance(obj, RemoteProxy):
|
|
|
|
return RPCProxy(self, obj.oid)
|
2007-06-07 20:15:56 -03:00
|
|
|
if isinstance(obj, list):
|
2007-08-09 15:00:23 -03:00
|
|
|
return list(map(self._proxify, obj))
|
2002-05-26 10:36:41 -03:00
|
|
|
# XXX Check for other types -- not currently needed
|
|
|
|
return obj
|
|
|
|
|
2003-03-12 16:52:00 -04:00
|
|
|
def _getresponse(self, myseq, wait):
|
2003-01-24 23:26:35 -04:00
|
|
|
self.debug("_getresponse:myseq:", myseq)
|
2008-06-12 23:00:47 -03:00
|
|
|
if threading.current_thread() is self.sockthread:
|
2003-05-08 17:26:55 -03:00
|
|
|
# this thread does all reading of requests or responses
|
2002-05-26 10:36:41 -03:00
|
|
|
while 1:
|
2003-03-12 16:52:00 -04:00
|
|
|
response = self.pollresponse(myseq, wait)
|
2002-05-26 10:36:41 -03:00
|
|
|
if response is not None:
|
|
|
|
return response
|
|
|
|
else:
|
2003-05-08 17:26:55 -03:00
|
|
|
# wait for notification from socket handling thread
|
|
|
|
cvar = self.cvars[myseq]
|
|
|
|
cvar.acquire()
|
2006-08-22 12:45:46 -03:00
|
|
|
while myseq not in self.responses:
|
2003-05-08 17:26:55 -03:00
|
|
|
cvar.wait()
|
2002-05-26 10:36:41 -03:00
|
|
|
response = self.responses[myseq]
|
2003-05-08 17:26:55 -03:00
|
|
|
self.debug("_getresponse:%s: thread woke up: response: %s" %
|
|
|
|
(myseq, response))
|
2002-05-26 10:36:41 -03:00
|
|
|
del self.responses[myseq]
|
|
|
|
del self.cvars[myseq]
|
2003-05-08 17:26:55 -03:00
|
|
|
cvar.release()
|
2003-02-17 14:57:16 -04:00
|
|
|
return response
|
2002-05-26 10:36:41 -03:00
|
|
|
|
|
|
|
def newseq(self):
|
|
|
|
self.nextseq = seq = self.nextseq + 2
|
|
|
|
return seq
|
|
|
|
|
|
|
|
def putmessage(self, message):
|
2003-01-24 23:26:35 -04:00
|
|
|
self.debug("putmessage:%d:" % message[0])
|
2002-05-26 10:36:41 -03:00
|
|
|
try:
|
|
|
|
s = pickle.dumps(message)
|
2004-01-21 15:21:11 -04:00
|
|
|
except pickle.PicklingError:
|
2007-02-09 01:37:30 -04:00
|
|
|
print("Cannot pickle:", repr(message), file=sys.__stderr__)
|
2002-05-26 10:36:41 -03:00
|
|
|
raise
|
|
|
|
s = struct.pack("<i", len(s)) + s
|
|
|
|
while len(s) > 0:
|
2003-02-17 14:57:16 -04:00
|
|
|
try:
|
2004-01-21 15:21:11 -04:00
|
|
|
r, w, x = select.select([], [self.sock], [])
|
|
|
|
n = self.sock.send(s[:BUFSIZE])
|
2005-05-10 00:44:24 -03:00
|
|
|
except (AttributeError, TypeError):
|
2007-08-22 22:06:15 -03:00
|
|
|
raise IOError("socket no longer exists")
|
2005-05-10 00:44:24 -03:00
|
|
|
except socket.error:
|
|
|
|
raise
|
2003-02-17 14:57:16 -04:00
|
|
|
else:
|
|
|
|
s = s[n:]
|
2002-05-26 10:36:41 -03:00
|
|
|
|
2007-08-22 18:33:27 -03:00
|
|
|
buff = b''
|
2002-05-26 10:36:41 -03:00
|
|
|
bufneed = 4
|
|
|
|
bufstate = 0 # meaning: 0 => reading count; 1 => reading data
|
|
|
|
|
2003-05-08 17:26:55 -03:00
|
|
|
def pollpacket(self, wait):
|
2002-05-26 10:36:41 -03:00
|
|
|
self._stage0()
|
2007-08-22 18:33:27 -03:00
|
|
|
if len(self.buff) < self.bufneed:
|
2004-01-21 15:21:11 -04:00
|
|
|
r, w, x = select.select([self.sock.fileno()], [], [], wait)
|
|
|
|
if len(r) == 0:
|
2002-05-26 10:36:41 -03:00
|
|
|
return None
|
|
|
|
try:
|
|
|
|
s = self.sock.recv(BUFSIZE)
|
|
|
|
except socket.error:
|
|
|
|
raise EOFError
|
|
|
|
if len(s) == 0:
|
|
|
|
raise EOFError
|
2007-08-22 18:33:27 -03:00
|
|
|
self.buff += s
|
2002-05-26 10:36:41 -03:00
|
|
|
self._stage0()
|
|
|
|
return self._stage1()
|
|
|
|
|
|
|
|
def _stage0(self):
|
2007-08-22 18:33:27 -03:00
|
|
|
if self.bufstate == 0 and len(self.buff) >= 4:
|
|
|
|
s = self.buff[:4]
|
|
|
|
self.buff = self.buff[4:]
|
2002-05-26 10:36:41 -03:00
|
|
|
self.bufneed = struct.unpack("<i", s)[0]
|
|
|
|
self.bufstate = 1
|
|
|
|
|
|
|
|
def _stage1(self):
|
2007-08-22 18:33:27 -03:00
|
|
|
if self.bufstate == 1 and len(self.buff) >= self.bufneed:
|
|
|
|
packet = self.buff[:self.bufneed]
|
|
|
|
self.buff = self.buff[self.bufneed:]
|
2002-05-26 10:36:41 -03:00
|
|
|
self.bufneed = 4
|
|
|
|
self.bufstate = 0
|
|
|
|
return packet
|
|
|
|
|
2003-05-08 17:26:55 -03:00
|
|
|
def pollmessage(self, wait):
|
2002-05-26 10:36:41 -03:00
|
|
|
packet = self.pollpacket(wait)
|
|
|
|
if packet is None:
|
|
|
|
return None
|
|
|
|
try:
|
|
|
|
message = pickle.loads(packet)
|
2004-01-21 15:21:11 -04:00
|
|
|
except pickle.UnpicklingError:
|
2007-02-09 01:37:30 -04:00
|
|
|
print("-----------------------", file=sys.__stderr__)
|
|
|
|
print("cannot unpickle packet:", repr(packet), file=sys.__stderr__)
|
2002-05-26 10:36:41 -03:00
|
|
|
traceback.print_stack(file=sys.__stderr__)
|
2007-02-09 01:37:30 -04:00
|
|
|
print("-----------------------", file=sys.__stderr__)
|
2002-05-26 10:36:41 -03:00
|
|
|
raise
|
|
|
|
return message
|
|
|
|
|
2003-05-08 17:26:55 -03:00
|
|
|
def pollresponse(self, myseq, wait):
|
2003-01-24 23:26:35 -04:00
|
|
|
"""Handle messages received on the socket.
|
|
|
|
|
2003-05-08 17:26:55 -03:00
|
|
|
Some messages received may be asynchronous 'call' or 'queue' requests,
|
|
|
|
and some may be responses for other threads.
|
|
|
|
|
|
|
|
'call' requests are passed to self.localcall() with the expectation of
|
|
|
|
immediate execution, during which time the socket is not serviced.
|
2003-01-24 23:26:35 -04:00
|
|
|
|
2003-05-08 17:26:55 -03:00
|
|
|
'queue' requests are used for tasks (which may block or hang) to be
|
|
|
|
processed in a different thread. These requests are fed into
|
|
|
|
request_queue by self.localcall(). Responses to queued requests are
|
|
|
|
taken from response_queue and sent across the link with the associated
|
|
|
|
sequence numbers. Messages in the queues are (sequence_number,
|
|
|
|
request/response) tuples and code using this module removing messages
|
|
|
|
from the request_queue is responsible for returning the correct
|
|
|
|
sequence number in the response_queue.
|
|
|
|
|
|
|
|
pollresponse() will loop until a response message with the myseq
|
|
|
|
sequence number is received, and will save other responses in
|
|
|
|
self.responses and notify the owning thread.
|
2003-01-24 23:26:35 -04:00
|
|
|
|
|
|
|
"""
|
2002-05-26 10:36:41 -03:00
|
|
|
while 1:
|
2003-05-08 17:26:55 -03:00
|
|
|
# send queued response if there is one available
|
|
|
|
try:
|
|
|
|
qmsg = response_queue.get(0)
|
2008-05-11 16:59:59 -03:00
|
|
|
except queue.Empty:
|
2003-05-08 17:26:55 -03:00
|
|
|
pass
|
|
|
|
else:
|
|
|
|
seq, response = qmsg
|
|
|
|
message = (seq, ('OK', response))
|
|
|
|
self.putmessage(message)
|
|
|
|
# poll for message on link
|
|
|
|
try:
|
|
|
|
message = self.pollmessage(wait)
|
|
|
|
if message is None: # socket not ready
|
|
|
|
return None
|
|
|
|
except EOFError:
|
|
|
|
self.handle_EOF()
|
|
|
|
return None
|
|
|
|
except AttributeError:
|
2002-05-26 10:36:41 -03:00
|
|
|
return None
|
|
|
|
seq, resq = message
|
2003-05-08 17:26:55 -03:00
|
|
|
how = resq[0]
|
2003-01-24 23:26:35 -04:00
|
|
|
self.debug("pollresponse:%d:myseq:%s" % (seq, myseq))
|
2003-05-08 17:26:55 -03:00
|
|
|
# process or queue a request
|
|
|
|
if how in ("CALL", "QUEUE"):
|
2003-01-25 17:33:40 -04:00
|
|
|
self.debug("pollresponse:%d:localcall:call:" % seq)
|
2003-05-08 17:26:55 -03:00
|
|
|
response = self.localcall(seq, resq)
|
2003-01-25 17:33:40 -04:00
|
|
|
self.debug("pollresponse:%d:localcall:response:%s"
|
|
|
|
% (seq, response))
|
2003-05-08 17:26:55 -03:00
|
|
|
if how == "CALL":
|
|
|
|
self.putmessage((seq, response))
|
|
|
|
elif how == "QUEUE":
|
|
|
|
# don't acknowledge the 'queue' request!
|
|
|
|
pass
|
2002-05-26 10:36:41 -03:00
|
|
|
continue
|
2003-05-08 17:26:55 -03:00
|
|
|
# return if completed message transaction
|
2002-05-26 10:36:41 -03:00
|
|
|
elif seq == myseq:
|
|
|
|
return resq
|
2003-05-08 17:26:55 -03:00
|
|
|
# must be a response for a different thread:
|
2002-05-26 10:36:41 -03:00
|
|
|
else:
|
2003-05-08 17:26:55 -03:00
|
|
|
cv = self.cvars.get(seq, None)
|
2003-02-17 14:57:16 -04:00
|
|
|
# response involving unknown sequence number is discarded,
|
2003-05-08 17:26:55 -03:00
|
|
|
# probably intended for prior incarnation of server
|
2002-05-26 10:36:41 -03:00
|
|
|
if cv is not None:
|
2003-05-08 17:26:55 -03:00
|
|
|
cv.acquire()
|
2003-02-17 14:57:16 -04:00
|
|
|
self.responses[seq] = resq
|
2002-05-26 10:36:41 -03:00
|
|
|
cv.notify()
|
2003-05-08 17:26:55 -03:00
|
|
|
cv.release()
|
2002-05-26 10:36:41 -03:00
|
|
|
continue
|
2002-12-31 12:03:23 -04:00
|
|
|
|
2003-05-08 17:26:55 -03:00
|
|
|
def handle_EOF(self):
|
|
|
|
"action taken upon link being closed by peer"
|
|
|
|
self.EOFhook()
|
|
|
|
self.debug("handle_EOF")
|
|
|
|
for key in self.cvars:
|
|
|
|
cv = self.cvars[key]
|
|
|
|
cv.acquire()
|
|
|
|
self.responses[key] = ('EOF', None)
|
|
|
|
cv.notify()
|
|
|
|
cv.release()
|
|
|
|
# call our (possibly overridden) exit function
|
|
|
|
self.exithook()
|
|
|
|
|
|
|
|
def EOFhook(self):
|
|
|
|
"Classes using rpc client/server can override to augment EOF action"
|
|
|
|
pass
|
|
|
|
|
2002-07-25 21:06:42 -03:00
|
|
|
#----------------- end class SocketIO --------------------
|
2002-05-26 10:36:41 -03:00
|
|
|
|
2004-12-21 18:10:32 -04:00
|
|
|
class RemoteObject(object):
|
2002-05-26 10:36:41 -03:00
|
|
|
# Token mix-in class
|
|
|
|
pass
|
|
|
|
|
|
|
|
def remoteref(obj):
|
|
|
|
oid = id(obj)
|
|
|
|
objecttable[oid] = obj
|
|
|
|
return RemoteProxy(oid)
|
|
|
|
|
2004-12-21 18:10:32 -04:00
|
|
|
class RemoteProxy(object):
|
2002-05-26 10:36:41 -03:00
|
|
|
|
|
|
|
def __init__(self, oid):
|
|
|
|
self.oid = oid
|
|
|
|
|
2008-05-11 23:31:37 -03:00
|
|
|
class RPCHandler(socketserver.BaseRequestHandler, SocketIO):
|
2002-05-26 10:36:41 -03:00
|
|
|
|
2002-12-06 17:45:24 -04:00
|
|
|
debugging = False
|
|
|
|
location = "#S" # Server
|
2002-05-26 10:36:41 -03:00
|
|
|
|
|
|
|
def __init__(self, sock, addr, svr):
|
|
|
|
svr.current_handler = self ## cgt xxx
|
|
|
|
SocketIO.__init__(self, sock)
|
2008-05-11 23:31:37 -03:00
|
|
|
socketserver.BaseRequestHandler.__init__(self, sock, addr, svr)
|
2002-05-26 10:36:41 -03:00
|
|
|
|
|
|
|
def handle(self):
|
2008-05-11 23:31:37 -03:00
|
|
|
"handle() method required by socketserver"
|
2002-05-26 10:36:41 -03:00
|
|
|
self.mainloop()
|
|
|
|
|
|
|
|
def get_remote_proxy(self, oid):
|
|
|
|
return RPCProxy(self, oid)
|
|
|
|
|
|
|
|
class RPCClient(SocketIO):
|
|
|
|
|
2002-12-06 17:45:24 -04:00
|
|
|
debugging = False
|
|
|
|
location = "#C" # Client
|
|
|
|
|
2002-07-25 21:06:42 -03:00
|
|
|
nextseq = 1 # Requests coming from the client are odd numbered
|
2002-05-26 10:36:41 -03:00
|
|
|
|
|
|
|
def __init__(self, address, family=socket.AF_INET, type=socket.SOCK_STREAM):
|
2002-08-25 11:08:07 -03:00
|
|
|
self.listening_sock = socket.socket(family, type)
|
|
|
|
self.listening_sock.bind(address)
|
|
|
|
self.listening_sock.listen(1)
|
2002-07-25 21:06:42 -03:00
|
|
|
|
|
|
|
def accept(self):
|
2002-08-25 11:08:07 -03:00
|
|
|
working_sock, address = self.listening_sock.accept()
|
2002-12-23 18:51:03 -04:00
|
|
|
if self.debugging:
|
2007-02-09 01:37:30 -04:00
|
|
|
print("****** Connection request from ", address, file=sys.__stderr__)
|
2003-06-05 20:51:29 -03:00
|
|
|
if address[0] == LOCALHOST:
|
2002-08-25 11:08:07 -03:00
|
|
|
SocketIO.__init__(self, working_sock)
|
2002-07-25 21:06:42 -03:00
|
|
|
else:
|
2007-02-09 01:37:30 -04:00
|
|
|
print("** Invalid host: ", address, file=sys.__stderr__)
|
2002-07-25 21:06:42 -03:00
|
|
|
raise socket.error
|
2002-05-26 10:36:41 -03:00
|
|
|
|
|
|
|
def get_remote_proxy(self, oid):
|
|
|
|
return RPCProxy(self, oid)
|
|
|
|
|
2004-12-21 18:10:32 -04:00
|
|
|
class RPCProxy(object):
|
2002-05-26 10:36:41 -03:00
|
|
|
|
|
|
|
__methods = None
|
|
|
|
__attributes = None
|
|
|
|
|
|
|
|
def __init__(self, sockio, oid):
|
|
|
|
self.sockio = sockio
|
|
|
|
self.oid = oid
|
|
|
|
|
|
|
|
def __getattr__(self, name):
|
|
|
|
if self.__methods is None:
|
|
|
|
self.__getmethods()
|
|
|
|
if self.__methods.get(name):
|
|
|
|
return MethodProxy(self.sockio, self.oid, name)
|
|
|
|
if self.__attributes is None:
|
|
|
|
self.__getattributes()
|
2006-08-22 12:45:46 -03:00
|
|
|
if name in self.__attributes:
|
2004-12-21 18:10:32 -04:00
|
|
|
value = self.sockio.remotecall(self.oid, '__getattribute__',
|
|
|
|
(name,), {})
|
|
|
|
return value
|
|
|
|
else:
|
2007-08-22 22:06:15 -03:00
|
|
|
raise AttributeError(name)
|
2003-05-08 17:26:55 -03:00
|
|
|
|
2002-05-26 10:36:41 -03:00
|
|
|
def __getattributes(self):
|
|
|
|
self.__attributes = self.sockio.remotecall(self.oid,
|
|
|
|
"__attributes__", (), {})
|
|
|
|
|
|
|
|
def __getmethods(self):
|
|
|
|
self.__methods = self.sockio.remotecall(self.oid,
|
|
|
|
"__methods__", (), {})
|
|
|
|
|
|
|
|
def _getmethods(obj, methods):
|
|
|
|
# Helper to get a list of methods from an object
|
|
|
|
# Adds names to dictionary argument 'methods'
|
|
|
|
for name in dir(obj):
|
|
|
|
attr = getattr(obj, name)
|
Merged revisions 55407-55513 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk
................
r55413 | fred.drake | 2007-05-17 12:30:10 -0700 (Thu, 17 May 2007) | 1 line
fix argument name in documentation; match the implementation
................
r55430 | jack.diederich | 2007-05-18 06:39:59 -0700 (Fri, 18 May 2007) | 1 line
Implements class decorators, PEP 3129.
................
r55432 | guido.van.rossum | 2007-05-18 08:09:41 -0700 (Fri, 18 May 2007) | 2 lines
obsubmit.
................
r55434 | guido.van.rossum | 2007-05-18 09:39:10 -0700 (Fri, 18 May 2007) | 3 lines
Fix bug in test_inspect. (I presume this is how it should be fixed;
Jack Diedrich, please verify.)
................
r55460 | brett.cannon | 2007-05-20 00:31:57 -0700 (Sun, 20 May 2007) | 4 lines
Remove the imageop module. With imgfile already removed in Python 3.0 and
rgbimg gone in Python 2.6 the unit tests themselves were made worthless. Plus
third-party libraries perform the same function much better.
................
r55469 | neal.norwitz | 2007-05-20 11:28:20 -0700 (Sun, 20 May 2007) | 118 lines
Merged revisions 55324-55467 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r55348 | georg.brandl | 2007-05-15 13:19:34 -0700 (Tue, 15 May 2007) | 4 lines
HTML-escape the plain traceback in cgitb's HTML output, to prevent
the traceback inadvertently or maliciously closing the comment and
injecting HTML into the error page.
........
r55372 | neal.norwitz | 2007-05-15 21:33:50 -0700 (Tue, 15 May 2007) | 6 lines
Port rev 55353 from Guido:
Add what looks like a necessary call to PyErr_NoMemory() when PyMem_MALLOC()
fails.
Will backport.
........
r55377 | neal.norwitz | 2007-05-15 22:06:33 -0700 (Tue, 15 May 2007) | 1 line
Mention removal of some directories for obsolete platforms
........
r55380 | brett.cannon | 2007-05-15 22:50:03 -0700 (Tue, 15 May 2007) | 2 lines
Change the maintainer of the BeOS port.
........
r55383 | georg.brandl | 2007-05-16 06:44:18 -0700 (Wed, 16 May 2007) | 2 lines
Bug #1719995: don't use deprecated method in sets example.
........
r55386 | neal.norwitz | 2007-05-16 13:05:11 -0700 (Wed, 16 May 2007) | 5 lines
Fix bug in marshal where bad data would cause a segfault due to
lack of an infinite recursion check.
Contributed by Damien Miller at Google.
........
r55389 | brett.cannon | 2007-05-16 15:42:29 -0700 (Wed, 16 May 2007) | 6 lines
Remove the gopherlib module. It has been raising a DeprecationWarning since
Python 2.5.
Also remove gopher support from urllib/urllib2. As both imported gopherlib the
usage of the support would have raised a DeprecationWarning.
........
r55394 | raymond.hettinger | 2007-05-16 18:08:04 -0700 (Wed, 16 May 2007) | 1 line
calendar.py gets no benefit from xrange() instead of range()
........
r55395 | brett.cannon | 2007-05-16 19:02:56 -0700 (Wed, 16 May 2007) | 3 lines
Complete deprecation of BaseException.message. Some subclasses were directly
accessing the message attribute instead of using the descriptor.
........
r55396 | neal.norwitz | 2007-05-16 23:11:36 -0700 (Wed, 16 May 2007) | 4 lines
Reduce the max stack depth to see if this fixes the segfaults on
Windows and some other boxes. If this is successful, this rev should
be backported. I'm not sure how close to the limit we should push this.
........
r55397 | neal.norwitz | 2007-05-16 23:23:50 -0700 (Wed, 16 May 2007) | 4 lines
Set the depth to something very small to try to determine if the
crashes on Windows are really due to the stack size or possibly
some other problem.
........
r55398 | neal.norwitz | 2007-05-17 00:04:46 -0700 (Thu, 17 May 2007) | 4 lines
Last try for tweaking the max stack depth. 5000 was the original value,
4000 didn't work either. 1000 does work on Windows. If 2000 works,
that will hopefully be a reasonable balance.
........
r55412 | fred.drake | 2007-05-17 12:29:58 -0700 (Thu, 17 May 2007) | 1 line
fix argument name in documentation; match the implementation
........
r55427 | neal.norwitz | 2007-05-17 22:47:16 -0700 (Thu, 17 May 2007) | 1 line
Verify neither dumps or loads overflow the stack and segfault.
........
r55446 | collin.winter | 2007-05-18 16:11:24 -0700 (Fri, 18 May 2007) | 1 line
Backport PEP 3110's new 'except' syntax to 2.6.
........
r55448 | raymond.hettinger | 2007-05-18 18:11:16 -0700 (Fri, 18 May 2007) | 1 line
Improvements to NamedTuple's implementation, tests, and documentation
........
r55449 | raymond.hettinger | 2007-05-18 18:50:11 -0700 (Fri, 18 May 2007) | 1 line
Fix beginner mistake -- don't mix spaces and tabs.
........
r55450 | neal.norwitz | 2007-05-18 20:48:47 -0700 (Fri, 18 May 2007) | 1 line
Clear data so random memory does not get freed. Will backport.
........
r55452 | neal.norwitz | 2007-05-18 21:34:55 -0700 (Fri, 18 May 2007) | 3 lines
Whoops, need to pay attention to those test failures.
Move the clear to *before* the first use, not after.
........
r55453 | neal.norwitz | 2007-05-18 21:35:52 -0700 (Fri, 18 May 2007) | 1 line
Give some clue as to what happened if the test fails.
........
r55455 | georg.brandl | 2007-05-19 11:09:26 -0700 (Sat, 19 May 2007) | 2 lines
Fix docstring for add_package in site.py.
........
r55458 | brett.cannon | 2007-05-20 00:09:50 -0700 (Sun, 20 May 2007) | 2 lines
Remove the rgbimg module. It has been deprecated since Python 2.5.
........
r55465 | nick.coghlan | 2007-05-20 04:12:49 -0700 (Sun, 20 May 2007) | 1 line
Fix typo in example (should be backported, but my maintenance branch is woefully out of date)
........
................
r55472 | brett.cannon | 2007-05-20 12:06:18 -0700 (Sun, 20 May 2007) | 2 lines
Remove imageop from the Windows build process.
................
r55486 | neal.norwitz | 2007-05-20 23:59:52 -0700 (Sun, 20 May 2007) | 1 line
Remove callable() builtin
................
r55506 | neal.norwitz | 2007-05-22 00:43:29 -0700 (Tue, 22 May 2007) | 78 lines
Merged revisions 55468-55505 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r55468 | neal.norwitz | 2007-05-20 11:06:27 -0700 (Sun, 20 May 2007) | 1 line
rotor is long gone.
........
r55470 | neal.norwitz | 2007-05-20 11:43:00 -0700 (Sun, 20 May 2007) | 1 line
Update directories/files at the top-level.
........
r55471 | brett.cannon | 2007-05-20 12:05:06 -0700 (Sun, 20 May 2007) | 2 lines
Try to remove rgbimg from Windows builds.
........
r55474 | brett.cannon | 2007-05-20 16:17:38 -0700 (Sun, 20 May 2007) | 4 lines
Remove the macfs module. This led to the deprecation of macostools.touched();
it completely relied on macfs and is a no-op on OS X according to code
comments.
........
r55476 | brett.cannon | 2007-05-20 16:56:18 -0700 (Sun, 20 May 2007) | 3 lines
Move imgfile import to the global namespace to trigger an import error ASAP to
prevent creation of a test file.
........
r55477 | brett.cannon | 2007-05-20 16:57:38 -0700 (Sun, 20 May 2007) | 3 lines
Cause posixfile to raise a DeprecationWarning. Documented as deprecated since
Ptyhon 1.5.
........
r55479 | andrew.kuchling | 2007-05-20 17:03:15 -0700 (Sun, 20 May 2007) | 1 line
Note removed modules
........
r55481 | martin.v.loewis | 2007-05-20 21:35:47 -0700 (Sun, 20 May 2007) | 2 lines
Add Alexandre Vassalotti.
........
r55482 | george.yoshida | 2007-05-20 21:41:21 -0700 (Sun, 20 May 2007) | 4 lines
fix against r55474 [Remove the macfs module]
Remove "libmacfs.tex" from Makefile.deps and mac/mac.tex.
........
r55487 | raymond.hettinger | 2007-05-21 01:13:35 -0700 (Mon, 21 May 2007) | 1 line
Replace assertion with straight error-checking.
........
r55489 | raymond.hettinger | 2007-05-21 09:40:10 -0700 (Mon, 21 May 2007) | 1 line
Allow all alphanumeric and underscores in type and field names.
........
r55490 | facundo.batista | 2007-05-21 10:32:32 -0700 (Mon, 21 May 2007) | 5 lines
Added timeout support to HTTPSConnection, through the
socket.create_connection function. Also added a small
test for this, and updated NEWS file.
........
r55495 | georg.brandl | 2007-05-21 13:34:16 -0700 (Mon, 21 May 2007) | 2 lines
Patch #1686487: you can now pass any mapping after '**' in function calls.
........
r55502 | neal.norwitz | 2007-05-21 23:03:36 -0700 (Mon, 21 May 2007) | 1 line
Document new params to HTTPSConnection
........
r55504 | neal.norwitz | 2007-05-22 00:16:10 -0700 (Tue, 22 May 2007) | 1 line
Stop using METH_OLDARGS
........
r55505 | neal.norwitz | 2007-05-22 00:16:44 -0700 (Tue, 22 May 2007) | 1 line
Stop using METH_OLDARGS implicitly
........
................
2007-05-22 15:11:13 -03:00
|
|
|
if hasattr(attr, '__call__'):
|
2002-05-26 10:36:41 -03:00
|
|
|
methods[name] = 1
|
2007-06-07 20:15:56 -03:00
|
|
|
if isinstance(obj, type):
|
2002-05-26 10:36:41 -03:00
|
|
|
for super in obj.__bases__:
|
|
|
|
_getmethods(super, methods)
|
|
|
|
|
|
|
|
def _getattributes(obj, attributes):
|
|
|
|
for name in dir(obj):
|
|
|
|
attr = getattr(obj, name)
|
Merged revisions 55407-55513 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk
................
r55413 | fred.drake | 2007-05-17 12:30:10 -0700 (Thu, 17 May 2007) | 1 line
fix argument name in documentation; match the implementation
................
r55430 | jack.diederich | 2007-05-18 06:39:59 -0700 (Fri, 18 May 2007) | 1 line
Implements class decorators, PEP 3129.
................
r55432 | guido.van.rossum | 2007-05-18 08:09:41 -0700 (Fri, 18 May 2007) | 2 lines
obsubmit.
................
r55434 | guido.van.rossum | 2007-05-18 09:39:10 -0700 (Fri, 18 May 2007) | 3 lines
Fix bug in test_inspect. (I presume this is how it should be fixed;
Jack Diedrich, please verify.)
................
r55460 | brett.cannon | 2007-05-20 00:31:57 -0700 (Sun, 20 May 2007) | 4 lines
Remove the imageop module. With imgfile already removed in Python 3.0 and
rgbimg gone in Python 2.6 the unit tests themselves were made worthless. Plus
third-party libraries perform the same function much better.
................
r55469 | neal.norwitz | 2007-05-20 11:28:20 -0700 (Sun, 20 May 2007) | 118 lines
Merged revisions 55324-55467 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r55348 | georg.brandl | 2007-05-15 13:19:34 -0700 (Tue, 15 May 2007) | 4 lines
HTML-escape the plain traceback in cgitb's HTML output, to prevent
the traceback inadvertently or maliciously closing the comment and
injecting HTML into the error page.
........
r55372 | neal.norwitz | 2007-05-15 21:33:50 -0700 (Tue, 15 May 2007) | 6 lines
Port rev 55353 from Guido:
Add what looks like a necessary call to PyErr_NoMemory() when PyMem_MALLOC()
fails.
Will backport.
........
r55377 | neal.norwitz | 2007-05-15 22:06:33 -0700 (Tue, 15 May 2007) | 1 line
Mention removal of some directories for obsolete platforms
........
r55380 | brett.cannon | 2007-05-15 22:50:03 -0700 (Tue, 15 May 2007) | 2 lines
Change the maintainer of the BeOS port.
........
r55383 | georg.brandl | 2007-05-16 06:44:18 -0700 (Wed, 16 May 2007) | 2 lines
Bug #1719995: don't use deprecated method in sets example.
........
r55386 | neal.norwitz | 2007-05-16 13:05:11 -0700 (Wed, 16 May 2007) | 5 lines
Fix bug in marshal where bad data would cause a segfault due to
lack of an infinite recursion check.
Contributed by Damien Miller at Google.
........
r55389 | brett.cannon | 2007-05-16 15:42:29 -0700 (Wed, 16 May 2007) | 6 lines
Remove the gopherlib module. It has been raising a DeprecationWarning since
Python 2.5.
Also remove gopher support from urllib/urllib2. As both imported gopherlib the
usage of the support would have raised a DeprecationWarning.
........
r55394 | raymond.hettinger | 2007-05-16 18:08:04 -0700 (Wed, 16 May 2007) | 1 line
calendar.py gets no benefit from xrange() instead of range()
........
r55395 | brett.cannon | 2007-05-16 19:02:56 -0700 (Wed, 16 May 2007) | 3 lines
Complete deprecation of BaseException.message. Some subclasses were directly
accessing the message attribute instead of using the descriptor.
........
r55396 | neal.norwitz | 2007-05-16 23:11:36 -0700 (Wed, 16 May 2007) | 4 lines
Reduce the max stack depth to see if this fixes the segfaults on
Windows and some other boxes. If this is successful, this rev should
be backported. I'm not sure how close to the limit we should push this.
........
r55397 | neal.norwitz | 2007-05-16 23:23:50 -0700 (Wed, 16 May 2007) | 4 lines
Set the depth to something very small to try to determine if the
crashes on Windows are really due to the stack size or possibly
some other problem.
........
r55398 | neal.norwitz | 2007-05-17 00:04:46 -0700 (Thu, 17 May 2007) | 4 lines
Last try for tweaking the max stack depth. 5000 was the original value,
4000 didn't work either. 1000 does work on Windows. If 2000 works,
that will hopefully be a reasonable balance.
........
r55412 | fred.drake | 2007-05-17 12:29:58 -0700 (Thu, 17 May 2007) | 1 line
fix argument name in documentation; match the implementation
........
r55427 | neal.norwitz | 2007-05-17 22:47:16 -0700 (Thu, 17 May 2007) | 1 line
Verify neither dumps or loads overflow the stack and segfault.
........
r55446 | collin.winter | 2007-05-18 16:11:24 -0700 (Fri, 18 May 2007) | 1 line
Backport PEP 3110's new 'except' syntax to 2.6.
........
r55448 | raymond.hettinger | 2007-05-18 18:11:16 -0700 (Fri, 18 May 2007) | 1 line
Improvements to NamedTuple's implementation, tests, and documentation
........
r55449 | raymond.hettinger | 2007-05-18 18:50:11 -0700 (Fri, 18 May 2007) | 1 line
Fix beginner mistake -- don't mix spaces and tabs.
........
r55450 | neal.norwitz | 2007-05-18 20:48:47 -0700 (Fri, 18 May 2007) | 1 line
Clear data so random memory does not get freed. Will backport.
........
r55452 | neal.norwitz | 2007-05-18 21:34:55 -0700 (Fri, 18 May 2007) | 3 lines
Whoops, need to pay attention to those test failures.
Move the clear to *before* the first use, not after.
........
r55453 | neal.norwitz | 2007-05-18 21:35:52 -0700 (Fri, 18 May 2007) | 1 line
Give some clue as to what happened if the test fails.
........
r55455 | georg.brandl | 2007-05-19 11:09:26 -0700 (Sat, 19 May 2007) | 2 lines
Fix docstring for add_package in site.py.
........
r55458 | brett.cannon | 2007-05-20 00:09:50 -0700 (Sun, 20 May 2007) | 2 lines
Remove the rgbimg module. It has been deprecated since Python 2.5.
........
r55465 | nick.coghlan | 2007-05-20 04:12:49 -0700 (Sun, 20 May 2007) | 1 line
Fix typo in example (should be backported, but my maintenance branch is woefully out of date)
........
................
r55472 | brett.cannon | 2007-05-20 12:06:18 -0700 (Sun, 20 May 2007) | 2 lines
Remove imageop from the Windows build process.
................
r55486 | neal.norwitz | 2007-05-20 23:59:52 -0700 (Sun, 20 May 2007) | 1 line
Remove callable() builtin
................
r55506 | neal.norwitz | 2007-05-22 00:43:29 -0700 (Tue, 22 May 2007) | 78 lines
Merged revisions 55468-55505 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r55468 | neal.norwitz | 2007-05-20 11:06:27 -0700 (Sun, 20 May 2007) | 1 line
rotor is long gone.
........
r55470 | neal.norwitz | 2007-05-20 11:43:00 -0700 (Sun, 20 May 2007) | 1 line
Update directories/files at the top-level.
........
r55471 | brett.cannon | 2007-05-20 12:05:06 -0700 (Sun, 20 May 2007) | 2 lines
Try to remove rgbimg from Windows builds.
........
r55474 | brett.cannon | 2007-05-20 16:17:38 -0700 (Sun, 20 May 2007) | 4 lines
Remove the macfs module. This led to the deprecation of macostools.touched();
it completely relied on macfs and is a no-op on OS X according to code
comments.
........
r55476 | brett.cannon | 2007-05-20 16:56:18 -0700 (Sun, 20 May 2007) | 3 lines
Move imgfile import to the global namespace to trigger an import error ASAP to
prevent creation of a test file.
........
r55477 | brett.cannon | 2007-05-20 16:57:38 -0700 (Sun, 20 May 2007) | 3 lines
Cause posixfile to raise a DeprecationWarning. Documented as deprecated since
Ptyhon 1.5.
........
r55479 | andrew.kuchling | 2007-05-20 17:03:15 -0700 (Sun, 20 May 2007) | 1 line
Note removed modules
........
r55481 | martin.v.loewis | 2007-05-20 21:35:47 -0700 (Sun, 20 May 2007) | 2 lines
Add Alexandre Vassalotti.
........
r55482 | george.yoshida | 2007-05-20 21:41:21 -0700 (Sun, 20 May 2007) | 4 lines
fix against r55474 [Remove the macfs module]
Remove "libmacfs.tex" from Makefile.deps and mac/mac.tex.
........
r55487 | raymond.hettinger | 2007-05-21 01:13:35 -0700 (Mon, 21 May 2007) | 1 line
Replace assertion with straight error-checking.
........
r55489 | raymond.hettinger | 2007-05-21 09:40:10 -0700 (Mon, 21 May 2007) | 1 line
Allow all alphanumeric and underscores in type and field names.
........
r55490 | facundo.batista | 2007-05-21 10:32:32 -0700 (Mon, 21 May 2007) | 5 lines
Added timeout support to HTTPSConnection, through the
socket.create_connection function. Also added a small
test for this, and updated NEWS file.
........
r55495 | georg.brandl | 2007-05-21 13:34:16 -0700 (Mon, 21 May 2007) | 2 lines
Patch #1686487: you can now pass any mapping after '**' in function calls.
........
r55502 | neal.norwitz | 2007-05-21 23:03:36 -0700 (Mon, 21 May 2007) | 1 line
Document new params to HTTPSConnection
........
r55504 | neal.norwitz | 2007-05-22 00:16:10 -0700 (Tue, 22 May 2007) | 1 line
Stop using METH_OLDARGS
........
r55505 | neal.norwitz | 2007-05-22 00:16:44 -0700 (Tue, 22 May 2007) | 1 line
Stop using METH_OLDARGS implicitly
........
................
2007-05-22 15:11:13 -03:00
|
|
|
if not hasattr(attr, '__call__'):
|
2002-12-31 12:03:23 -04:00
|
|
|
attributes[name] = 1
|
2002-05-26 10:36:41 -03:00
|
|
|
|
2004-12-21 18:10:32 -04:00
|
|
|
class MethodProxy(object):
|
2002-05-26 10:36:41 -03:00
|
|
|
|
|
|
|
def __init__(self, sockio, oid, name):
|
|
|
|
self.sockio = sockio
|
|
|
|
self.oid = oid
|
|
|
|
self.name = name
|
|
|
|
|
|
|
|
def __call__(self, *args, **kwargs):
|
|
|
|
value = self.sockio.remotecall(self.oid, self.name, args, kwargs)
|
|
|
|
return value
|
|
|
|
|
|
|
|
|
2003-09-09 23:42:18 -03:00
|
|
|
# XXX KBK 09Sep03 We need a proper unit test for this module. Previously
|
|
|
|
# existing test code was removed at Rev 1.27.
|