Commit 69f90452 authored by Benjamin Peterson's avatar Benjamin Peterson

Merged revisions 77167 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r77167 | benjamin.peterson | 2009-12-30 21:11:23 -0600 (Wed, 30 Dec 2009) | 61 lines

  Merged revisions 76847,76851,76869,76882,76891-76892,76924,77007,77070,77092,77096,77120,77126,77155 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r76847 | benjamin.peterson | 2009-12-14 21:25:27 -0600 (Mon, 14 Dec 2009) | 1 line

    adverb
  ........
    r76851 | benjamin.peterson | 2009-12-15 21:28:52 -0600 (Tue, 15 Dec 2009) | 1 line

    remove lib2to3 resource
  ........
    r76869 | vinay.sajip | 2009-12-17 08:52:00 -0600 (Thu, 17 Dec 2009) | 1 line

    Issue #7529: logging: Minor correction to documentation.
  ........
    r76882 | georg.brandl | 2009-12-19 11:30:28 -0600 (Sat, 19 Dec 2009) | 1 line

    #7527: use standard versionadded tags.
  ........
    r76891 | georg.brandl | 2009-12-19 12:16:31 -0600 (Sat, 19 Dec 2009) | 1 line

    #7479: add note about function availability on Unices.
  ........
    r76892 | georg.brandl | 2009-12-19 12:20:18 -0600 (Sat, 19 Dec 2009) | 1 line

    #7480: remove tautology.
  ........
    r76924 | georg.brandl | 2009-12-20 08:28:05 -0600 (Sun, 20 Dec 2009) | 1 line

    Small indentation fix.
  ........
    r77007 | gregory.p.smith | 2009-12-23 03:31:11 -0600 (Wed, 23 Dec 2009) | 3 lines

    Fix possible integer overflow in lchown and fchown functions.  For issue1747858.
  ........
    r77070 | amaury.forgeotdarc | 2009-12-27 14:06:44 -0600 (Sun, 27 Dec 2009) | 2 lines

    Fix a typo in comment
  ........
    r77092 | georg.brandl | 2009-12-28 02:48:24 -0600 (Mon, 28 Dec 2009) | 1 line

    #7404: remove reference to non-existing example files.
  ........
    r77096 | benjamin.peterson | 2009-12-28 14:51:17 -0600 (Mon, 28 Dec 2009) | 1 line

    document new fix_callable behavior
  ........
    r77120 | georg.brandl | 2009-12-29 15:09:17 -0600 (Tue, 29 Dec 2009) | 1 line

    #7595: fix typo in argument default constant.
  ........
    r77126 | amaury.forgeotdarc | 2009-12-29 17:06:17 -0600 (Tue, 29 Dec 2009) | 2 lines

    #7579: Add docstrings to the msvcrt module
  ........
    r77155 | georg.brandl | 2009-12-30 13:03:00 -0600 (Wed, 30 Dec 2009) | 1 line

    We only support Windows NT derivatives now.
  ........
................
parent f0b3d54c
...@@ -122,7 +122,8 @@ and off individually. They are described here in more detail. ...@@ -122,7 +122,8 @@ and off individually. They are described here in more detail.
.. 2to3fixer:: callable .. 2to3fixer:: callable
Converts ``callable(x)`` to ``hasattr(x, "__call_")``. Converts ``callable(x)`` to ``isinstance(x, collections.Callable)``, adding
an import to :mod:`collections` if needed.
.. 2to3fixer:: dict .. 2to3fixer:: dict
......
...@@ -1005,7 +1005,7 @@ Here is what we get on Windows:: ...@@ -1005,7 +1005,7 @@ Here is what we get on Windows::
>>> >>>
It is funny to see that on linux the sort function seems to work much more It is funny to see that on linux the sort function seems to work much more
efficient, it is doing less comparisons:: efficiently, it is doing less comparisons::
>>> qsort(ia, len(ia), sizeof(c_int), cmp_func) # doctest: +LINUX >>> qsort(ia, len(ia), sizeof(c_int), cmp_func) # doctest: +LINUX
py_cmp_func 5 1 py_cmp_func 5 1
......
...@@ -1611,6 +1611,8 @@ file-like object (or, more precisely, any object which supports :meth:`write` ...@@ -1611,6 +1611,8 @@ file-like object (or, more precisely, any object which supports :meth:`write`
and :meth:`flush` methods). and :meth:`flush` methods).
.. currentmodule:: logging
.. class:: StreamHandler(stream=None) .. class:: StreamHandler(stream=None)
Returns a new instance of the :class:`StreamHandler` class. If *stream* is Returns a new instance of the :class:`StreamHandler` class. If *stream* is
......
...@@ -144,6 +144,4 @@ Other Functions ...@@ -144,6 +144,4 @@ Other Functions
.. function:: heapmin() .. function:: heapmin()
Force the :cfunc:`malloc` heap to clean itself up and return unused blocks to Force the :cfunc:`malloc` heap to clean itself up and return unused blocks to
the operating system. This only works on Windows NT. On failure, this raises the operating system. On failure, this raises :exc:`IOError`.
:exc:`IOError`.
...@@ -153,9 +153,7 @@ required option ...@@ -153,9 +153,7 @@ required option
an option that must be supplied on the command-line; note that the phrase an option that must be supplied on the command-line; note that the phrase
"required option" is self-contradictory in English. :mod:`optparse` doesn't "required option" is self-contradictory in English. :mod:`optparse` doesn't
prevent you from implementing required options, but doesn't give you much prevent you from implementing required options, but doesn't give you much
help at it either. See ``examples/required_1.py`` and help at it either.
``examples/required_2.py`` in the :mod:`optparse` source distribution for two
ways to implement required options with :mod:`optparse`.
For example, consider this hypothetical command-line:: For example, consider this hypothetical command-line::
......
...@@ -13,18 +13,19 @@ module. For creating temporary files and directories see the :mod:`tempfile` ...@@ -13,18 +13,19 @@ module. For creating temporary files and directories see the :mod:`tempfile`
module, and for high-level file and directory handling see the :mod:`shutil` module, and for high-level file and directory handling see the :mod:`shutil`
module. module.
The design of all built-in operating system dependent modules of Python is such Notes on the availability of these functions:
that as long as the same functionality is available, it uses the same interface;
for example, the function ``os.stat(path)`` returns stat information about
*path* in the same format (which happens to have originated with the POSIX
interface).
Extensions peculiar to a particular operating system are also available through * The design of all built-in operating system dependent modules of Python is
the :mod:`os` module, but using them is of course a threat to portability! such that as long as the same functionality is available, it uses the same
interface; for example, the function ``os.stat(path)`` returns stat
information about *path* in the same format (which happens to have originated
with the POSIX interface).
.. note:: * Extensions peculiar to a particular operating system are also available
through the :mod:`os` module, but using them is of course a threat to
portability.
All functions accepting path or file names accept both bytes and string * All functions accepting path or file names accept both bytes and string
objects, and result in an object of the same type, if a path or file name is objects, and result in an object of the same type, if a path or file name is
returned. returned.
...@@ -33,6 +34,13 @@ the :mod:`os` module, but using them is of course a threat to portability! ...@@ -33,6 +34,13 @@ the :mod:`os` module, but using them is of course a threat to portability!
If not separately noted, all functions that claim "Availability: Unix" are If not separately noted, all functions that claim "Availability: Unix" are
supported on Mac OS X, which builds on a Unix core. supported on Mac OS X, which builds on a Unix core.
* An "Availability: Unix" note means that this function is commonly found on
Unix systems. It does not make any claims about its existence on a specific
operating system.
* If not separately noted, all functions that claim "Availability: Unix" are
supported on Mac OS X, which builds on a Unix core.
.. note:: .. note::
All functions in this module raise :exc:`OSError` in the case of invalid or All functions in this module raise :exc:`OSError` in the case of invalid or
...@@ -46,9 +54,9 @@ the :mod:`os` module, but using them is of course a threat to portability! ...@@ -46,9 +54,9 @@ the :mod:`os` module, but using them is of course a threat to portability!
.. data:: name .. data:: name
The name of the operating system dependent module imported. The following names The name of the operating system dependent module imported. The following
have currently been registered: ``'posix'``, ``'nt'``, ``'mac'``, ``'os2'``, names have currently been registered: ``'posix'``, ``'nt'``, ``'mac'``,
``'ce'``, ``'java'``. ``'os2'``, ``'ce'``, ``'java'``.
.. _os-filenames: .. _os-filenames:
......
...@@ -46,7 +46,7 @@ The module defines the following: ...@@ -46,7 +46,7 @@ The module defines the following:
:ref:`kqueue-objects` below for the methods supported by kqueue objects. :ref:`kqueue-objects` below for the methods supported by kqueue objects.
.. function:: kevent(ident, filter=KQ_FILTER_READ, flags=KQ_ADD, fflags=0, data=0, udata=0) .. function:: kevent(ident, filter=KQ_FILTER_READ, flags=KQ_EV_ADD, fflags=0, data=0, udata=0)
(Only supported on BSD.) Returns a kernel event object object; see section (Only supported on BSD.) Returns a kernel event object object; see section
:ref:`kevent-objects` below for the methods supported by kqueue objects. :ref:`kevent-objects` below for the methods supported by kqueue objects.
......
...@@ -2454,8 +2454,7 @@ types, where they are relevant. Some of these are not reported by the ...@@ -2454,8 +2454,7 @@ types, where they are relevant. Some of these are not reported by the
.. attribute:: class.__bases__ .. attribute:: class.__bases__
The tuple of base classes of a class object. If there are no base classes, this The tuple of base classes of a class object.
will be an empty tuple.
.. attribute:: class.__name__ .. attribute:: class.__name__
......
...@@ -86,6 +86,7 @@ substitutions and value formatting via the :func:`format` method described in ...@@ -86,6 +86,7 @@ substitutions and value formatting via the :func:`format` method described in
you to create and customize your own string formatting behaviors using the same you to create and customize your own string formatting behaviors using the same
implementation as the built-in :meth:`format` method. implementation as the built-in :meth:`format` method.
.. class:: Formatter .. class:: Formatter
The :class:`Formatter` class has the following public methods: The :class:`Formatter` class has the following public methods:
...@@ -470,6 +471,8 @@ The available presentation types for floating point and decimal values are: ...@@ -470,6 +471,8 @@ The available presentation types for floating point and decimal values are:
Template strings Template strings
---------------- ----------------
.. versionadded:: 2.4
Templates provide simpler string substitutions as described in :pep:`292`. Templates provide simpler string substitutions as described in :pep:`292`.
Instead of the normal ``%``\ -based substitutions, Templates support ``$``\ Instead of the normal ``%``\ -based substitutions, Templates support ``$``\
-based substitutions, using the following rules: -based substitutions, using the following rules:
......
...@@ -105,8 +105,6 @@ resources to test. Currently only the following are defined: ...@@ -105,8 +105,6 @@ resources to test. Currently only the following are defined:
curses - Tests that use curses and will modify the terminal's curses - Tests that use curses and will modify the terminal's
state and output modes. state and output modes.
lib2to3 - Run the tests for 2to3 (They take a while.)
largefile - It is okay to run some test that may create huge largefile - It is okay to run some test that may create huge
files. These tests can take a long time and may files. These tests can take a long time and may
consume >2GB of disk space temporarily. consume >2GB of disk space temporarily.
......
...@@ -131,14 +131,8 @@ class PosixTester(unittest.TestCase): ...@@ -131,14 +131,8 @@ class PosixTester(unittest.TestCase):
if hasattr(posix, 'stat'): if hasattr(posix, 'stat'):
self.assertTrue(posix.stat(support.TESTFN)) self.assertTrue(posix.stat(support.TESTFN))
if hasattr(posix, 'chown'): def _test_all_chown_common(self, chown_func, first_param):
def test_chown(self): """Common code for chown, fchown and lchown tests."""
# raise an OSError if the file does not exist
os.unlink(support.TESTFN)
self.assertRaises(OSError, posix.chown, support.TESTFN, -1, -1)
# re-create the file
open(support.TESTFN, 'w').close()
if os.getuid() == 0: if os.getuid() == 0:
try: try:
# Many linux distros have a nfsnobody user as MAX_UID-2 # Many linux distros have a nfsnobody user as MAX_UID-2
...@@ -147,16 +141,44 @@ class PosixTester(unittest.TestCase): ...@@ -147,16 +141,44 @@ class PosixTester(unittest.TestCase):
# This part of the test only runs when run as root. # This part of the test only runs when run as root.
# Only scary people run their tests as root. # Only scary people run their tests as root.
ent = pwd.getpwnam('nfsnobody') ent = pwd.getpwnam('nfsnobody')
posix.chown(support.TESTFN, ent.pw_uid, ent.pw_gid) chown_func(first_param, ent.pw_uid, ent.pw_gid)
except KeyError: except KeyError:
pass pass
else: else:
# non-root cannot chown to root, raises OSError # non-root cannot chown to root, raises OSError
self.assertRaises(OSError, posix.chown, self.assertRaises(OSError, chown_func,
support.TESTFN, 0, 0) first_param, 0, 0)
# test a successful chown call # test a successful chown call
posix.chown(support.TESTFN, os.getuid(), os.getgid()) chown_func(first_param, os.getuid(), os.getgid())
@unittest.skipUnless(hasattr(posix, 'chown'), "test needs os.chown()")
def test_chown(self):
# raise an OSError if the file does not exist
os.unlink(support.TESTFN)
self.assertRaises(OSError, posix.chown, support.TESTFN, -1, -1)
# re-create the file
open(support.TESTFN, 'w').close()
self._test_all_chown_common(posix.chown, support.TESTFN)
@unittest.skipUnless(hasattr(posix, 'fchown'), "test needs os.fchown()")
def test_fchown(self):
os.unlink(support.TESTFN)
# re-create the file
test_file = open(support.TESTFN, 'w')
try:
fd = test_file.fileno()
self._test_all_chown_common(posix.fchown, fd)
finally:
test_file.close()
@unittest.skipUnless(hasattr(posix, 'lchown'), "test needs os.lchown()")
def test_lchown(self):
os.unlink(support.TESTFN)
# create a symlink
os.symlink('/tmp/dummy-symlink-target', support.TESTFN)
self._test_all_chown_common(posix.lchown, support.TESTFN)
def test_chdir(self): def test_chdir(self):
if hasattr(posix, 'chdir'): if hasattr(posix, 'chdir'):
......
...@@ -927,7 +927,7 @@ collect(int generation) ...@@ -927,7 +927,7 @@ collect(int generation)
*/ */
(void)handle_finalizers(&finalizers, old); (void)handle_finalizers(&finalizers, old);
/* Clear free list only during the collection of the higest /* Clear free list only during the collection of the highest
* generation */ * generation */
if (generation == NUM_GENERATIONS-1) { if (generation == NUM_GENERATIONS-1) {
clear_freelists(); clear_freelists();
...@@ -948,7 +948,7 @@ collect_generations(void) ...@@ -948,7 +948,7 @@ collect_generations(void)
int i; int i;
Py_ssize_t n = 0; Py_ssize_t n = 0;
/* Find the oldest generation (higest numbered) where the count /* Find the oldest generation (highest numbered) where the count
* exceeds the threshold. Objects in the that generation and * exceeds the threshold. Objects in the that generation and
* generations younger than it will be collected. */ * generations younger than it will be collected. */
for (i = NUM_GENERATIONS-1; i >= 0; i--) { for (i = NUM_GENERATIONS-1; i >= 0; i--) {
......
...@@ -2088,9 +2088,10 @@ fd to the numeric uid and gid."); ...@@ -2088,9 +2088,10 @@ fd to the numeric uid and gid.");
static PyObject * static PyObject *
posix_fchown(PyObject *self, PyObject *args) posix_fchown(PyObject *self, PyObject *args)
{ {
int fd, uid, gid; int fd;
long uid, gid;
int res; int res;
if (!PyArg_ParseTuple(args, "iii:chown", &fd, &uid, &gid)) if (!PyArg_ParseTuple(args, "ill:chown", &fd, &uid, &gid))
return NULL; return NULL;
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
res = fchown(fd, (uid_t) uid, (gid_t) gid); res = fchown(fd, (uid_t) uid, (gid_t) gid);
...@@ -2112,9 +2113,9 @@ posix_lchown(PyObject *self, PyObject *args) ...@@ -2112,9 +2113,9 @@ posix_lchown(PyObject *self, PyObject *args)
{ {
PyObject *opath; PyObject *opath;
char *path; char *path;
int uid, gid; long uid, gid;
int res; int res;
if (!PyArg_ParseTuple(args, "O&ii:lchown", if (!PyArg_ParseTuple(args, "O&ll:lchown",
PyUnicode_FSConverter, &opath, PyUnicode_FSConverter, &opath,
&uid, &gid)) &uid, &gid))
return NULL; return NULL;
......
...@@ -1166,7 +1166,7 @@ static PyTypeObject pyEpoll_Type = { ...@@ -1166,7 +1166,7 @@ static PyTypeObject pyEpoll_Type = {
#endif #endif
PyDoc_STRVAR(kqueue_event_doc, PyDoc_STRVAR(kqueue_event_doc,
"kevent(ident, filter=KQ_FILTER_READ, flags=KQ_ADD, fflags=0, data=0, udata=0)\n\ "kevent(ident, filter=KQ_FILTER_READ, flags=KQ_EV_ADD, fflags=0, data=0, udata=0)\n\
\n\ \n\
This object is the equivalent of the struct kevent for the C API.\n\ This object is the equivalent of the struct kevent for the C API.\n\
\n\ \n\
......
...@@ -45,6 +45,12 @@ msvcrt_heapmin(PyObject *self, PyObject *args) ...@@ -45,6 +45,12 @@ msvcrt_heapmin(PyObject *self, PyObject *args)
return Py_None; return Py_None;
} }
PyDoc_STRVAR(heapmin_doc,
"heapmin() -> None\n\
\n\
Force the malloc() heap to clean itself up and return unused blocks\n\
to the operating system. On failure, this raises IOError.");
// Perform locking operations on a C runtime file descriptor. // Perform locking operations on a C runtime file descriptor.
static PyObject * static PyObject *
msvcrt_locking(PyObject *self, PyObject *args) msvcrt_locking(PyObject *self, PyObject *args)
...@@ -67,6 +73,17 @@ msvcrt_locking(PyObject *self, PyObject *args) ...@@ -67,6 +73,17 @@ msvcrt_locking(PyObject *self, PyObject *args)
return Py_None; return Py_None;
} }
PyDoc_STRVAR(locking_doc,
"locking(fd, mode, nbytes) -> None\n\
\n\
Lock part of a file based on file descriptor fd from the C runtime.\n\
Raises IOError on failure. The locked region of the file extends from\n\
the current file position for nbytes bytes, and may continue beyond\n\
the end of the file. mode must be one of the LK_* constants listed\n\
below. Multiple regions in a file may be locked at the same time, but\n\
may not overlap. Adjacent regions are not merged; they must be unlocked\n\
individually.");
// Set the file translation mode for a C runtime file descriptor. // Set the file translation mode for a C runtime file descriptor.
static PyObject * static PyObject *
msvcrt_setmode(PyObject *self, PyObject *args) msvcrt_setmode(PyObject *self, PyObject *args)
...@@ -83,6 +100,13 @@ msvcrt_setmode(PyObject *self, PyObject *args) ...@@ -83,6 +100,13 @@ msvcrt_setmode(PyObject *self, PyObject *args)
return PyLong_FromLong(flags); return PyLong_FromLong(flags);
} }
PyDoc_STRVAR(setmode_doc,
"setmode(fd, mode) -> Previous mode\n\
\n\
Set the line-end translation mode for the file descriptor fd. To set\n\
it to text mode, flags should be os.O_TEXT; for binary, it should be\n\
os.O_BINARY.");
// Convert an OS file handle to a C runtime file descriptor. // Convert an OS file handle to a C runtime file descriptor.
static PyObject * static PyObject *
msvcrt_open_osfhandle(PyObject *self, PyObject *args) msvcrt_open_osfhandle(PyObject *self, PyObject *args)
...@@ -101,6 +125,14 @@ msvcrt_open_osfhandle(PyObject *self, PyObject *args) ...@@ -101,6 +125,14 @@ msvcrt_open_osfhandle(PyObject *self, PyObject *args)
return PyLong_FromLong(fd); return PyLong_FromLong(fd);
} }
PyDoc_STRVAR(open_osfhandle_doc,
"open_osfhandle(handle, flags) -> file descriptor\n\
\n\
Create a C runtime file descriptor from the file handle handle. The\n\
flags parameter should be a bitwise OR of os.O_APPEND, os.O_RDONLY,\n\
and os.O_TEXT. The returned file descriptor may be used as a parameter\n\
to os.fdopen() to create a file object.");
// Convert a C runtime file descriptor to an OS file handle. // Convert a C runtime file descriptor to an OS file handle.
static PyObject * static PyObject *
msvcrt_get_osfhandle(PyObject *self, PyObject *args) msvcrt_get_osfhandle(PyObject *self, PyObject *args)
...@@ -121,6 +153,12 @@ msvcrt_get_osfhandle(PyObject *self, PyObject *args) ...@@ -121,6 +153,12 @@ msvcrt_get_osfhandle(PyObject *self, PyObject *args)
return PyLong_FromVoidPtr((void*)handle); return PyLong_FromVoidPtr((void*)handle);
} }
PyDoc_STRVAR(get_osfhandle_doc,
"get_osfhandle(fd) -> file handle\n\
\n\
Return the file handle for the file descriptor fd. Raises IOError\n\
if fd is not recognized.");
/* Console I/O */ /* Console I/O */
static PyObject * static PyObject *
...@@ -135,6 +173,11 @@ msvcrt_kbhit(PyObject *self, PyObject *args) ...@@ -135,6 +173,11 @@ msvcrt_kbhit(PyObject *self, PyObject *args)
return PyLong_FromLong(ok); return PyLong_FromLong(ok);
} }
PyDoc_STRVAR(kbhit_doc,
"kbhit() -> bool\n\
\n\
Return true if a keypress is waiting to be read.");
static PyObject * static PyObject *
msvcrt_getch(PyObject *self, PyObject *args) msvcrt_getch(PyObject *self, PyObject *args)
{ {
...@@ -151,6 +194,16 @@ msvcrt_getch(PyObject *self, PyObject *args) ...@@ -151,6 +194,16 @@ msvcrt_getch(PyObject *self, PyObject *args)
return PyBytes_FromStringAndSize(s, 1); return PyBytes_FromStringAndSize(s, 1);
} }
PyDoc_STRVAR(getch_doc,
"getch() -> key character\n\
\n\
Read a keypress and return the resulting character. Nothing is echoed to\n\
the console. This call will block if a keypress is not already\n\
available, but will not wait for Enter to be pressed. If the pressed key\n\
was a special function key, this will return '\\000' or '\\xe0'; the next\n\
call will return the keycode. The Control-C keypress cannot be read with\n\
this function.");
#ifdef _WCONIO_DEFINED #ifdef _WCONIO_DEFINED
static PyObject * static PyObject *
msvcrt_getwch(PyObject *self, PyObject *args) msvcrt_getwch(PyObject *self, PyObject *args)
...@@ -167,6 +220,11 @@ msvcrt_getwch(PyObject *self, PyObject *args) ...@@ -167,6 +220,11 @@ msvcrt_getwch(PyObject *self, PyObject *args)
u[0] = ch; u[0] = ch;
return PyUnicode_FromUnicode(u, 1); return PyUnicode_FromUnicode(u, 1);
} }
PyDoc_STRVAR(getwch_doc,
"getwch() -> Unicode key character\n\
\n\
Wide char variant of getch(), returning a Unicode value.");
#endif #endif
static PyObject * static PyObject *
...@@ -185,6 +243,12 @@ msvcrt_getche(PyObject *self, PyObject *args) ...@@ -185,6 +243,12 @@ msvcrt_getche(PyObject *self, PyObject *args)
return PyBytes_FromStringAndSize(s, 1); return PyBytes_FromStringAndSize(s, 1);
} }
PyDoc_STRVAR(getche_doc,
"getche() -> key character\n\
\n\
Similar to getch(), but the keypress will be echoed if it represents\n\
a printable character.");
#ifdef _WCONIO_DEFINED #ifdef _WCONIO_DEFINED
static PyObject * static PyObject *
msvcrt_getwche(PyObject *self, PyObject *args) msvcrt_getwche(PyObject *self, PyObject *args)
...@@ -201,6 +265,11 @@ msvcrt_getwche(PyObject *self, PyObject *args) ...@@ -201,6 +265,11 @@ msvcrt_getwche(PyObject *self, PyObject *args)
s[0] = ch; s[0] = ch;
return PyUnicode_FromUnicode(s, 1); return PyUnicode_FromUnicode(s, 1);
} }
PyDoc_STRVAR(getwche_doc,
"getwche() -> Unicode key character\n\
\n\
Wide char variant of getche(), returning a Unicode value.");
#endif #endif
static PyObject * static PyObject *
...@@ -216,6 +285,11 @@ msvcrt_putch(PyObject *self, PyObject *args) ...@@ -216,6 +285,11 @@ msvcrt_putch(PyObject *self, PyObject *args)
return Py_None; return Py_None;
} }
PyDoc_STRVAR(putch_doc,
"putch(char) -> None\n\
\n\
Print the character char to the console without buffering.");
#ifdef _WCONIO_DEFINED #ifdef _WCONIO_DEFINED
static PyObject * static PyObject *
msvcrt_putwch(PyObject *self, PyObject *args) msvcrt_putwch(PyObject *self, PyObject *args)
...@@ -229,6 +303,11 @@ msvcrt_putwch(PyObject *self, PyObject *args) ...@@ -229,6 +303,11 @@ msvcrt_putwch(PyObject *self, PyObject *args)
Py_RETURN_NONE; Py_RETURN_NONE;
} }
PyDoc_STRVAR(putwch_doc,
"putwch(unicode_char) -> None\n\
\n\
Wide char variant of putch(), accepting a Unicode value.");
#endif #endif
static PyObject * static PyObject *
...@@ -245,6 +324,12 @@ msvcrt_ungetch(PyObject *self, PyObject *args) ...@@ -245,6 +324,12 @@ msvcrt_ungetch(PyObject *self, PyObject *args)
return Py_None; return Py_None;
} }
PyDoc_STRVAR(ungetch_doc,
"ungetch(char) -> None\n\
\n\
Cause the character char to be \"pushed back\" into the console buffer;\n\
it will be the next character read by getch() or getche().");
#ifdef _WCONIO_DEFINED #ifdef _WCONIO_DEFINED
static PyObject * static PyObject *
msvcrt_ungetwch(PyObject *self, PyObject *args) msvcrt_ungetwch(PyObject *self, PyObject *args)
...@@ -259,6 +344,11 @@ msvcrt_ungetwch(PyObject *self, PyObject *args) ...@@ -259,6 +344,11 @@ msvcrt_ungetwch(PyObject *self, PyObject *args)
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
} }
PyDoc_STRVAR(ungetwch_doc,
"ungetwch(unicode_char) -> None\n\
\n\
Wide char variant of ungetch(), accepting a Unicode value.");
#endif #endif
static void static void
...@@ -332,16 +422,16 @@ seterrormode(PyObject *self, PyObject *args) ...@@ -332,16 +422,16 @@ seterrormode(PyObject *self, PyObject *args)
/* List of functions exported by this module */ /* List of functions exported by this module */
static struct PyMethodDef msvcrt_functions[] = { static struct PyMethodDef msvcrt_functions[] = {
{"heapmin", msvcrt_heapmin, METH_VARARGS}, {"heapmin", msvcrt_heapmin, METH_VARARGS, heapmin_doc},
{"locking", msvcrt_locking, METH_VARARGS}, {"locking", msvcrt_locking, METH_VARARGS, locking_doc},
{"setmode", msvcrt_setmode, METH_VARARGS}, {"setmode", msvcrt_setmode, METH_VARARGS, setmode_doc},
{"open_osfhandle", msvcrt_open_osfhandle, METH_VARARGS}, {"open_osfhandle", msvcrt_open_osfhandle, METH_VARARGS, open_osfhandle_doc},
{"get_osfhandle", msvcrt_get_osfhandle, METH_VARARGS}, {"get_osfhandle", msvcrt_get_osfhandle, METH_VARARGS, get_osfhandle_doc},
{"kbhit", msvcrt_kbhit, METH_VARARGS}, {"kbhit", msvcrt_kbhit, METH_VARARGS, kbhit_doc},
{"getch", msvcrt_getch, METH_VARARGS}, {"getch", msvcrt_getch, METH_VARARGS, getch_doc},
{"getche", msvcrt_getche, METH_VARARGS}, {"getche", msvcrt_getche, METH_VARARGS, getche_doc},
{"putch", msvcrt_putch, METH_VARARGS}, {"putch", msvcrt_putch, METH_VARARGS, putch_doc},
{"ungetch", msvcrt_ungetch, METH_VARARGS}, {"ungetch", msvcrt_ungetch, METH_VARARGS, ungetch_doc},
{"SetErrorMode", seterrormode, METH_VARARGS}, {"SetErrorMode", seterrormode, METH_VARARGS},
#ifdef _DEBUG #ifdef _DEBUG
{"CrtSetReportFile", msvcrt_setreportfile, METH_VARARGS}, {"CrtSetReportFile", msvcrt_setreportfile, METH_VARARGS},
...@@ -349,10 +439,10 @@ static struct PyMethodDef msvcrt_functions[] = { ...@@ -349,10 +439,10 @@ static struct PyMethodDef msvcrt_functions[] = {
{"set_error_mode", msvcrt_seterrormode, METH_VARARGS}, {"set_error_mode", msvcrt_seterrormode, METH_VARARGS},
#endif #endif
#ifdef _WCONIO_DEFINED #ifdef _WCONIO_DEFINED
{"getwch", msvcrt_getwch, METH_VARARGS}, {"getwch", msvcrt_getwch, METH_VARARGS, getwch_doc},
{"getwche", msvcrt_getwche, METH_VARARGS}, {"getwche", msvcrt_getwche, METH_VARARGS, getwche_doc},
{"putwch", msvcrt_putwch, METH_VARARGS}, {"putwch", msvcrt_putwch, METH_VARARGS, putwch_doc},
{"ungetwch", msvcrt_ungetwch, METH_VARARGS}, {"ungetwch", msvcrt_ungetwch, METH_VARARGS, ungetwch_doc},
#endif #endif
{NULL, NULL} {NULL, NULL}
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment