[Python-3000-checkins] r59450 - in python/branches/py3k: Doc/library/msvcrt.rst Lib/DocXMLRPCServer.py Lib/test/test_docxmlrpc.py Misc/ACKS PC/msvcrtmodule.c
christian.heimes
python-3000-checkins at python.org
Mon Dec 10 17:18:49 CET 2007
Author: christian.heimes
Date: Mon Dec 10 17:18:49 2007
New Revision: 59450
Added:
python/branches/py3k/Lib/test/test_docxmlrpc.py
- copied unchanged from r59448, python/trunk/Lib/test/test_docxmlrpc.py
Modified:
python/branches/py3k/ (props changed)
python/branches/py3k/Doc/library/msvcrt.rst
python/branches/py3k/Lib/DocXMLRPCServer.py
python/branches/py3k/Misc/ACKS
python/branches/py3k/PC/msvcrtmodule.c
Log:
Merged revisions 59441-59449 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59442 | georg.brandl | 2007-12-09 22:15:07 +0100 (Sun, 09 Dec 2007) | 5 lines
Two fixes in DocXMLRPCServer:
* remove parameter default that didn't make sense
* properly escape values in output
Thanks to Jeff Wheeler from GHOP!
........
r59444 | georg.brandl | 2007-12-09 23:38:26 +0100 (Sun, 09 Dec 2007) | 2 lines
Add Jeff Wheeler.
........
r59445 | georg.brandl | 2007-12-09 23:39:12 +0100 (Sun, 09 Dec 2007) | 2 lines
Add DocXMLRPCServer test from GHOP task #136, written by Jeff Wheeler.
........
r59447 | christian.heimes | 2007-12-10 16:12:41 +0100 (Mon, 10 Dec 2007) | 1 line
Added wide char api variants of getch and putch to msvcrt module. The wide char methods are required to fix #1578 in py3k. I figured out that they might be useful in 2.6, too.
........
r59448 | christian.heimes | 2007-12-10 16:39:09 +0100 (Mon, 10 Dec 2007) | 1 line
Stupid save all didn't safe it all ...
........
Modified: python/branches/py3k/Doc/library/msvcrt.rst
==============================================================================
--- python/branches/py3k/Doc/library/msvcrt.rst (original)
+++ python/branches/py3k/Doc/library/msvcrt.rst Mon Dec 10 17:18:49 2007
@@ -16,6 +16,10 @@
Further documentation on these functions can be found in the Platform API
documentation.
+The module implements both the normal and wide char variants of the console I/O
+api. The normal API deals only with ASCII characters and is of limited use
+for internationalized applications. The wide char API should be used where
+ever possible
.. _msvcrt-files:
@@ -94,6 +98,13 @@
return the keycode. The :kbd:`Control-C` keypress cannot be read with this
function.
+
+.. function:: getwch()
+
+ Wide char variant of `func:getch`, returns unicode.
+
+ ..versionadded:: 2.6
+
.. function:: getche()
@@ -101,16 +112,37 @@
printable character.
+.. function:: getwche()
+
+ Wide char variant of `func:getche`, returns unicode.
+
+ ..versionadded:: 2.6
+
+
.. function:: putch(char)
Print the character *char* to the console without buffering.
+
+.. function:: putwch(unicode_char)
+
+ Wide char variant of `func:putch`, accepts unicode.
+
+ ..versionadded:: 2.6
+
.. function:: ungetch(char)
Cause the character *char* to be "pushed back" into the console buffer; it will
be the next character read by :func:`getch` or :func:`getche`.
+
+.. function:: ungetwch(unicode_char)
+
+ Wide char variant of `func:ungetch`, accepts unicode.
+
+ ..versionadded:: 2.6
+
.. _msvcrt-other:
Modified: python/branches/py3k/Lib/DocXMLRPCServer.py
==============================================================================
--- python/branches/py3k/Lib/DocXMLRPCServer.py (original)
+++ python/branches/py3k/Lib/DocXMLRPCServer.py Mon Dec 10 17:18:49 2007
@@ -64,14 +64,15 @@
results.append(escape(text[here:]))
return ''.join(results)
- def docroutine(self, object, name=None, mod=None,
+ def docroutine(self, object, name, mod=None,
funcs={}, classes={}, methods={}, cl=None):
"""Produce HTML documentation for a function or method object."""
anchor = (cl and cl.__name__ or '') + '-' + name
note = ''
- title = '<a name="%s"><strong>%s</strong></a>' % (anchor, name)
+ title = '<a name="%s"><strong>%s</strong></a>' % (
+ self.escape(anchor), self.escape(name))
if inspect.ismethod(object):
args, varargs, varkw, defaults = inspect.getargspec(object)
@@ -113,6 +114,7 @@
fdict[key] = '#-' + key
fdict[value] = fdict[key]
+ server_name = self.escape(server_name)
head = '<big><big><strong>%s</strong></big></big>' % server_name
result = self.heading(head, '#ffffff', '#7799ee')
@@ -280,29 +282,3 @@
def __init__(self):
CGIXMLRPCRequestHandler.__init__(self)
XMLRPCDocGenerator.__init__(self)
-
-if __name__ == '__main__':
- def deg_to_rad(deg):
- """deg_to_rad(90) => 1.5707963267948966
-
- Converts an angle in degrees to an angle in radians"""
- import math
- return deg * math.pi / 180
-
- server = DocXMLRPCServer(("localhost", 8000))
-
- server.set_server_title("Math Server")
- server.set_server_name("Math XML-RPC Server")
- server.set_server_documentation("""This server supports various mathematical functions.
-
-You can use it from Python as follows:
-
->>> from xmlrpclib import ServerProxy
->>> s = ServerProxy("http://localhost:8000")
->>> s.deg_to_rad(90.0)
-1.5707963267948966""")
-
- server.register_function(deg_to_rad)
- server.register_introspection_functions()
-
- server.serve_forever()
Modified: python/branches/py3k/Misc/ACKS
==============================================================================
--- python/branches/py3k/Misc/ACKS (original)
+++ python/branches/py3k/Misc/ACKS Mon Dec 10 17:18:49 2007
@@ -699,6 +699,7 @@
Edward Welbourne
Cliff Wells
Rickard Westman
+Jeff Wheeler
Mats Wichmann
Truida Wiedijk
Felix Wiemann
Modified: python/branches/py3k/PC/msvcrtmodule.c
==============================================================================
--- python/branches/py3k/PC/msvcrtmodule.c (original)
+++ python/branches/py3k/PC/msvcrtmodule.c Mon Dec 10 17:18:49 2007
@@ -146,6 +146,22 @@
}
static PyObject *
+msvcrt_getwch(PyObject *self, PyObject *args)
+{
+ Py_UNICODE ch;
+ Py_UNICODE u[1];
+
+ if (!PyArg_ParseTuple(args, ":getwch"))
+ return NULL;
+
+ Py_BEGIN_ALLOW_THREADS
+ ch = _getwch();
+ Py_END_ALLOW_THREADS
+ u[0] = ch;
+ return PyUnicode_FromUnicode(u, 1);
+}
+
+static PyObject *
msvcrt_getche(PyObject *self, PyObject *args)
{
int ch;
@@ -162,6 +178,22 @@
}
static PyObject *
+msvcrt_getwche(PyObject *self, PyObject *args)
+{
+ Py_UNICODE ch;
+ Py_UNICODE s[1];
+
+ if (!PyArg_ParseTuple(args, ":getwche"))
+ return NULL;
+
+ Py_BEGIN_ALLOW_THREADS
+ ch = _getwche();
+ Py_END_ALLOW_THREADS
+ s[0] = ch;
+ return PyUnicode_FromUnicode(s, 1);
+}
+
+static PyObject *
msvcrt_putch(PyObject *self, PyObject *args)
{
char ch;
@@ -174,6 +206,26 @@
return Py_None;
}
+
+static PyObject *
+msvcrt_putwch(PyObject *self, PyObject *args)
+{
+ Py_UNICODE *ch;
+ int size;
+
+ if (!PyArg_ParseTuple(args, "u#:putwch", &ch, &size))
+ return NULL;
+
+ if (size == 0) {
+ PyErr_SetString(PyExc_ValueError,
+ "Expected unicode string of length 1");
+ return NULL;
+ }
+ _putwch(*ch);
+ Py_RETURN_NONE;
+
+}
+
static PyObject *
msvcrt_ungetch(PyObject *self, PyObject *args)
{
@@ -188,6 +240,19 @@
return Py_None;
}
+static PyObject *
+msvcrt_ungetwch(PyObject *self, PyObject *args)
+{
+ Py_UNICODE ch;
+
+ if (!PyArg_ParseTuple(args, "u:ungetwch", &ch))
+ return NULL;
+
+ if (_ungetch(ch) == EOF)
+ return PyErr_SetFromErrno(PyExc_IOError);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
static void
insertint(PyObject *d, char *name, int value)
@@ -276,6 +341,10 @@
{"CrtSetReportMode", msvcrt_setreportmode, METH_VARARGS},
{"set_error_mode", msvcrt_seterrormode, METH_VARARGS},
#endif
+ {"getwch", msvcrt_getwch, METH_VARARGS},
+ {"getwche", msvcrt_getwche, METH_VARARGS},
+ {"putwch", msvcrt_putwch, METH_VARARGS},
+ {"ungetwch", msvcrt_ungetwch, METH_VARARGS},
{NULL, NULL}
};
More information about the Python-3000-checkins
mailing list