Index: Misc/NEWS =================================================================== --- Misc/NEWS (revision 63574) +++ Misc/NEWS (working copy) @@ -161,9 +161,6 @@ - The multifile module has been deprecated as per PEP 4. -- The SocketServer module has been renamed 'socketserver'. The old - name is now deprecated. - - The imageop module has been deprecated for removal in Python 3.0. - Issue #2250: Exceptions raised during evaluation of names in Index: Misc/cheatsheet =================================================================== --- Misc/cheatsheet (revision 63574) +++ Misc/cheatsheet (working copy) @@ -1952,7 +1952,7 @@ pyexpat Interface to the Expay XML parser. py_compile Routine to "compile" a .py file to a .pyc file. pyclbr Parse a Python file and retrieve classes and methods. -queue A multi-producer, multi-consumer queue. +Queue A multi-producer, multi-consumer queue. quopri Conversions to/from quoted-printable transport encoding. rand Don't use unless you want compatibility with C's rand(). random Random variable generators @@ -1973,7 +1973,7 @@ sys.path. smtplib SMTP Client class (RFC 821) sndhdr Several routines that help recognizing sound. -socketserver Generic socket server classes. +SocketServer Generic socket server classes. stat Constants and functions for interpreting stat/lstat struct. statcache Maintain a cache of file stats. statvfs Constants for interpreting statvfs struct as returned by @@ -2271,3 +2271,5 @@ after editing, any remembered breakpoints are likely to be wrong. Always single-steps through top-most stack frame. That is, "c" acts like "n". + + Index: Doc/reference/simple_stmts.rst =================================================================== --- Doc/reference/simple_stmts.rst (revision 63574) +++ Doc/reference/simple_stmts.rst (working copy) @@ -534,7 +534,7 @@ If no expressions are present, :keyword:`raise` re-raises the last exception that was active in the current scope. If no exception is active in the current scope, a :exc:`TypeError` exception is raised indicating that this is an error -(if running under IDLE, a :exc:`queue.Empty` exception is raised instead). +(if running under IDLE, a :exc:`Queue.Empty` exception is raised instead). Otherwise, :keyword:`raise` evaluates the expressions to get three objects, using ``None`` as the value of omitted expressions. The first two objects are Index: Doc/whatsnew/2.6.rst =================================================================== --- Doc/whatsnew/2.6.rst (revision 63574) +++ Doc/whatsnew/2.6.rst (working copy) @@ -1963,7 +1963,7 @@ used to hold character data. (Contributed by Achim Gaedke; :issue:`1137`.) -* The :mod:`queue` module now provides queue classes that retrieve entries +* The :mod:`Queue` module now provides queue classes that retrieve entries in different orders. The :class:`PriorityQueue` class stores queued items in a heap and retrieves them in priority order, and :class:`LifoQueue` retrieves the most recently added entries first, @@ -2067,7 +2067,7 @@ and connects to it using an optional timeout value, returning the connected socket object. -* The base classes in the :mod:`socketserver` module now support +* The base classes in the :mod:`SocketServer` module now support calling a :meth:`handle_timeout` method after a span of inactivity specified by the server's :attr:`timeout` attribute. (Contributed by Michael Pomraning.) The :meth:`serve_forever` method Index: Doc/tutorial/stdlib2.rst =================================================================== --- Doc/tutorial/stdlib2.rst (revision 63574) +++ Doc/tutorial/stdlib2.rst (working copy) @@ -198,7 +198,7 @@ While those tools are powerful, minor design errors can result in problems that are difficult to reproduce. So, the preferred approach to task coordination is to concentrate all access to a resource in a single thread and then use the -:mod:`queue` module to feed that thread with requests from other threads. +:mod:`Queue` module to feed that thread with requests from other threads. Applications using :class:`Queue` objects for inter-thread communication and coordination are easier to design, more readable, and more reliable. Index: Doc/library/queue.rst =================================================================== --- Doc/library/queue.rst (revision 63574) +++ Doc/library/queue.rst (working copy) @@ -1,18 +1,14 @@ -:mod:`queue` --- A synchronized queue class + +:mod:`Queue` --- A synchronized queue class =========================================== .. module:: Queue - :synopsis: Old name for the queue module. - -.. module:: queue :synopsis: A synchronized queue class. .. note:: - The :mod:`Queue` module has been renamed to :mod:`queue` in Python 3.0. It - is importable under both names in Python 2.6 and the rest of the 2.x series. + The :mod:`Queue` module has been renamed to `queue` in Python 3.0. - -The :mod:`queue` module implements multi-producer, multi-consumer queues. +The :mod:`Queue` module implements multi-producer, multi-consumer queues. It is especially useful in threaded programming when information must be exchanged safely between multiple threads. The :class:`Queue` class in this module implements all the required locking semantics. It depends on the @@ -26,7 +22,7 @@ the entries are kept sorted (using the :mod:`heapq` module) and the lowest valued entry is retrieved first. -The :mod:`queue` module defines the following classes and exceptions: +The :mod:`Queue` module defines the following classes and exceptions: .. class:: Queue(maxsize) Index: Doc/library/logging.rst =================================================================== --- Doc/library/logging.rst (revision 63574) +++ Doc/library/logging.rst (working copy) @@ -1299,17 +1299,17 @@ logger2.warning('Jail zesty vixen who grabbed pay from quack.') logger2.error('The five boxing wizards jump quickly.') -At the receiving end, you can set up a receiver using the :mod:`socketserver` +At the receiving end, you can set up a receiver using the :mod:`SocketServer` module. Here is a basic working example:: import cPickle import logging import logging.handlers - import socketserver + import SocketServer import struct - class LogRecordStreamHandler(socketserver.StreamRequestHandler): + class LogRecordStreamHandler(SocketServer.StreamRequestHandler): """Handler for a streaming logging request. This basically logs the record using whatever logging policy is @@ -1351,7 +1351,7 @@ # cycles and network bandwidth! logger.handle(record) - class LogRecordSocketReceiver(socketserver.ThreadingTCPServer): + class LogRecordSocketReceiver(SocketServer.ThreadingTCPServer): """simple TCP socket-based logging receiver suitable for testing. """ @@ -1360,7 +1360,7 @@ def __init__(self, host='localhost', port=logging.handlers.DEFAULT_TCP_LOGGING_PORT, handler=LogRecordStreamHandler): - socketserver.ThreadingTCPServer.__init__(self, (host, port), handler) + SocketServer.ThreadingTCPServer.__init__(self, (host, port), handler) self.abort = 0 self.timeout = 1 self.logname = None Index: Doc/library/socket.rst =================================================================== --- Doc/library/socket.rst (revision 63574) +++ Doc/library/socket.rst (working copy) @@ -481,7 +481,7 @@ .. seealso:: - Module :mod:`socketserver` + Module :mod:`SocketServer` Classes that simplify writing network servers. Index: Doc/library/socketserver.rst =================================================================== --- Doc/library/socketserver.rst (revision 63574) +++ Doc/library/socketserver.rst (working copy) @@ -1,19 +1,16 @@ -:mod:`socketserver` --- A framework for network servers + +:mod:`SocketServer` --- A framework for network servers ======================================================= .. module:: SocketServer - :synopsis: Old name for the socketserver module. - -.. module:: socketserver :synopsis: A framework for network servers. .. note:: - The :mod:`SocketServer` module has been renamed to :mod:`socketserver` in - Python 3.0. It is importable under both names in Python 2.6 and the rest of - the 2.x series. + The :mod:`SocketServer` module has been renamed to `socketserver` in + Python 3.0. -The :mod:`socketserver` module simplifies the task of writing network servers. +The :mod:`SocketServer` module simplifies the task of writing network servers. There are four basic server classes: :class:`TCPServer` uses the Internet TCP protocol, which provides for continuous streams of data between the client and @@ -220,7 +217,7 @@ users of the server object. .. XXX should the default implementations of these be documented, or should - it be assumed that the user will look at socketserver.py? + it be assumed that the user will look at SocketServer.py? .. function:: finish_request() @@ -325,14 +322,14 @@ Examples -------- -:class:`socketserver.TCPServer` Example +:class:`SocketServer.TCPServer` Example ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is the server side:: - import socketserver + import SocketServer - class MyTCPHandler(socketserver.BaseRequestHandler): + class MyTCPHandler(SocketServer.BaseRequestHandler): """ The RequestHandler class for our server. @@ -353,7 +350,7 @@ HOST, PORT = "localhost", 9999 # Create the server, binding to localhost on port 9999 - server = socketserver.TCPServer((HOST, PORT), MyTCPHandler) + server = SocketServer.TCPServer((HOST, PORT), MyTCPHandler) # Activate the server; this will keep running until you # interrupt the program with Ctrl-C @@ -362,7 +359,7 @@ An alternative request handler class that makes use of streams (file-like objects that simplify communication by providing the standard file interface):: - class MyTCPHandler(socketserver.StreamRequestHandler): + class MyTCPHandler(SocketServer.StreamRequestHandler): def handle(self): # self.rfile is a file-like object created by the handler; @@ -423,14 +420,14 @@ Received: PYTHON IS NICE -:class:`socketserver.UDPServer` Example +:class:`SocketServer.UDPServer` Example ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is the server side:: - import socketserver + import SocketServer - class MyUDPHandler(socketserver.BaseRequestHandler): + class MyUDPHandler(SocketServer.BaseRequestHandler): """ This class works similar to the TCP handler class, except that self.request consists of a pair of data and client socket, and since @@ -447,7 +444,7 @@ if __name__ == "__main__": HOST, PORT = "localhost", 9999 - server = socketserver.UDPServer((HOST, PORT), BaseUDPRequestHandler) + server = SocketServer.UDPServer((HOST, PORT), BaseUDPRequestHandler) server.serve_forever() This is the client side:: @@ -482,9 +479,9 @@ import socket import threading - import socketserver + import SocketServer - class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler): + class ThreadedTCPRequestHandler(SocketServer.BaseRequestHandler): def handle(self): data = self.request.recv(1024) @@ -492,7 +489,7 @@ response = "%s: %s" % (cur_thread.getName(), data) self.request.send(response) - class ThreadedTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer): + class ThreadedTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer): pass def client(ip, port, message): Index: Doc/library/simplexmlrpcserver.rst =================================================================== --- Doc/library/simplexmlrpcserver.rst (revision 63574) +++ Doc/library/simplexmlrpcserver.rst (working copy) @@ -22,7 +22,7 @@ functions that can be called by the XML-RPC protocol. The *requestHandler* parameter should be a factory for request handler instances; it defaults to :class:`SimpleXMLRPCRequestHandler`. The *addr* and *requestHandler* parameters - are passed to the :class:`socketserver.TCPServer` constructor. If *logRequests* + are passed to the :class:`SocketServer.TCPServer` constructor. If *logRequests* is true (the default), requests will be logged; setting this parameter to false will turn off logging. The *allow_none* and *encoding* parameters are passed on to :mod:`xmlrpclib` and control the XML-RPC responses that will be returned @@ -63,7 +63,7 @@ -------------------------- The :class:`SimpleXMLRPCServer` class is based on -:class:`socketserver.TCPServer` and provides a means of creating simple, stand +:class:`SocketServer.TCPServer` and provides a means of creating simple, stand alone XML-RPC servers. Index: Doc/library/basehttpserver.rst =================================================================== --- Doc/library/basehttpserver.rst (revision 63574) +++ Doc/library/basehttpserver.rst (working copy) @@ -21,7 +21,7 @@ functioning Web servers. See the :mod:`SimpleHTTPServer` and :mod:`CGIHTTPServer` modules. -The first class, :class:`HTTPServer`, is a :class:`socketserver.TCPServer` +The first class, :class:`HTTPServer`, is a :class:`SocketServer.TCPServer` subclass. It creates and listens at the HTTP socket, dispatching the requests to a handler. Code to create and run the server looks like this:: Index: Doc/library/threading.rst =================================================================== --- Doc/library/threading.rst (revision 63574) +++ Doc/library/threading.rst (working copy) @@ -8,7 +8,7 @@ This module constructs higher-level threading interfaces on top of the lower level :mod:`thread` module. -See also the :mod:`mutex` and :mod:`queue` modules. +See also the :mod:`mutex` and :mod:`Queue` modules. The :mod:`dummy_threading` module is provided for situations where :mod:`threading` cannot be used because :mod:`thread` is missing. Index: Lib/idlelib/rpc.py =================================================================== --- Lib/idlelib/rpc.py (revision 63574) +++ Lib/idlelib/rpc.py (working copy) @@ -5,7 +5,7 @@ has only one client per server, this was not a limitation. +---------------------------------+ +-------------+ - | socketserver.BaseRequestHandler | | SocketIO | + | SocketServer.BaseRequestHandler | | SocketIO | +---------------------------------+ +-------------+ ^ | register() | | | unregister()| @@ -31,7 +31,7 @@ import os import socket import select -import socketserver +import SocketServer import struct import cPickle as pickle import threading @@ -66,12 +66,12 @@ BUFSIZE = 8*1024 LOCALHOST = '127.0.0.1' -class RPCServer(socketserver.TCPServer): +class RPCServer(SocketServer.TCPServer): def __init__(self, addr, handlerclass=None): if handlerclass is None: handlerclass = RPCHandler - socketserver.TCPServer.__init__(self, addr, handlerclass) + SocketServer.TCPServer.__init__(self, addr, handlerclass) def server_bind(self): "Override TCPServer method, no bind() phase for connecting entity" @@ -492,7 +492,7 @@ def __init__(self, oid): self.oid = oid -class RPCHandler(socketserver.BaseRequestHandler, SocketIO): +class RPCHandler(SocketServer.BaseRequestHandler, SocketIO): debugging = False location = "#S" # Server @@ -500,10 +500,10 @@ def __init__(self, sock, addr, svr): svr.current_handler = self ## cgt xxx SocketIO.__init__(self, sock) - socketserver.BaseRequestHandler.__init__(self, sock, addr, svr) + SocketServer.BaseRequestHandler.__init__(self, sock, addr, svr) def handle(self): - "handle() method required by socketserver" + "handle() method required by SocketServer" self.mainloop() def get_remote_proxy(self, oid): Index: Lib/lib-old/SocketServer.py =================================================================== --- Lib/lib-old/SocketServer.py (revision 63574) +++ Lib/lib-old/SocketServer.py (working copy) @@ -1,8 +0,0 @@ -import sys -from warnings import warnpy3k - -warnpy3k("the SocketServer module has been renamed " - "to 'socketserver' in Python 3.0", stacklevel=2) - -import socketserver -sys.modules[__name__] = socketserver Index: Lib/logging/config.py =================================================================== --- Lib/logging/config.py (revision 63574) +++ Lib/logging/config.py (working copy) @@ -35,7 +35,7 @@ except ImportError: thread = None -from socketserver import ThreadingTCPServer, StreamRequestHandler +from SocketServer import ThreadingTCPServer, StreamRequestHandler DEFAULT_LOGGING_CONFIG_PORT = 9030 Index: Lib/BaseHTTPServer.py =================================================================== --- Lib/BaseHTTPServer.py (revision 63574) +++ Lib/BaseHTTPServer.py (working copy) @@ -74,7 +74,7 @@ import time import socket # For gethostbyaddr() import mimetools -import socketserver +import SocketServer # Default error message template DEFAULT_ERROR_MESSAGE = """\ @@ -94,19 +94,19 @@ def _quote_html(html): return html.replace("&", "&").replace("<", "<").replace(">", ">") -class HTTPServer(socketserver.TCPServer): +class HTTPServer(SocketServer.TCPServer): allow_reuse_address = 1 # Seems to make sense in testing environment def server_bind(self): """Override server_bind to store the server name.""" - socketserver.TCPServer.server_bind(self) + SocketServer.TCPServer.server_bind(self) host, port = self.socket.getsockname()[:2] self.server_name = socket.getfqdn(host) self.server_port = port -class BaseHTTPRequestHandler(socketserver.StreamRequestHandler): +class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler): """HTTP request handler base class. Index: Lib/test/test_py3kwarn.py =================================================================== --- Lib/test/test_py3kwarn.py (revision 63574) +++ Lib/test/test_py3kwarn.py (working copy) @@ -216,7 +216,6 @@ class TestStdlibRenames(unittest.TestCase): renames = {'Queue': 'queue', - 'SocketServer': 'socketserver', 'ConfigParser': 'configparser', } Index: Lib/test/test_logging.py =================================================================== --- Lib/test/test_logging.py (revision 63574) +++ Lib/test/test_logging.py (working copy) @@ -33,7 +33,7 @@ import re import select import socket -from socketserver import ThreadingTCPServer, StreamRequestHandler +from SocketServer import ThreadingTCPServer, StreamRequestHandler import string import struct import sys Index: Lib/test/test_socketserver.py =================================================================== --- Lib/test/test_socketserver.py (revision 63574) +++ Lib/test/test_socketserver.py (working copy) @@ -1,5 +1,5 @@ """ -Test suite for socketserver. +Test suite for SocketServer.py. """ import contextlib @@ -13,7 +13,7 @@ import threading import time import unittest -import socketserver +import SocketServer import test.test_support from test.test_support import reap_children, verbose, TestSkipped @@ -40,12 +40,12 @@ raise RuntimeError, "timed out on %r" % (sock,) if HAVE_UNIX_SOCKETS: - class ForkingUnixStreamServer(socketserver.ForkingMixIn, - socketserver.UnixStreamServer): + class ForkingUnixStreamServer(SocketServer.ForkingMixIn, + SocketServer.UnixStreamServer): pass - class ForkingUnixDatagramServer(socketserver.ForkingMixIn, - socketserver.UnixDatagramServer): + class ForkingUnixDatagramServer(SocketServer.ForkingMixIn, + SocketServer.UnixDatagramServer): pass @@ -172,55 +172,55 @@ s.close() def test_TCPServer(self): - self.run_server(socketserver.TCPServer, - socketserver.StreamRequestHandler, + self.run_server(SocketServer.TCPServer, + SocketServer.StreamRequestHandler, self.stream_examine) def test_ThreadingTCPServer(self): - self.run_server(socketserver.ThreadingTCPServer, - socketserver.StreamRequestHandler, + self.run_server(SocketServer.ThreadingTCPServer, + SocketServer.StreamRequestHandler, self.stream_examine) if HAVE_FORKING: def test_ForkingTCPServer(self): with simple_subprocess(self): - self.run_server(socketserver.ForkingTCPServer, - socketserver.StreamRequestHandler, + self.run_server(SocketServer.ForkingTCPServer, + SocketServer.StreamRequestHandler, self.stream_examine) if HAVE_UNIX_SOCKETS: def test_UnixStreamServer(self): - self.run_server(socketserver.UnixStreamServer, - socketserver.StreamRequestHandler, + self.run_server(SocketServer.UnixStreamServer, + SocketServer.StreamRequestHandler, self.stream_examine) def test_ThreadingUnixStreamServer(self): - self.run_server(socketserver.ThreadingUnixStreamServer, - socketserver.StreamRequestHandler, + self.run_server(SocketServer.ThreadingUnixStreamServer, + SocketServer.StreamRequestHandler, self.stream_examine) if HAVE_FORKING: def test_ForkingUnixStreamServer(self): with simple_subprocess(self): self.run_server(ForkingUnixStreamServer, - socketserver.StreamRequestHandler, + SocketServer.StreamRequestHandler, self.stream_examine) def test_UDPServer(self): - self.run_server(socketserver.UDPServer, - socketserver.DatagramRequestHandler, + self.run_server(SocketServer.UDPServer, + SocketServer.DatagramRequestHandler, self.dgram_examine) def test_ThreadingUDPServer(self): - self.run_server(socketserver.ThreadingUDPServer, - socketserver.DatagramRequestHandler, + self.run_server(SocketServer.ThreadingUDPServer, + SocketServer.DatagramRequestHandler, self.dgram_examine) if HAVE_FORKING: def test_ForkingUDPServer(self): with simple_subprocess(self): - self.run_server(socketserver.ForkingUDPServer, - socketserver.DatagramRequestHandler, + self.run_server(SocketServer.ForkingUDPServer, + SocketServer.DatagramRequestHandler, self.dgram_examine) # Alas, on Linux (at least) recvfrom() doesn't return a meaningful @@ -228,19 +228,19 @@ # if HAVE_UNIX_SOCKETS: # def test_UnixDatagramServer(self): - # self.run_server(socketserver.UnixDatagramServer, - # socketserver.DatagramRequestHandler, + # self.run_server(SocketServer.UnixDatagramServer, + # SocketServer.DatagramRequestHandler, # self.dgram_examine) # # def test_ThreadingUnixDatagramServer(self): - # self.run_server(socketserver.ThreadingUnixDatagramServer, - # socketserver.DatagramRequestHandler, + # self.run_server(SocketServer.ThreadingUnixDatagramServer, + # SocketServer.DatagramRequestHandler, # self.dgram_examine) # # if HAVE_FORKING: # def test_ForkingUnixDatagramServer(self): - # self.run_server(socketserver.ForkingUnixDatagramServer, - # socketserver.DatagramRequestHandler, + # self.run_server(SocketServer.ForkingUnixDatagramServer, + # SocketServer.DatagramRequestHandler, # self.dgram_examine) Index: Lib/test/test_wsgiref.py =================================================================== --- Lib/test/test_wsgiref.py (revision 63574) +++ Lib/test/test_wsgiref.py (working copy) @@ -8,7 +8,7 @@ from wsgiref.simple_server import WSGIServer, WSGIRequestHandler, demo_app from wsgiref.simple_server import make_server from StringIO import StringIO -from socketserver import BaseServer +from SocketServer import BaseServer import re, sys from test import test_support Index: Lib/test/test___all__.py =================================================================== --- Lib/test/test___all__.py (revision 63574) +++ Lib/test/test___all__.py (working copy) @@ -40,9 +40,9 @@ self.check_all("configparser") self.check_all("Cookie") self.check_all("MimeWriter") - self.check_all("queue") + self.check_all("Queue") self.check_all("SimpleHTTPServer") - self.check_all("socketserver") + self.check_all("SocketServer") self.check_all("StringIO") self.check_all("UserString") self.check_all("aifc") Index: Lib/SimpleXMLRPCServer.py =================================================================== --- Lib/SimpleXMLRPCServer.py (revision 63574) +++ Lib/SimpleXMLRPCServer.py (working copy) @@ -101,7 +101,7 @@ import xmlrpclib from xmlrpclib import Fault -import socketserver +import SocketServer import BaseHTTPServer import sys import os @@ -512,7 +512,7 @@ if self.server.logRequests: BaseHTTPServer.BaseHTTPRequestHandler.log_request(self, code, size) -class SimpleXMLRPCServer(socketserver.TCPServer, +class SimpleXMLRPCServer(SocketServer.TCPServer, SimpleXMLRPCDispatcher): """Simple XML-RPC server. @@ -536,7 +536,7 @@ self.logRequests = logRequests SimpleXMLRPCDispatcher.__init__(self, allow_none, encoding) - socketserver.TCPServer.__init__(self, addr, requestHandler, bind_and_activate) + SocketServer.TCPServer.__init__(self, addr, requestHandler, bind_and_activate) # [Bug #1222790] If possible, set close-on-exec flag; if a # method spawns a subprocess, the subprocess shouldn't have