summaryrefslogtreecommitdiffstats
path: root/PC
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2008-01-09 00:17:24 (GMT)
committerChristian Heimes <christian@cheimes.de>2008-01-09 00:17:24 (GMT)
commit2380ac740ecedca7990d7461590e86636a364bad (patch)
tree3485b9f8d7e71a964b6bdb060a10456a14cb57c1 /PC
parent790c8232019d0a13c3f0a72b8cffcf3ae69ea7b9 (diff)
downloadcpython-2380ac740ecedca7990d7461590e86636a364bad.zip
cpython-2380ac740ecedca7990d7461590e86636a364bad.tar.gz
cpython-2380ac740ecedca7990d7461590e86636a364bad.tar.bz2
Merged revisions 59843-59863 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r59844 | raymond.hettinger | 2008-01-07 21:56:05 +0100 (Mon, 07 Jan 2008) | 1 line Use get() instead of pop() for the optimized version of _replace(). ........ r59847 | raymond.hettinger | 2008-01-07 22:33:51 +0100 (Mon, 07 Jan 2008) | 1 line Documentation nits. ........ r59849 | raymond.hettinger | 2008-01-08 03:02:05 +0100 (Tue, 08 Jan 2008) | 1 line Expand comment. ........ r59850 | raymond.hettinger | 2008-01-08 03:24:15 +0100 (Tue, 08 Jan 2008) | 1 line Docs on named tuple's naming conventions and limits of subclassing ........ r59851 | christian.heimes | 2008-01-08 04:40:04 +0100 (Tue, 08 Jan 2008) | 1 line It's verbose, not debug ........ r59852 | facundo.batista | 2008-01-08 13:25:20 +0100 (Tue, 08 Jan 2008) | 4 lines Issue #1757: The hash of a Decimal instance is no longer affected by the current context. Thanks Mark Dickinson. ........ r59853 | andrew.kuchling | 2008-01-08 15:30:55 +0100 (Tue, 08 Jan 2008) | 1 line Patch 1137: allow assigning to .buffer_size attribute of PyExpat.parser objects ........ r59854 | andrew.kuchling | 2008-01-08 15:56:02 +0100 (Tue, 08 Jan 2008) | 1 line Patch 1114: fix compilation of curses module on 64-bit AIX, and any other LP64 platforms where attr_t isn't a C long ........ r59856 | thomas.heller | 2008-01-08 16:15:09 +0100 (Tue, 08 Jan 2008) | 5 lines Use relative instead of absolute filenames in the C-level tracebacks. This prevents traceback prints pointing to files in this way: File "\loewis\25\python\Modules\_ctypes\callbacks.c", line 206, in 'calling callback function' ........ r59857 | christian.heimes | 2008-01-08 16:46:10 +0100 (Tue, 08 Jan 2008) | 2 lines Added __enter__ and __exit__ functions to HKEY object Added ExpandEnvironmentStrings to the _winreg module. ........ r59858 | georg.brandl | 2008-01-08 17:18:26 +0100 (Tue, 08 Jan 2008) | 2 lines Fix markup errors from r59857 and clarify key.__enter__/__exit__ docs ........ r59860 | georg.brandl | 2008-01-08 20:42:30 +0100 (Tue, 08 Jan 2008) | 2 lines Better method for associating .py files with the interpreter. ........ r59862 | facundo.batista | 2008-01-08 22:10:12 +0100 (Tue, 08 Jan 2008) | 9 lines Issue 846388. Adds a call to PyErr_CheckSignals to SRE_MATCH so that signal handlers can be invoked during long regular expression matches. It also adds a new error return value indicating that an exception occurred in a signal handler during the match, allowing exceptions in the signal handler to propagate up to the main loop. Thanks Josh Hoyt and Ralf Schmitt. ........
Diffstat (limited to 'PC')
-rw-r--r--PC/_winreg.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/PC/_winreg.c b/PC/_winreg.c
index 2fdc5b5..0dcade8 100644
--- a/PC/_winreg.c
+++ b/PC/_winreg.c
@@ -46,6 +46,7 @@ PyDoc_STRVAR(module_doc,
"DeleteValue() - Removes a named value from the specified registry key.\n"
"EnumKey() - Enumerates subkeys of the specified open registry key.\n"
"EnumValue() - Enumerates values of the specified open registry key.\n"
+"ExpandEnvironmentStrings() - Expand the env strings in a REG_EXPAND_SZ string.\n"
"FlushKey() - Writes all the attributes of the specified key to the registry.\n"
"LoadKey() - Creates a subkey under HKEY_USER or HKEY_LOCAL_MACHINE and stores\n"
" registration information from a specified file into that subkey.\n"
@@ -145,6 +146,9 @@ PyDoc_STRVAR(EnumValue_doc,
" on the underlying registry type.\n"
"data_type is an integer that identifies the type of the value data.");
+PyDoc_STRVAR(ExpandEnvironmentStrings_doc,
+"string = ExpandEnvironmentStrings(string) - Expand environment vars.\n");
+
PyDoc_STRVAR(FlushKey_doc,
"FlushKey(key) - Writes all the attributes of a key to the registry.\n"
"\n"
@@ -503,9 +507,27 @@ PyHKEY_DetachMethod(PyObject *self, PyObject *args)
return PyLong_FromVoidPtr(ret);
}
+static PyObject *
+PyHKEY_Enter(PyObject *self)
+{
+ Py_XINCREF(self);
+ return self;
+}
+
+static PyObject *
+PyHKEY_Exit(PyObject *self, PyObject *args)
+{
+ if (!PyHKEY_Close(self))
+ return NULL;
+ Py_RETURN_NONE;
+}
+
+
static struct PyMethodDef PyHKEY_methods[] = {
{"Close", PyHKEY_CloseMethod, METH_VARARGS, PyHKEY_Close_doc},
{"Detach", PyHKEY_DetachMethod, METH_VARARGS, PyHKEY_Detach_doc},
+ {"__enter__", (PyCFunction)PyHKEY_Enter, METH_NOARGS, NULL},
+ {"__exit__", PyHKEY_Exit, METH_VARARGS, NULL},
{NULL}
};
@@ -1062,6 +1084,39 @@ PyEnumValue(PyObject *self, PyObject *args)
}
static PyObject *
+PyExpandEnvironmentStrings(PyObject *self, PyObject *args)
+{
+ Py_UNICODE *retValue = NULL;
+ Py_UNICODE *src;
+ DWORD retValueSize;
+ DWORD rc;
+ PyObject *o;
+
+ if (!PyArg_ParseTuple(args, "u:ExpandEnvironmentStrings", &src))
+ return NULL;
+
+ retValueSize = ExpandEnvironmentStringsW(src, retValue, 0);
+ if (retValueSize == 0) {
+ return PyErr_SetFromWindowsErrWithFunction(retValueSize,
+ "ExpandEnvironmentStrings");
+ }
+ retValue = (Py_UNICODE *)PyMem_Malloc(retValueSize * sizeof(Py_UNICODE));
+ if (retValue == NULL) {
+ return PyErr_NoMemory();
+ }
+
+ rc = ExpandEnvironmentStringsW(src, retValue, retValueSize);
+ if (rc == 0) {
+ PyMem_Free(retValue);
+ return PyErr_SetFromWindowsErrWithFunction(retValueSize,
+ "ExpandEnvironmentStrings");
+ }
+ o = PyUnicode_FromUnicode(retValue, wcslen(retValue));
+ PyMem_Free(retValue);
+ return o;
+}
+
+static PyObject *
PyFlushKey(PyObject *self, PyObject *args)
{
HKEY hKey;
@@ -1346,6 +1401,8 @@ static struct PyMethodDef winreg_methods[] = {
{"DeleteValue", PyDeleteValue, METH_VARARGS, DeleteValue_doc},
{"EnumKey", PyEnumKey, METH_VARARGS, EnumKey_doc},
{"EnumValue", PyEnumValue, METH_VARARGS, EnumValue_doc},
+ {"ExpandEnvironmentStrings", PyExpandEnvironmentStrings, METH_VARARGS,
+ ExpandEnvironmentStrings_doc },
{"FlushKey", PyFlushKey, METH_VARARGS, FlushKey_doc},
{"LoadKey", PyLoadKey, METH_VARARGS, LoadKey_doc},
{"OpenKey", PyOpenKey, METH_VARARGS, OpenKey_doc},