2000-03-28 16:37:15 -04:00
|
|
|
/*
|
2008-05-25 04:45:51 -03:00
|
|
|
winreg.c
|
2000-03-28 16:37:15 -04:00
|
|
|
|
|
|
|
Windows Registry access module for Python.
|
|
|
|
|
|
|
|
* Simple registry access written by Mark Hammond in win32api
|
2010-05-09 12:52:27 -03:00
|
|
|
module circa 1995.
|
2000-03-28 16:37:15 -04:00
|
|
|
* Bill Tutt expanded the support significantly not long after.
|
|
|
|
* Numerous other people have submitted patches since then.
|
|
|
|
* Ripped from win32api module 03-Feb-2000 by Mark Hammond, and
|
|
|
|
basic Unicode support added.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Python.h"
|
|
|
|
#include "structmember.h"
|
Merged revisions 55631-55794 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk
................
r55636 | neal.norwitz | 2007-05-29 00:06:39 -0700 (Tue, 29 May 2007) | 149 lines
Merged revisions 55506-55635 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r55507 | georg.brandl | 2007-05-22 07:28:17 -0700 (Tue, 22 May 2007) | 2 lines
Remove the "panel" module doc file which has been ignored since 1994.
........
r55522 | mark.hammond | 2007-05-22 19:04:28 -0700 (Tue, 22 May 2007) | 4 lines
Remove definition of PY_UNICODE_TYPE from pyconfig.h, allowing the
definition in unicodeobject.h to be used, giving us the desired
wchar_t in place of 'unsigned short'. As discussed on python-dev.
........
r55525 | neal.norwitz | 2007-05-22 23:35:32 -0700 (Tue, 22 May 2007) | 6 lines
Add -3 option to the interpreter to warn about features that are
deprecated and will be changed/removed in Python 3.0.
This patch is mostly from Anthony. I tweaked some format and added
a little doc.
........
r55527 | neal.norwitz | 2007-05-22 23:57:35 -0700 (Tue, 22 May 2007) | 1 line
Whitespace cleanup
........
r55528 | neal.norwitz | 2007-05-22 23:58:36 -0700 (Tue, 22 May 2007) | 1 line
Add a bunch more deprecation warnings for builtins that are going away in 3.0
........
r55549 | georg.brandl | 2007-05-24 09:49:29 -0700 (Thu, 24 May 2007) | 2 lines
shlex.split() now has an optional "posix" parameter.
........
r55550 | georg.brandl | 2007-05-24 10:33:33 -0700 (Thu, 24 May 2007) | 2 lines
Fix parameter passing.
........
r55555 | facundo.batista | 2007-05-24 10:50:54 -0700 (Thu, 24 May 2007) | 6 lines
Added an optional timeout parameter to urllib.ftpwrapper, with tests
(for this and a basic one, because there weren't any). Changed also
NEWS, but didn't find documentation for this function, assumed it
wasn't public...
........
r55563 | facundo.batista | 2007-05-24 13:01:59 -0700 (Thu, 24 May 2007) | 4 lines
Removed the .recv() in the test, is not necessary, and was
causing problems that didn't have anything to do with was
actually being tested...
........
r55564 | facundo.batista | 2007-05-24 13:51:19 -0700 (Thu, 24 May 2007) | 5 lines
Let's see if reading exactly what is written allow this live
test to pass (now I know why there were so few tests in ftp,
http, etc, :( ).
........
r55567 | facundo.batista | 2007-05-24 20:10:28 -0700 (Thu, 24 May 2007) | 4 lines
Trying to make the tests work in Windows and Solaris, everywhere
else just works
........
r55568 | facundo.batista | 2007-05-24 20:47:19 -0700 (Thu, 24 May 2007) | 4 lines
Fixing stupid error, and introducing a sleep, to see if the
other thread is awakened and finish sending data.
........
r55569 | facundo.batista | 2007-05-24 21:20:22 -0700 (Thu, 24 May 2007) | 4 lines
Commenting out the tests until find out who can test them in
one of the problematic enviroments.
........
r55570 | neal.norwitz | 2007-05-24 22:13:40 -0700 (Thu, 24 May 2007) | 2 lines
Get test passing again by commenting out the reference to the test class.
........
r55575 | vinay.sajip | 2007-05-25 00:05:59 -0700 (Fri, 25 May 2007) | 1 line
Updated docstring for SysLogHandler (#1720726).
........
r55576 | vinay.sajip | 2007-05-25 00:06:55 -0700 (Fri, 25 May 2007) | 1 line
Updated documentation for SysLogHandler (#1720726).
........
r55592 | brett.cannon | 2007-05-25 13:17:15 -0700 (Fri, 25 May 2007) | 3 lines
Remove direct call's to file's constructor and replace them with calls to
open() as ths is considered best practice.
........
r55601 | kristjan.jonsson | 2007-05-26 12:19:50 -0700 (Sat, 26 May 2007) | 1 line
Remove the rgbimgmodule from PCBuild8
........
r55602 | kristjan.jonsson | 2007-05-26 12:31:39 -0700 (Sat, 26 May 2007) | 1 line
Include <windows.h> after python.h, so that WINNT is properly set before windows.h is included. Fixes warnings in PC builds.
........
r55603 | walter.doerwald | 2007-05-26 14:04:13 -0700 (Sat, 26 May 2007) | 2 lines
Fix typo.
........
r55604 | peter.astrand | 2007-05-26 15:18:20 -0700 (Sat, 26 May 2007) | 1 line
Applied patch 1669481, slightly modified: Support close_fds on Win32
........
r55606 | neal.norwitz | 2007-05-26 21:08:54 -0700 (Sat, 26 May 2007) | 2 lines
Add the new function object attribute names from py3k.
........
r55617 | lars.gustaebel | 2007-05-27 12:49:30 -0700 (Sun, 27 May 2007) | 20 lines
Added errors argument to TarFile class that allows the user to
specify an error handling scheme for character conversion. Additional
scheme "utf-8" in read mode. Unicode input filenames are now
supported by design. The values of the pax_headers dictionary are now
limited to unicode objects.
Fixed: The prefix field is no longer used in PAX_FORMAT (in
conformance with POSIX).
Fixed: In read mode use a possible pax header size field.
Fixed: Strip trailing slashes from pax header name values.
Fixed: Give values in user-specified pax_headers precedence when
writing.
Added unicode tests. Added pax/regtype4 member to testtar.tar all
possible number fields in a pax header.
Added two chapters to the documentation about the different formats
tarfile.py supports and how unicode issues are handled.
........
r55618 | raymond.hettinger | 2007-05-27 22:23:22 -0700 (Sun, 27 May 2007) | 1 line
Explain when groupby() issues a new group.
........
r55634 | martin.v.loewis | 2007-05-28 21:01:29 -0700 (Mon, 28 May 2007) | 2 lines
Test pre-commit hook for a link to a .py file.
........
r55635 | martin.v.loewis | 2007-05-28 21:02:03 -0700 (Mon, 28 May 2007) | 2 lines
Revert 55634.
........
................
r55639 | neal.norwitz | 2007-05-29 00:58:11 -0700 (Tue, 29 May 2007) | 1 line
Remove sys.exc_{type,exc_value,exc_traceback}
................
r55641 | neal.norwitz | 2007-05-29 01:03:50 -0700 (Tue, 29 May 2007) | 1 line
Missed one sys.exc_type. I wonder why exc_{value,traceback} were already gone
................
r55642 | neal.norwitz | 2007-05-29 01:08:33 -0700 (Tue, 29 May 2007) | 1 line
Missed more doc for sys.exc_* attrs.
................
r55643 | neal.norwitz | 2007-05-29 01:18:19 -0700 (Tue, 29 May 2007) | 1 line
Remove sys.exc_clear()
................
r55665 | guido.van.rossum | 2007-05-29 19:45:43 -0700 (Tue, 29 May 2007) | 4 lines
Make None, True, False keywords.
We can now also delete all the other places that explicitly forbid
assignment to None, but I'm not going to bother right now.
................
r55666 | guido.van.rossum | 2007-05-29 20:01:51 -0700 (Tue, 29 May 2007) | 3 lines
Found another place that needs check for forbidden names.
Fixed test_syntax.py accordingly (it helped me find that one).
................
r55668 | guido.van.rossum | 2007-05-29 20:41:48 -0700 (Tue, 29 May 2007) | 2 lines
Mark None, True, False as keywords.
................
r55673 | neal.norwitz | 2007-05-29 23:28:25 -0700 (Tue, 29 May 2007) | 3 lines
Get the dis module working on modules again after changing dicts
to not return lists and also new-style classes. Add a test.
................
r55674 | neal.norwitz | 2007-05-29 23:35:45 -0700 (Tue, 29 May 2007) | 1 line
Umm, it helps to add the module that the test uses
................
r55675 | neal.norwitz | 2007-05-29 23:53:05 -0700 (Tue, 29 May 2007) | 4 lines
Try to fix up all the other places that were assigning to True/False.
There's at least one more problem in test.test_xmlrpc. I have other
changes in that file and that should be fixed soon (I hope).
................
r55679 | neal.norwitz | 2007-05-30 00:31:55 -0700 (Wed, 30 May 2007) | 1 line
Fix up another place that was assigning to True/False.
................
r55688 | brett.cannon | 2007-05-30 14:19:47 -0700 (Wed, 30 May 2007) | 2 lines
Ditch MimeWriter.
................
r55692 | brett.cannon | 2007-05-30 14:52:00 -0700 (Wed, 30 May 2007) | 2 lines
Remove the mimify module.
................
r55707 | guido.van.rossum | 2007-05-31 05:08:45 -0700 (Thu, 31 May 2007) | 2 lines
Backport the addition of show_code() to dis.py -- it's too handy.
................
r55708 | guido.van.rossum | 2007-05-31 06:22:57 -0700 (Thu, 31 May 2007) | 7 lines
Fix a fairly long-standing bug in the check for assignment to None (and other
keywords, these days). In 2.5, you could write foo(None=1) without getting
a SyntaxError (although foo()'s definition would have to use **kwds to avoid
getting a runtime error complaining about an unknown keyword of course).
This ought to be backported to 2.5.2 or at least 2.6.
................
r55724 | brett.cannon | 2007-05-31 19:32:41 -0700 (Thu, 31 May 2007) | 2 lines
Remove the cfmfile.
................
r55727 | neal.norwitz | 2007-05-31 22:19:44 -0700 (Thu, 31 May 2007) | 1 line
Remove reload() builtin.
................
r55729 | neal.norwitz | 2007-05-31 22:51:30 -0700 (Thu, 31 May 2007) | 59 lines
Merged revisions 55636-55728 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r55637 | georg.brandl | 2007-05-29 00:16:47 -0700 (Tue, 29 May 2007) | 2 lines
Fix rst markup.
........
r55638 | neal.norwitz | 2007-05-29 00:51:39 -0700 (Tue, 29 May 2007) | 1 line
Fix typo in doc
........
r55671 | neal.norwitz | 2007-05-29 21:53:41 -0700 (Tue, 29 May 2007) | 1 line
Fix indentation (whitespace only).
........
r55676 | thomas.heller | 2007-05-29 23:58:30 -0700 (Tue, 29 May 2007) | 1 line
Fix compiler warnings.
........
r55677 | thomas.heller | 2007-05-30 00:01:25 -0700 (Wed, 30 May 2007) | 2 lines
Correct the name of a field in the WIN32_FIND_DATAA and WIN32_FIND_DATAW structures.
Closes bug #1726026.
........
r55686 | brett.cannon | 2007-05-30 13:46:26 -0700 (Wed, 30 May 2007) | 2 lines
Have MimeWriter raise a DeprecationWarning as per PEP 4 and its documentation.
........
r55690 | brett.cannon | 2007-05-30 14:48:58 -0700 (Wed, 30 May 2007) | 3 lines
Have mimify raise a DeprecationWarning. The docs and PEP 4 have listed the
module as deprecated for a while.
........
r55696 | brett.cannon | 2007-05-30 15:24:28 -0700 (Wed, 30 May 2007) | 2 lines
Have md5 raise a DeprecationWarning as per PEP 4.
........
r55705 | neal.norwitz | 2007-05-30 21:14:22 -0700 (Wed, 30 May 2007) | 1 line
Add some spaces in the example code.
........
r55716 | brett.cannon | 2007-05-31 12:20:00 -0700 (Thu, 31 May 2007) | 2 lines
Have the sha module raise a DeprecationWarning as specified in PEP 4.
........
r55719 | brett.cannon | 2007-05-31 12:40:42 -0700 (Thu, 31 May 2007) | 2 lines
Cause buildtools to raise a DeprecationWarning.
........
r55721 | brett.cannon | 2007-05-31 13:01:11 -0700 (Thu, 31 May 2007) | 2 lines
Have cfmfile raise a DeprecationWarning as per PEP 4.
........
r55726 | neal.norwitz | 2007-05-31 21:56:47 -0700 (Thu, 31 May 2007) | 1 line
Mail if there is an installation failure.
........
................
r55730 | neal.norwitz | 2007-05-31 23:22:07 -0700 (Thu, 31 May 2007) | 2 lines
Remove the code that was missed in rev 55303.
................
r55738 | neal.norwitz | 2007-06-01 19:10:43 -0700 (Fri, 01 Jun 2007) | 1 line
Fix doc breakage
................
r55741 | neal.norwitz | 2007-06-02 00:41:58 -0700 (Sat, 02 Jun 2007) | 1 line
Remove timing module (plus some remnants of other modules).
................
r55742 | neal.norwitz | 2007-06-02 00:51:44 -0700 (Sat, 02 Jun 2007) | 1 line
Remove posixfile module (plus some remnants of other modules).
................
r55744 | neal.norwitz | 2007-06-02 10:18:56 -0700 (Sat, 02 Jun 2007) | 1 line
Fix doc breakage.
................
r55745 | neal.norwitz | 2007-06-02 11:32:16 -0700 (Sat, 02 Jun 2007) | 1 line
Make a whatsnew 3.0 template.
................
r55754 | neal.norwitz | 2007-06-03 23:24:18 -0700 (Sun, 03 Jun 2007) | 1 line
SF #1730441, os._execvpe raises UnboundLocal due to new try/except semantics
................
r55755 | neal.norwitz | 2007-06-03 23:26:00 -0700 (Sun, 03 Jun 2007) | 1 line
Get rid of extra whitespace
................
r55794 | guido.van.rossum | 2007-06-06 15:29:22 -0700 (Wed, 06 Jun 2007) | 3 lines
Make this compile in GCC 2.96, which does not allow interspersing
declarations and code.
................
2007-06-06 20:52:48 -03:00
|
|
|
#include "windows.h"
|
2000-03-28 16:37:15 -04:00
|
|
|
|
|
|
|
static BOOL PyHKEY_AsHKEY(PyObject *ob, HKEY *pRes, BOOL bNoneOK);
|
|
|
|
static PyObject *PyHKEY_FromHKEY(HKEY h);
|
|
|
|
static BOOL PyHKEY_Close(PyObject *obHandle);
|
|
|
|
|
|
|
|
static char errNotAHandle[] = "Object is not a handle";
|
|
|
|
|
|
|
|
/* The win32api module reports the function name that failed,
|
|
|
|
but this concept is not in the Python core.
|
|
|
|
Hopefully it will one day, and in the meantime I dont
|
|
|
|
want to lose this info...
|
|
|
|
*/
|
|
|
|
#define PyErr_SetFromWindowsErrWithFunction(rc, fnname) \
|
2010-05-09 12:52:27 -03:00
|
|
|
PyErr_SetFromWindowsErr(rc)
|
2000-03-28 16:37:15 -04:00
|
|
|
|
|
|
|
/* Forward declares */
|
|
|
|
|
|
|
|
/* Doc strings */
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(module_doc,
|
2000-03-28 16:37:15 -04:00
|
|
|
"This module provides access to the Windows registry API.\n"
|
|
|
|
"\n"
|
|
|
|
"Functions:\n"
|
|
|
|
"\n"
|
|
|
|
"CloseKey() - Closes a registry key.\n"
|
|
|
|
"ConnectRegistry() - Establishes a connection to a predefined registry handle\n"
|
|
|
|
" on another computer.\n"
|
|
|
|
"CreateKey() - Creates the specified key, or opens it if it already exists.\n"
|
|
|
|
"DeleteKey() - Deletes the specified key.\n"
|
|
|
|
"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"
|
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.
........
2008-01-08 20:17:24 -04:00
|
|
|
"ExpandEnvironmentStrings() - Expand the env strings in a REG_EXPAND_SZ string.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"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"
|
2012-10-29 20:16:39 -03:00
|
|
|
"OpenKey() - Opens the specified key.\n"
|
|
|
|
"OpenKeyEx() - Alias of OpenKey().\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"QueryValue() - Retrieves the value associated with the unnamed value for a\n"
|
|
|
|
" specified key in the registry.\n"
|
|
|
|
"QueryValueEx() - Retrieves the type and data for a specified value name\n"
|
|
|
|
" associated with an open registry key.\n"
|
|
|
|
"QueryInfoKey() - Returns information about the specified key.\n"
|
|
|
|
"SaveKey() - Saves the specified key, and all its subkeys a file.\n"
|
|
|
|
"SetValue() - Associates a value with a specified key.\n"
|
|
|
|
"SetValueEx() - Stores data in the value field of an open registry key.\n"
|
|
|
|
"\n"
|
|
|
|
"Special objects:\n"
|
|
|
|
"\n"
|
|
|
|
"HKEYType -- type object for HKEY objects\n"
|
|
|
|
"error -- exception raised for Win32 errors\n"
|
|
|
|
"\n"
|
|
|
|
"Integer constants:\n"
|
|
|
|
"Many constants are defined - see the documentation for each function\n"
|
2002-06-13 17:33:02 -03:00
|
|
|
"to see what constants are used, and where.");
|
2000-03-28 16:37:15 -04:00
|
|
|
|
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(CloseKey_doc,
|
2012-10-29 20:16:39 -03:00
|
|
|
"CloseKey(hkey)\n"
|
|
|
|
"Closes a previously opened registry key.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"\n"
|
|
|
|
"The hkey argument specifies a previously opened key.\n"
|
|
|
|
"\n"
|
|
|
|
"Note that if the key is not closed using this method, it will be\n"
|
2002-06-13 17:33:02 -03:00
|
|
|
"closed when the hkey object is destroyed by Python.");
|
2000-03-28 16:37:15 -04:00
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(ConnectRegistry_doc,
|
2012-10-29 20:16:39 -03:00
|
|
|
"ConnectRegistry(computer_name, key) -> key\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"Establishes a connection to a predefined registry handle on another computer.\n"
|
|
|
|
"\n"
|
|
|
|
"computer_name is the name of the remote computer, of the form \\\\computername.\n"
|
2012-10-29 20:16:39 -03:00
|
|
|
" If None, the local computer is used.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"key is the predefined handle to connect to.\n"
|
|
|
|
"\n"
|
|
|
|
"The return value is the handle of the opened key.\n"
|
2012-10-31 14:29:33 -03:00
|
|
|
"If the function fails, an OSError exception is raised.");
|
2000-03-28 16:37:15 -04:00
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(CreateKey_doc,
|
2012-10-29 20:16:39 -03:00
|
|
|
"CreateKey(key, sub_key) -> key\n"
|
|
|
|
"Creates or opens the specified key.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"\n"
|
2012-10-29 20:16:39 -03:00
|
|
|
"key is an already open key, or one of the predefined HKEY_* constants.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"sub_key is a string that names the key this method opens or creates.\n"
|
|
|
|
"\n"
|
2012-10-29 20:16:39 -03:00
|
|
|
"If key is one of the predefined keys, sub_key may be None. In that case,\n"
|
|
|
|
"the handle returned is the same key handle passed in to the function.\n"
|
|
|
|
"\n"
|
|
|
|
"If the key already exists, this function opens the existing key.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"\n"
|
|
|
|
"The return value is the handle of the opened key.\n"
|
2012-10-31 14:29:33 -03:00
|
|
|
"If the function fails, an OSError exception is raised.");
|
2000-03-28 16:37:15 -04:00
|
|
|
|
2010-04-21 20:56:21 -03:00
|
|
|
PyDoc_STRVAR(CreateKeyEx_doc,
|
2012-10-29 20:16:39 -03:00
|
|
|
"CreateKeyEx(key, sub_key, reserved=0, access=KEY_WRITE) -> key\n"
|
|
|
|
"Creates or opens the specified key.\n"
|
2010-04-21 20:56:21 -03:00
|
|
|
"\n"
|
|
|
|
"key is an already open key, or one of the predefined HKEY_* constants\n"
|
|
|
|
"sub_key is a string that names the key this method opens or creates.\n"
|
2012-10-29 20:16:39 -03:00
|
|
|
"reserved is a reserved integer, and must be zero. Default is zero.\n"
|
|
|
|
"access is an integer that specifies an access mask that describes the \n"
|
|
|
|
" desired security access for the key. Default is KEY_WRITE.\n"
|
|
|
|
"\n"
|
|
|
|
"If key is one of the predefined keys, sub_key may be None. In that case,\n"
|
|
|
|
"the handle returned is the same key handle passed in to the function.\n"
|
2010-04-21 20:56:21 -03:00
|
|
|
"\n"
|
|
|
|
"If the key already exists, this function opens the existing key\n"
|
|
|
|
"\n"
|
|
|
|
"The return value is the handle of the opened key.\n"
|
2012-10-31 14:29:33 -03:00
|
|
|
"If the function fails, an OSError exception is raised.");
|
2010-04-21 20:56:21 -03:00
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(DeleteKey_doc,
|
2012-10-29 20:16:39 -03:00
|
|
|
"DeleteKey(key, sub_key)\n"
|
|
|
|
"Deletes the specified key.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"\n"
|
|
|
|
"key is an already open key, or any one of the predefined HKEY_* constants.\n"
|
2012-10-29 20:16:39 -03:00
|
|
|
"sub_key is a string that must be a subkey of the key identified by the key\n"
|
|
|
|
" parameter. This value must not be None, and the key may not have\n"
|
|
|
|
" subkeys.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"\n"
|
|
|
|
"This method can not delete keys with subkeys.\n"
|
|
|
|
"\n"
|
2012-10-29 20:16:39 -03:00
|
|
|
"If the function succeeds, the entire key, including all of its values,\n"
|
2012-10-31 14:29:33 -03:00
|
|
|
"is removed. If the function fails, an OSError exception is raised.");
|
2010-04-21 20:56:21 -03:00
|
|
|
|
|
|
|
PyDoc_STRVAR(DeleteKeyEx_doc,
|
2012-10-29 20:16:39 -03:00
|
|
|
"DeleteKeyEx(key, sub_key, access=KEY_WOW64_64KEY, reserved=0)\n"
|
|
|
|
"Deletes the specified key (64-bit OS only).\n"
|
2010-04-21 20:56:21 -03:00
|
|
|
"\n"
|
|
|
|
"key is an already open key, or any one of the predefined HKEY_* constants.\n"
|
2012-10-29 20:16:39 -03:00
|
|
|
"sub_key is a string that must be a subkey of the key identified by the key\n"
|
|
|
|
" parameter. This value must not be None, and the key may not have\n"
|
|
|
|
" subkeys.\n"
|
|
|
|
"reserved is a reserved integer, and must be zero. Default is zero.\n"
|
|
|
|
"access is an integer that specifies an access mask that describes the \n"
|
|
|
|
" desired security access for the key. Default is KEY_WOW64_64KEY.\n"
|
2010-04-21 20:56:21 -03:00
|
|
|
"\n"
|
|
|
|
"This method can not delete keys with subkeys.\n"
|
|
|
|
"\n"
|
2012-10-29 20:16:39 -03:00
|
|
|
"If the function succeeds, the entire key, including all of its values,\n"
|
2012-10-31 14:29:33 -03:00
|
|
|
"is removed. If the function fails, an OSError exception is raised.\n"
|
2010-04-21 20:56:21 -03:00
|
|
|
"On unsupported Windows versions, NotImplementedError is raised.");
|
2000-03-28 16:37:15 -04:00
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(DeleteValue_doc,
|
2012-10-29 20:16:39 -03:00
|
|
|
"DeleteValue(key, value)\n"
|
|
|
|
"Removes a named value from a registry key.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"\n"
|
|
|
|
"key is an already open key, or any one of the predefined HKEY_* constants.\n"
|
2002-06-13 17:33:02 -03:00
|
|
|
"value is a string that identifies the value to remove.");
|
2000-03-28 16:37:15 -04:00
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(EnumKey_doc,
|
2012-10-29 20:16:39 -03:00
|
|
|
"EnumKey(key, index) -> string\n"
|
|
|
|
"Enumerates subkeys of an open registry key.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"\n"
|
|
|
|
"key is an already open key, or any one of the predefined HKEY_* constants.\n"
|
|
|
|
"index is an integer that identifies the index of the key to retrieve.\n"
|
|
|
|
"\n"
|
|
|
|
"The function retrieves the name of one subkey each time it is called.\n"
|
2012-10-31 14:29:33 -03:00
|
|
|
"It is typically called repeatedly until an OSError exception is\n"
|
2002-06-13 17:33:02 -03:00
|
|
|
"raised, indicating no more values are available.");
|
2000-03-28 16:37:15 -04:00
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(EnumValue_doc,
|
2012-10-29 20:16:39 -03:00
|
|
|
"EnumValue(key, index) -> tuple\n"
|
|
|
|
"Enumerates values of an open registry key.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"key is an already open key, or any one of the predefined HKEY_* constants.\n"
|
|
|
|
"index is an integer that identifies the index of the value to retrieve.\n"
|
|
|
|
"\n"
|
|
|
|
"The function retrieves the name of one subkey each time it is called.\n"
|
2012-10-31 14:29:33 -03:00
|
|
|
"It is typically called repeatedly, until an OSError exception\n"
|
2000-06-09 03:01:47 -03:00
|
|
|
"is raised, indicating no more values.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"\n"
|
|
|
|
"The result is a tuple of 3 items:\n"
|
|
|
|
"value_name is a string that identifies the value.\n"
|
|
|
|
"value_data is an object that holds the value data, and whose type depends\n"
|
2012-10-29 20:16:39 -03:00
|
|
|
" on the underlying registry type.\n"
|
2002-06-13 17:33:02 -03:00
|
|
|
"data_type is an integer that identifies the type of the value data.");
|
2000-03-28 16:37:15 -04:00
|
|
|
|
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.
........
2008-01-08 20:17:24 -04:00
|
|
|
PyDoc_STRVAR(ExpandEnvironmentStrings_doc,
|
2012-10-29 20:16:39 -03:00
|
|
|
"ExpandEnvironmentStrings(string) -> string\n"
|
|
|
|
"Expand environment vars.\n");
|
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.
........
2008-01-08 20:17:24 -04:00
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(FlushKey_doc,
|
2012-10-29 20:16:39 -03:00
|
|
|
"FlushKey(key)\n"
|
|
|
|
"Writes all the attributes of a key to the registry.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"\n"
|
|
|
|
"key is an already open key, or any one of the predefined HKEY_* constants.\n"
|
|
|
|
"\n"
|
2012-10-29 20:16:39 -03:00
|
|
|
"It is not necessary to call FlushKey to change a key. Registry changes are\n"
|
|
|
|
"flushed to disk by the registry using its lazy flusher. Registry changes are\n"
|
|
|
|
"also flushed to disk at system shutdown. Unlike CloseKey(), the FlushKey()\n"
|
|
|
|
"method returns only when all the data has been written to the registry.\n"
|
|
|
|
"\n"
|
|
|
|
"An application should only call FlushKey() if it requires absolute certainty\n"
|
|
|
|
"that registry changes are on disk. If you don't know whether a FlushKey()\n"
|
|
|
|
"call is required, it probably isn't.");
|
2000-03-28 16:37:15 -04:00
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(LoadKey_doc,
|
2012-10-29 20:16:39 -03:00
|
|
|
"LoadKey(key, sub_key, file_name)\n"
|
|
|
|
"Creates a subkey under the specified key and stores registration information\n"
|
|
|
|
"from a specified file into that subkey.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"\n"
|
|
|
|
"key is an already open key, or any one of the predefined HKEY_* constants.\n"
|
2012-10-29 20:16:39 -03:00
|
|
|
"sub_key is a string that identifies the sub_key to load.\n"
|
|
|
|
"file_name is the name of the file to load registry data from. This file must\n"
|
|
|
|
" have been created with the SaveKey() function. Under the file\n"
|
|
|
|
" allocation table (FAT) file system, the filename may not have an\n"
|
|
|
|
" extension.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"\n"
|
|
|
|
"A call to LoadKey() fails if the calling process does not have the\n"
|
|
|
|
"SE_RESTORE_PRIVILEGE privilege.\n"
|
|
|
|
"\n"
|
|
|
|
"If key is a handle returned by ConnectRegistry(), then the path specified\n"
|
|
|
|
"in fileName is relative to the remote computer.\n"
|
|
|
|
"\n"
|
2002-06-13 17:33:02 -03:00
|
|
|
"The docs imply key must be in the HKEY_USER or HKEY_LOCAL_MACHINE tree");
|
2000-03-28 16:37:15 -04:00
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(OpenKey_doc,
|
2012-10-29 20:16:39 -03:00
|
|
|
"OpenKey(key, sub_key, reserved=0, access=KEY_READ) -> key\n"
|
|
|
|
"Opens the specified key.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"\n"
|
|
|
|
"key is an already open key, or any one of the predefined HKEY_* constants.\n"
|
2012-10-29 20:16:39 -03:00
|
|
|
"sub_key is a string that identifies the sub_key to open.\n"
|
|
|
|
"reserved is a reserved integer, and must be zero. Default is zero.\n"
|
|
|
|
"access is an integer that specifies an access mask that describes the desired\n"
|
|
|
|
" security access for the key. Default is KEY_READ\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"\n"
|
|
|
|
"The result is a new handle to the specified key\n"
|
2012-10-31 14:29:33 -03:00
|
|
|
"If the function fails, an OSError exception is raised.");
|
2000-03-28 16:37:15 -04:00
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(OpenKeyEx_doc, "See OpenKey()");
|
2000-03-28 16:37:15 -04:00
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(QueryInfoKey_doc,
|
2012-10-29 20:16:39 -03:00
|
|
|
"QueryInfoKey(key) -> tuple\n"
|
|
|
|
"Returns information about a key.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"\n"
|
|
|
|
"key is an already open key, or any one of the predefined HKEY_* constants.\n"
|
|
|
|
"\n"
|
|
|
|
"The result is a tuple of 3 items:"
|
|
|
|
"An integer that identifies the number of sub keys this key has.\n"
|
|
|
|
"An integer that identifies the number of values this key has.\n"
|
|
|
|
"A long integer that identifies when the key was last modified (if available)\n"
|
2002-06-13 17:33:02 -03:00
|
|
|
" as 100's of nanoseconds since Jan 1, 1600.");
|
2000-03-28 16:37:15 -04:00
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(QueryValue_doc,
|
2012-10-29 20:16:39 -03:00
|
|
|
"QueryValue(key, sub_key) -> string\n"
|
|
|
|
"Retrieves the unnamed value for a key.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"\n"
|
|
|
|
"key is an already open key, or any one of the predefined HKEY_* constants.\n"
|
2000-06-09 03:01:47 -03:00
|
|
|
"sub_key is a string that holds the name of the subkey with which the value\n"
|
2012-10-29 20:16:39 -03:00
|
|
|
" is associated. If this parameter is None or empty, the function\n"
|
|
|
|
" retrieves the value set by the SetValue() method for the key\n"
|
|
|
|
" identified by key."
|
2000-03-28 16:37:15 -04:00
|
|
|
"\n"
|
|
|
|
"Values in the registry have name, type, and data components. This method\n"
|
|
|
|
"retrieves the data for a key's first value that has a NULL name.\n"
|
2002-06-13 17:33:02 -03:00
|
|
|
"But the underlying API call doesn't return the type, Lame Lame Lame, DONT USE THIS!!!");
|
2000-03-28 16:37:15 -04:00
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(QueryValueEx_doc,
|
2012-10-29 20:16:39 -03:00
|
|
|
"QueryValueEx(key, value_name) -> (value, type_id)\n"
|
|
|
|
"Retrieves the type and data for a specified value name associated with an\n"
|
|
|
|
"open registry key.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"\n"
|
|
|
|
"key is an already open key, or any one of the predefined HKEY_* constants.\n"
|
2002-06-13 17:33:02 -03:00
|
|
|
"value_name is a string indicating the value to query");
|
2000-03-28 16:37:15 -04:00
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(SaveKey_doc,
|
2012-10-29 20:16:39 -03:00
|
|
|
"SaveKey(key, file_name)\n"
|
|
|
|
"Saves the specified key, and all its subkeys to the specified file.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"\n"
|
|
|
|
"key is an already open key, or any one of the predefined HKEY_* constants.\n"
|
2012-10-29 20:16:39 -03:00
|
|
|
"file_name is the name of the file to save registry data to. This file cannot\n"
|
|
|
|
" already exist. If this filename includes an extension, it cannot be\n"
|
|
|
|
" used on file allocation table (FAT) file systems by the LoadKey(),\n"
|
|
|
|
" ReplaceKey() or RestoreKey() methods.\n"
|
|
|
|
"\n"
|
|
|
|
"If key represents a key on a remote computer, the path described by file_name\n"
|
|
|
|
"is relative to the remote computer.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"\n"
|
2012-10-29 20:16:39 -03:00
|
|
|
"The caller of this method must possess the SeBackupPrivilege security\n"
|
|
|
|
"privilege. This function passes NULL for security_attributes to the API.");
|
2000-03-28 16:37:15 -04:00
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(SetValue_doc,
|
2012-10-29 20:16:39 -03:00
|
|
|
"SetValue(key, sub_key, type, value)\n"
|
|
|
|
"Associates a value with a specified key.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"\n"
|
|
|
|
"key is an already open key, or any one of the predefined HKEY_* constants.\n"
|
|
|
|
"sub_key is a string that names the subkey with which the value is associated.\n"
|
2012-10-29 20:16:39 -03:00
|
|
|
"type is an integer that specifies the type of the data. Currently this must\n"
|
|
|
|
" be REG_SZ, meaning only strings are supported.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"value is a string that specifies the new value.\n"
|
|
|
|
"\n"
|
|
|
|
"If the key specified by the sub_key parameter does not exist, the SetValue\n"
|
|
|
|
"function creates it.\n"
|
|
|
|
"\n"
|
|
|
|
"Value lengths are limited by available memory. Long values (more than\n"
|
|
|
|
"2048 bytes) should be stored as files with the filenames stored in \n"
|
|
|
|
"the configuration registry. This helps the registry perform efficiently.\n"
|
|
|
|
"\n"
|
|
|
|
"The key identified by the key parameter must have been opened with\n"
|
2002-06-13 17:33:02 -03:00
|
|
|
"KEY_SET_VALUE access.");
|
2000-03-28 16:37:15 -04:00
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(SetValueEx_doc,
|
2012-10-29 20:16:39 -03:00
|
|
|
"SetValueEx(key, value_name, reserved, type, value)\n"
|
|
|
|
"Stores data in the value field of an open registry key.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"\n"
|
|
|
|
"key is an already open key, or any one of the predefined HKEY_* constants.\n"
|
2012-10-29 20:16:39 -03:00
|
|
|
"value_name is a string containing the name of the value to set, or None.\n"
|
|
|
|
"reserved can be anything - zero is always passed to the API.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"type is an integer that specifies the type of the data. This should be one of:\n"
|
|
|
|
" REG_BINARY -- Binary data in any form.\n"
|
|
|
|
" REG_DWORD -- A 32-bit number.\n"
|
|
|
|
" REG_DWORD_LITTLE_ENDIAN -- A 32-bit number in little-endian format.\n"
|
|
|
|
" REG_DWORD_BIG_ENDIAN -- A 32-bit number in big-endian format.\n"
|
|
|
|
" REG_EXPAND_SZ -- A null-terminated string that contains unexpanded references\n"
|
|
|
|
" to environment variables (for example, %PATH%).\n"
|
|
|
|
" REG_LINK -- A Unicode symbolic link.\n"
|
2000-06-09 03:01:47 -03:00
|
|
|
" REG_MULTI_SZ -- An sequence of null-terminated strings, terminated by\n"
|
|
|
|
" two null characters. Note that Python handles this\n"
|
|
|
|
" termination automatically.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
" REG_NONE -- No defined value type.\n"
|
|
|
|
" REG_RESOURCE_LIST -- A device-driver resource list.\n"
|
|
|
|
" REG_SZ -- A null-terminated string.\n"
|
|
|
|
"value is a string that specifies the new value.\n"
|
|
|
|
"\n"
|
|
|
|
"This method can also set additional value and type information for the\n"
|
|
|
|
"specified key. The key identified by the key parameter must have been\n"
|
|
|
|
"opened with KEY_SET_VALUE access.\n"
|
|
|
|
"\n"
|
|
|
|
"To open the key, use the CreateKeyEx() or OpenKeyEx() methods.\n"
|
|
|
|
"\n"
|
|
|
|
"Value lengths are limited by available memory. Long values (more than\n"
|
|
|
|
"2048 bytes) should be stored as files with the filenames stored in \n"
|
2002-06-13 17:33:02 -03:00
|
|
|
"the configuration registry. This helps the registry perform efficiently.");
|
2000-03-28 16:37:15 -04:00
|
|
|
|
2008-04-07 00:17:54 -03:00
|
|
|
PyDoc_STRVAR(DisableReflectionKey_doc,
|
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r62194 | jeffrey.yasskin | 2008-04-07 01:04:28 +0200 (Mon, 07 Apr 2008) | 7 lines
Add enough debugging information to diagnose failures where the
HandlerBException is ignored, and fix one such problem, where it was thrown
during the __del__ method of the previous Popen object.
We may want to find a better way of printing verbose information so it's not
spammy when the test passes.
........
r62197 | mark.hammond | 2008-04-07 03:53:39 +0200 (Mon, 07 Apr 2008) | 2 lines
Issue #2513: enable 64bit cross compilation on windows.
........
r62198 | mark.hammond | 2008-04-07 03:59:40 +0200 (Mon, 07 Apr 2008) | 2 lines
correct heading underline for new "Cross-compiling on Windows" section
........
r62204 | gregory.p.smith | 2008-04-07 08:33:21 +0200 (Mon, 07 Apr 2008) | 4 lines
Use the new PyFile_IncUseCount & PyFile_DecUseCount calls appropriatly
within the standard library. These modules use PyFile_AsFile and later
release the GIL while operating on the previously returned FILE*.
........
r62205 | mark.summerfield | 2008-04-07 09:39:23 +0200 (Mon, 07 Apr 2008) | 4 lines
changed "2500 components" to "several thousand" since the number keeps
growning:-)
........
r62214 | georg.brandl | 2008-04-07 20:51:59 +0200 (Mon, 07 Apr 2008) | 2 lines
#2525: update timezone info examples in the docs.
........
r62219 | andrew.kuchling | 2008-04-08 01:57:07 +0200 (Tue, 08 Apr 2008) | 1 line
Write PEP 3127 section; add items
........
r62220 | andrew.kuchling | 2008-04-08 01:57:21 +0200 (Tue, 08 Apr 2008) | 1 line
Typo fix
........
r62221 | andrew.kuchling | 2008-04-08 03:33:10 +0200 (Tue, 08 Apr 2008) | 1 line
Typographical fix: 32bit -> 32-bit, 64bit -> 64-bit
........
r62227 | andrew.kuchling | 2008-04-08 23:22:53 +0200 (Tue, 08 Apr 2008) | 1 line
Add items
........
r62229 | amaury.forgeotdarc | 2008-04-08 23:27:42 +0200 (Tue, 08 Apr 2008) | 7 lines
Issue2564: Prevent a hang in "import test.autotest", which runs the entire test
suite as a side-effect of importing the module.
- in test_capi, a thread tried to import other modules
- re.compile() imported sre_parse again on every call.
........
r62230 | amaury.forgeotdarc | 2008-04-08 23:51:57 +0200 (Tue, 08 Apr 2008) | 2 lines
Prevent an error when inspect.isabstract() is called with something else than a new-style class.
........
r62231 | amaury.forgeotdarc | 2008-04-09 00:07:05 +0200 (Wed, 09 Apr 2008) | 8 lines
Issue 2408: remove the _types module
It was only used as a helper in types.py to access types (GetSetDescriptorType and MemberDescriptorType),
when they can easily be obtained with python code.
These expressions even work with Jython.
I don't know what the future of the types module is; (cf. discussion in http://bugs.python.org/issue1605 )
at least this change makes it simpler.
........
r62233 | amaury.forgeotdarc | 2008-04-09 01:10:07 +0200 (Wed, 09 Apr 2008) | 2 lines
Add a NEWS entry for previous checkin
........
r62234 | trent.nelson | 2008-04-09 01:47:30 +0200 (Wed, 09 Apr 2008) | 37 lines
- Issue #2550: The approach used by client/server code for obtaining ports
to listen on in network-oriented tests has been refined in an effort to
facilitate running multiple instances of the entire regression test suite
in parallel without issue. test_support.bind_port() has been fixed such
that it will always return a unique port -- which wasn't always the case
with the previous implementation, especially if socket options had been
set that affected address reuse (i.e. SO_REUSEADDR, SO_REUSEPORT). The
new implementation of bind_port() will actually raise an exception if it
is passed an AF_INET/SOCK_STREAM socket with either the SO_REUSEADDR or
SO_REUSEPORT socket option set. Furthermore, if available, bind_port()
will set the SO_EXCLUSIVEADDRUSE option on the socket it's been passed.
This currently only applies to Windows. This option prevents any other
sockets from binding to the host/port we've bound to, thus removing the
possibility of the 'non-deterministic' behaviour, as Microsoft puts it,
that occurs when a second SOCK_STREAM socket binds and accepts to a
host/port that's already been bound by another socket. The optional
preferred port parameter to bind_port() has been removed. Under no
circumstances should tests be hard coding ports!
test_support.find_unused_port() has also been introduced, which will pass
a temporary socket object to bind_port() in order to obtain an unused port.
The temporary socket object is then closed and deleted, and the port is
returned. This method should only be used for obtaining an unused port
in order to pass to an external program (i.e. the -accept [port] argument
to openssl's s_server mode) or as a parameter to a server-oriented class
that doesn't give you direct access to the underlying socket used.
Finally, test_support.HOST has been introduced, which should be used for
the host argument of any relevant socket calls (i.e. bind and connect).
The following tests were updated to following the new conventions:
test_socket, test_smtplib, test_asyncore, test_ssl, test_httplib,
test_poplib, test_ftplib, test_telnetlib, test_socketserver,
test_asynchat and test_socket_ssl.
It is now possible for multiple instances of the regression test suite to
run in parallel without issue.
........
r62235 | gregory.p.smith | 2008-04-09 02:25:17 +0200 (Wed, 09 Apr 2008) | 3 lines
Fix zlib crash from zlib.decompressobj().flush(val) when val was not positive.
It tried to allocate negative or zero memory. That fails.
........
r62237 | trent.nelson | 2008-04-09 02:34:53 +0200 (Wed, 09 Apr 2008) | 1 line
Fix typo with regards to self.PORT shadowing class variables with the same name.
........
r62238 | andrew.kuchling | 2008-04-09 03:08:32 +0200 (Wed, 09 Apr 2008) | 1 line
Add items
........
r62239 | jerry.seutter | 2008-04-09 07:07:58 +0200 (Wed, 09 Apr 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
2008-04-09 05:37:03 -03:00
|
|
|
"Disables registry reflection for 32-bit processes running on a 64-bit\n"
|
2008-04-07 00:17:54 -03:00
|
|
|
"Operating System. Will generally raise NotImplemented if executed on\n"
|
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r62194 | jeffrey.yasskin | 2008-04-07 01:04:28 +0200 (Mon, 07 Apr 2008) | 7 lines
Add enough debugging information to diagnose failures where the
HandlerBException is ignored, and fix one such problem, where it was thrown
during the __del__ method of the previous Popen object.
We may want to find a better way of printing verbose information so it's not
spammy when the test passes.
........
r62197 | mark.hammond | 2008-04-07 03:53:39 +0200 (Mon, 07 Apr 2008) | 2 lines
Issue #2513: enable 64bit cross compilation on windows.
........
r62198 | mark.hammond | 2008-04-07 03:59:40 +0200 (Mon, 07 Apr 2008) | 2 lines
correct heading underline for new "Cross-compiling on Windows" section
........
r62204 | gregory.p.smith | 2008-04-07 08:33:21 +0200 (Mon, 07 Apr 2008) | 4 lines
Use the new PyFile_IncUseCount & PyFile_DecUseCount calls appropriatly
within the standard library. These modules use PyFile_AsFile and later
release the GIL while operating on the previously returned FILE*.
........
r62205 | mark.summerfield | 2008-04-07 09:39:23 +0200 (Mon, 07 Apr 2008) | 4 lines
changed "2500 components" to "several thousand" since the number keeps
growning:-)
........
r62214 | georg.brandl | 2008-04-07 20:51:59 +0200 (Mon, 07 Apr 2008) | 2 lines
#2525: update timezone info examples in the docs.
........
r62219 | andrew.kuchling | 2008-04-08 01:57:07 +0200 (Tue, 08 Apr 2008) | 1 line
Write PEP 3127 section; add items
........
r62220 | andrew.kuchling | 2008-04-08 01:57:21 +0200 (Tue, 08 Apr 2008) | 1 line
Typo fix
........
r62221 | andrew.kuchling | 2008-04-08 03:33:10 +0200 (Tue, 08 Apr 2008) | 1 line
Typographical fix: 32bit -> 32-bit, 64bit -> 64-bit
........
r62227 | andrew.kuchling | 2008-04-08 23:22:53 +0200 (Tue, 08 Apr 2008) | 1 line
Add items
........
r62229 | amaury.forgeotdarc | 2008-04-08 23:27:42 +0200 (Tue, 08 Apr 2008) | 7 lines
Issue2564: Prevent a hang in "import test.autotest", which runs the entire test
suite as a side-effect of importing the module.
- in test_capi, a thread tried to import other modules
- re.compile() imported sre_parse again on every call.
........
r62230 | amaury.forgeotdarc | 2008-04-08 23:51:57 +0200 (Tue, 08 Apr 2008) | 2 lines
Prevent an error when inspect.isabstract() is called with something else than a new-style class.
........
r62231 | amaury.forgeotdarc | 2008-04-09 00:07:05 +0200 (Wed, 09 Apr 2008) | 8 lines
Issue 2408: remove the _types module
It was only used as a helper in types.py to access types (GetSetDescriptorType and MemberDescriptorType),
when they can easily be obtained with python code.
These expressions even work with Jython.
I don't know what the future of the types module is; (cf. discussion in http://bugs.python.org/issue1605 )
at least this change makes it simpler.
........
r62233 | amaury.forgeotdarc | 2008-04-09 01:10:07 +0200 (Wed, 09 Apr 2008) | 2 lines
Add a NEWS entry for previous checkin
........
r62234 | trent.nelson | 2008-04-09 01:47:30 +0200 (Wed, 09 Apr 2008) | 37 lines
- Issue #2550: The approach used by client/server code for obtaining ports
to listen on in network-oriented tests has been refined in an effort to
facilitate running multiple instances of the entire regression test suite
in parallel without issue. test_support.bind_port() has been fixed such
that it will always return a unique port -- which wasn't always the case
with the previous implementation, especially if socket options had been
set that affected address reuse (i.e. SO_REUSEADDR, SO_REUSEPORT). The
new implementation of bind_port() will actually raise an exception if it
is passed an AF_INET/SOCK_STREAM socket with either the SO_REUSEADDR or
SO_REUSEPORT socket option set. Furthermore, if available, bind_port()
will set the SO_EXCLUSIVEADDRUSE option on the socket it's been passed.
This currently only applies to Windows. This option prevents any other
sockets from binding to the host/port we've bound to, thus removing the
possibility of the 'non-deterministic' behaviour, as Microsoft puts it,
that occurs when a second SOCK_STREAM socket binds and accepts to a
host/port that's already been bound by another socket. The optional
preferred port parameter to bind_port() has been removed. Under no
circumstances should tests be hard coding ports!
test_support.find_unused_port() has also been introduced, which will pass
a temporary socket object to bind_port() in order to obtain an unused port.
The temporary socket object is then closed and deleted, and the port is
returned. This method should only be used for obtaining an unused port
in order to pass to an external program (i.e. the -accept [port] argument
to openssl's s_server mode) or as a parameter to a server-oriented class
that doesn't give you direct access to the underlying socket used.
Finally, test_support.HOST has been introduced, which should be used for
the host argument of any relevant socket calls (i.e. bind and connect).
The following tests were updated to following the new conventions:
test_socket, test_smtplib, test_asyncore, test_ssl, test_httplib,
test_poplib, test_ftplib, test_telnetlib, test_socketserver,
test_asynchat and test_socket_ssl.
It is now possible for multiple instances of the regression test suite to
run in parallel without issue.
........
r62235 | gregory.p.smith | 2008-04-09 02:25:17 +0200 (Wed, 09 Apr 2008) | 3 lines
Fix zlib crash from zlib.decompressobj().flush(val) when val was not positive.
It tried to allocate negative or zero memory. That fails.
........
r62237 | trent.nelson | 2008-04-09 02:34:53 +0200 (Wed, 09 Apr 2008) | 1 line
Fix typo with regards to self.PORT shadowing class variables with the same name.
........
r62238 | andrew.kuchling | 2008-04-09 03:08:32 +0200 (Wed, 09 Apr 2008) | 1 line
Add items
........
r62239 | jerry.seutter | 2008-04-09 07:07:58 +0200 (Wed, 09 Apr 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
2008-04-09 05:37:03 -03:00
|
|
|
"a 32-bit Operating System.\n"
|
2012-10-29 20:16:39 -03:00
|
|
|
"\n"
|
2008-04-07 00:17:54 -03:00
|
|
|
"If the key is not on the reflection list, the function succeeds but has no effect.\n"
|
|
|
|
"Disabling reflection for a key does not affect reflection of any subkeys.");
|
|
|
|
|
|
|
|
PyDoc_STRVAR(EnableReflectionKey_doc,
|
|
|
|
"Restores registry reflection for the specified disabled key.\n"
|
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r62194 | jeffrey.yasskin | 2008-04-07 01:04:28 +0200 (Mon, 07 Apr 2008) | 7 lines
Add enough debugging information to diagnose failures where the
HandlerBException is ignored, and fix one such problem, where it was thrown
during the __del__ method of the previous Popen object.
We may want to find a better way of printing verbose information so it's not
spammy when the test passes.
........
r62197 | mark.hammond | 2008-04-07 03:53:39 +0200 (Mon, 07 Apr 2008) | 2 lines
Issue #2513: enable 64bit cross compilation on windows.
........
r62198 | mark.hammond | 2008-04-07 03:59:40 +0200 (Mon, 07 Apr 2008) | 2 lines
correct heading underline for new "Cross-compiling on Windows" section
........
r62204 | gregory.p.smith | 2008-04-07 08:33:21 +0200 (Mon, 07 Apr 2008) | 4 lines
Use the new PyFile_IncUseCount & PyFile_DecUseCount calls appropriatly
within the standard library. These modules use PyFile_AsFile and later
release the GIL while operating on the previously returned FILE*.
........
r62205 | mark.summerfield | 2008-04-07 09:39:23 +0200 (Mon, 07 Apr 2008) | 4 lines
changed "2500 components" to "several thousand" since the number keeps
growning:-)
........
r62214 | georg.brandl | 2008-04-07 20:51:59 +0200 (Mon, 07 Apr 2008) | 2 lines
#2525: update timezone info examples in the docs.
........
r62219 | andrew.kuchling | 2008-04-08 01:57:07 +0200 (Tue, 08 Apr 2008) | 1 line
Write PEP 3127 section; add items
........
r62220 | andrew.kuchling | 2008-04-08 01:57:21 +0200 (Tue, 08 Apr 2008) | 1 line
Typo fix
........
r62221 | andrew.kuchling | 2008-04-08 03:33:10 +0200 (Tue, 08 Apr 2008) | 1 line
Typographical fix: 32bit -> 32-bit, 64bit -> 64-bit
........
r62227 | andrew.kuchling | 2008-04-08 23:22:53 +0200 (Tue, 08 Apr 2008) | 1 line
Add items
........
r62229 | amaury.forgeotdarc | 2008-04-08 23:27:42 +0200 (Tue, 08 Apr 2008) | 7 lines
Issue2564: Prevent a hang in "import test.autotest", which runs the entire test
suite as a side-effect of importing the module.
- in test_capi, a thread tried to import other modules
- re.compile() imported sre_parse again on every call.
........
r62230 | amaury.forgeotdarc | 2008-04-08 23:51:57 +0200 (Tue, 08 Apr 2008) | 2 lines
Prevent an error when inspect.isabstract() is called with something else than a new-style class.
........
r62231 | amaury.forgeotdarc | 2008-04-09 00:07:05 +0200 (Wed, 09 Apr 2008) | 8 lines
Issue 2408: remove the _types module
It was only used as a helper in types.py to access types (GetSetDescriptorType and MemberDescriptorType),
when they can easily be obtained with python code.
These expressions even work with Jython.
I don't know what the future of the types module is; (cf. discussion in http://bugs.python.org/issue1605 )
at least this change makes it simpler.
........
r62233 | amaury.forgeotdarc | 2008-04-09 01:10:07 +0200 (Wed, 09 Apr 2008) | 2 lines
Add a NEWS entry for previous checkin
........
r62234 | trent.nelson | 2008-04-09 01:47:30 +0200 (Wed, 09 Apr 2008) | 37 lines
- Issue #2550: The approach used by client/server code for obtaining ports
to listen on in network-oriented tests has been refined in an effort to
facilitate running multiple instances of the entire regression test suite
in parallel without issue. test_support.bind_port() has been fixed such
that it will always return a unique port -- which wasn't always the case
with the previous implementation, especially if socket options had been
set that affected address reuse (i.e. SO_REUSEADDR, SO_REUSEPORT). The
new implementation of bind_port() will actually raise an exception if it
is passed an AF_INET/SOCK_STREAM socket with either the SO_REUSEADDR or
SO_REUSEPORT socket option set. Furthermore, if available, bind_port()
will set the SO_EXCLUSIVEADDRUSE option on the socket it's been passed.
This currently only applies to Windows. This option prevents any other
sockets from binding to the host/port we've bound to, thus removing the
possibility of the 'non-deterministic' behaviour, as Microsoft puts it,
that occurs when a second SOCK_STREAM socket binds and accepts to a
host/port that's already been bound by another socket. The optional
preferred port parameter to bind_port() has been removed. Under no
circumstances should tests be hard coding ports!
test_support.find_unused_port() has also been introduced, which will pass
a temporary socket object to bind_port() in order to obtain an unused port.
The temporary socket object is then closed and deleted, and the port is
returned. This method should only be used for obtaining an unused port
in order to pass to an external program (i.e. the -accept [port] argument
to openssl's s_server mode) or as a parameter to a server-oriented class
that doesn't give you direct access to the underlying socket used.
Finally, test_support.HOST has been introduced, which should be used for
the host argument of any relevant socket calls (i.e. bind and connect).
The following tests were updated to following the new conventions:
test_socket, test_smtplib, test_asyncore, test_ssl, test_httplib,
test_poplib, test_ftplib, test_telnetlib, test_socketserver,
test_asynchat and test_socket_ssl.
It is now possible for multiple instances of the regression test suite to
run in parallel without issue.
........
r62235 | gregory.p.smith | 2008-04-09 02:25:17 +0200 (Wed, 09 Apr 2008) | 3 lines
Fix zlib crash from zlib.decompressobj().flush(val) when val was not positive.
It tried to allocate negative or zero memory. That fails.
........
r62237 | trent.nelson | 2008-04-09 02:34:53 +0200 (Wed, 09 Apr 2008) | 1 line
Fix typo with regards to self.PORT shadowing class variables with the same name.
........
r62238 | andrew.kuchling | 2008-04-09 03:08:32 +0200 (Wed, 09 Apr 2008) | 1 line
Add items
........
r62239 | jerry.seutter | 2008-04-09 07:07:58 +0200 (Wed, 09 Apr 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
2008-04-09 05:37:03 -03:00
|
|
|
"Will generally raise NotImplemented if executed on a 32-bit Operating System.\n"
|
2008-04-07 00:17:54 -03:00
|
|
|
"Restoring reflection for a key does not affect reflection of any subkeys.");
|
|
|
|
|
|
|
|
PyDoc_STRVAR(QueryReflectionKey_doc,
|
2012-10-29 20:16:39 -03:00
|
|
|
"QueryReflectionKey(hkey) -> bool\n"
|
|
|
|
"Determines the reflection state for the specified key.\n"
|
Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r62194 | jeffrey.yasskin | 2008-04-07 01:04:28 +0200 (Mon, 07 Apr 2008) | 7 lines
Add enough debugging information to diagnose failures where the
HandlerBException is ignored, and fix one such problem, where it was thrown
during the __del__ method of the previous Popen object.
We may want to find a better way of printing verbose information so it's not
spammy when the test passes.
........
r62197 | mark.hammond | 2008-04-07 03:53:39 +0200 (Mon, 07 Apr 2008) | 2 lines
Issue #2513: enable 64bit cross compilation on windows.
........
r62198 | mark.hammond | 2008-04-07 03:59:40 +0200 (Mon, 07 Apr 2008) | 2 lines
correct heading underline for new "Cross-compiling on Windows" section
........
r62204 | gregory.p.smith | 2008-04-07 08:33:21 +0200 (Mon, 07 Apr 2008) | 4 lines
Use the new PyFile_IncUseCount & PyFile_DecUseCount calls appropriatly
within the standard library. These modules use PyFile_AsFile and later
release the GIL while operating on the previously returned FILE*.
........
r62205 | mark.summerfield | 2008-04-07 09:39:23 +0200 (Mon, 07 Apr 2008) | 4 lines
changed "2500 components" to "several thousand" since the number keeps
growning:-)
........
r62214 | georg.brandl | 2008-04-07 20:51:59 +0200 (Mon, 07 Apr 2008) | 2 lines
#2525: update timezone info examples in the docs.
........
r62219 | andrew.kuchling | 2008-04-08 01:57:07 +0200 (Tue, 08 Apr 2008) | 1 line
Write PEP 3127 section; add items
........
r62220 | andrew.kuchling | 2008-04-08 01:57:21 +0200 (Tue, 08 Apr 2008) | 1 line
Typo fix
........
r62221 | andrew.kuchling | 2008-04-08 03:33:10 +0200 (Tue, 08 Apr 2008) | 1 line
Typographical fix: 32bit -> 32-bit, 64bit -> 64-bit
........
r62227 | andrew.kuchling | 2008-04-08 23:22:53 +0200 (Tue, 08 Apr 2008) | 1 line
Add items
........
r62229 | amaury.forgeotdarc | 2008-04-08 23:27:42 +0200 (Tue, 08 Apr 2008) | 7 lines
Issue2564: Prevent a hang in "import test.autotest", which runs the entire test
suite as a side-effect of importing the module.
- in test_capi, a thread tried to import other modules
- re.compile() imported sre_parse again on every call.
........
r62230 | amaury.forgeotdarc | 2008-04-08 23:51:57 +0200 (Tue, 08 Apr 2008) | 2 lines
Prevent an error when inspect.isabstract() is called with something else than a new-style class.
........
r62231 | amaury.forgeotdarc | 2008-04-09 00:07:05 +0200 (Wed, 09 Apr 2008) | 8 lines
Issue 2408: remove the _types module
It was only used as a helper in types.py to access types (GetSetDescriptorType and MemberDescriptorType),
when they can easily be obtained with python code.
These expressions even work with Jython.
I don't know what the future of the types module is; (cf. discussion in http://bugs.python.org/issue1605 )
at least this change makes it simpler.
........
r62233 | amaury.forgeotdarc | 2008-04-09 01:10:07 +0200 (Wed, 09 Apr 2008) | 2 lines
Add a NEWS entry for previous checkin
........
r62234 | trent.nelson | 2008-04-09 01:47:30 +0200 (Wed, 09 Apr 2008) | 37 lines
- Issue #2550: The approach used by client/server code for obtaining ports
to listen on in network-oriented tests has been refined in an effort to
facilitate running multiple instances of the entire regression test suite
in parallel without issue. test_support.bind_port() has been fixed such
that it will always return a unique port -- which wasn't always the case
with the previous implementation, especially if socket options had been
set that affected address reuse (i.e. SO_REUSEADDR, SO_REUSEPORT). The
new implementation of bind_port() will actually raise an exception if it
is passed an AF_INET/SOCK_STREAM socket with either the SO_REUSEADDR or
SO_REUSEPORT socket option set. Furthermore, if available, bind_port()
will set the SO_EXCLUSIVEADDRUSE option on the socket it's been passed.
This currently only applies to Windows. This option prevents any other
sockets from binding to the host/port we've bound to, thus removing the
possibility of the 'non-deterministic' behaviour, as Microsoft puts it,
that occurs when a second SOCK_STREAM socket binds and accepts to a
host/port that's already been bound by another socket. The optional
preferred port parameter to bind_port() has been removed. Under no
circumstances should tests be hard coding ports!
test_support.find_unused_port() has also been introduced, which will pass
a temporary socket object to bind_port() in order to obtain an unused port.
The temporary socket object is then closed and deleted, and the port is
returned. This method should only be used for obtaining an unused port
in order to pass to an external program (i.e. the -accept [port] argument
to openssl's s_server mode) or as a parameter to a server-oriented class
that doesn't give you direct access to the underlying socket used.
Finally, test_support.HOST has been introduced, which should be used for
the host argument of any relevant socket calls (i.e. bind and connect).
The following tests were updated to following the new conventions:
test_socket, test_smtplib, test_asyncore, test_ssl, test_httplib,
test_poplib, test_ftplib, test_telnetlib, test_socketserver,
test_asynchat and test_socket_ssl.
It is now possible for multiple instances of the regression test suite to
run in parallel without issue.
........
r62235 | gregory.p.smith | 2008-04-09 02:25:17 +0200 (Wed, 09 Apr 2008) | 3 lines
Fix zlib crash from zlib.decompressobj().flush(val) when val was not positive.
It tried to allocate negative or zero memory. That fails.
........
r62237 | trent.nelson | 2008-04-09 02:34:53 +0200 (Wed, 09 Apr 2008) | 1 line
Fix typo with regards to self.PORT shadowing class variables with the same name.
........
r62238 | andrew.kuchling | 2008-04-09 03:08:32 +0200 (Wed, 09 Apr 2008) | 1 line
Add items
........
r62239 | jerry.seutter | 2008-04-09 07:07:58 +0200 (Wed, 09 Apr 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
2008-04-09 05:37:03 -03:00
|
|
|
"Will generally raise NotImplemented if executed on a 32-bit Operating System.\n");
|
2008-04-07 00:17:54 -03:00
|
|
|
|
2000-03-28 16:37:15 -04:00
|
|
|
/* PyHKEY docstrings */
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(PyHKEY_doc,
|
2000-03-28 16:37:15 -04:00
|
|
|
"PyHKEY Object - A Python object, representing a win32 registry key.\n"
|
|
|
|
"\n"
|
2000-06-09 03:01:47 -03:00
|
|
|
"This object wraps a Windows HKEY object, automatically closing it when\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"the object is destroyed. To guarantee cleanup, you can call either\n"
|
|
|
|
"the Close() method on the PyHKEY, or the CloseKey() method.\n"
|
|
|
|
"\n"
|
|
|
|
"All functions which accept a handle object also accept an integer - \n"
|
|
|
|
"however, use of the handle object is encouraged.\n"
|
|
|
|
"\n"
|
|
|
|
"Functions:\n"
|
|
|
|
"Close() - Closes the underlying handle.\n"
|
|
|
|
"Detach() - Returns the integer Win32 handle, detaching it from the object\n"
|
|
|
|
"\n"
|
|
|
|
"Properties:\n"
|
|
|
|
"handle - The integer Win32 handle.\n"
|
|
|
|
"\n"
|
|
|
|
"Operations:\n"
|
2006-11-28 15:15:13 -04:00
|
|
|
"__bool__ - Handles with an open object return true, otherwise false.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"__int__ - Converting a handle to an integer returns the Win32 handle.\n"
|
2009-02-01 06:28:51 -04:00
|
|
|
"rich comparison - Handle objects are compared using the handle value.");
|
2000-03-28 16:37:15 -04:00
|
|
|
|
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(PyHKEY_Close_doc,
|
2012-10-29 20:16:39 -03:00
|
|
|
"key.Close()\n"
|
|
|
|
"Closes the underlying Windows handle.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"\n"
|
2002-06-13 17:33:02 -03:00
|
|
|
"If the handle is already closed, no error is raised.");
|
2000-03-28 16:37:15 -04:00
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(PyHKEY_Detach_doc,
|
2012-10-29 20:16:39 -03:00
|
|
|
"key.Detach() -> int\n"
|
|
|
|
"Detaches the Windows handle from the handle object.\n"
|
2000-03-28 16:37:15 -04:00
|
|
|
"\n"
|
|
|
|
"The result is the value of the handle before it is detached. If the\n"
|
|
|
|
"handle is already detached, this will return zero.\n"
|
|
|
|
"\n"
|
|
|
|
"After calling this function, the handle is effectively invalidated,\n"
|
|
|
|
"but the handle is not closed. You would call this function when you\n"
|
|
|
|
"need the underlying win32 handle to exist beyond the lifetime of the\n"
|
2000-06-09 03:01:47 -03:00
|
|
|
"handle object.\n"
|
2002-06-13 17:33:02 -03:00
|
|
|
"On 64 bit windows, the result of this function is a long integer");
|
2000-03-28 16:37:15 -04:00
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
|
|
|
|
The PyHKEY object definition
|
|
|
|
|
|
|
|
************************************************************************/
|
|
|
|
typedef struct {
|
2010-05-09 12:52:27 -03:00
|
|
|
PyObject_VAR_HEAD
|
|
|
|
HKEY hkey;
|
2000-03-28 16:37:15 -04:00
|
|
|
} PyHKEYObject;
|
|
|
|
|
|
|
|
#define PyHKEY_Check(op) ((op)->ob_type == &PyHKEY_Type)
|
|
|
|
|
|
|
|
static char *failMsg = "bad operand type";
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
PyHKEY_unaryFailureFunc(PyObject *ob)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
PyErr_SetString(PyExc_TypeError, failMsg);
|
|
|
|
return NULL;
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
static PyObject *
|
|
|
|
PyHKEY_binaryFailureFunc(PyObject *ob1, PyObject *ob2)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
PyErr_SetString(PyExc_TypeError, failMsg);
|
|
|
|
return NULL;
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
static PyObject *
|
|
|
|
PyHKEY_ternaryFailureFunc(PyObject *ob1, PyObject *ob2, PyObject *ob3)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
PyErr_SetString(PyExc_TypeError, failMsg);
|
|
|
|
return NULL;
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
PyHKEY_deallocFunc(PyObject *ob)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
/* Can not call PyHKEY_Close, as the ob->tp_type
|
|
|
|
has already been cleared, thus causing the type
|
|
|
|
check to fail!
|
|
|
|
*/
|
|
|
|
PyHKEYObject *obkey = (PyHKEYObject *)ob;
|
|
|
|
if (obkey->hkey)
|
|
|
|
RegCloseKey((HKEY)obkey->hkey);
|
|
|
|
PyObject_DEL(ob);
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2006-11-28 15:15:13 -04:00
|
|
|
PyHKEY_boolFunc(PyObject *ob)
|
2000-03-28 16:37:15 -04:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
return ((PyHKEYObject *)ob)->hkey != 0;
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
PyHKEY_intFunc(PyObject *ob)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
PyHKEYObject *pyhkey = (PyHKEYObject *)ob;
|
|
|
|
return PyLong_FromVoidPtr(pyhkey->hkey);
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
PyHKEY_strFunc(PyObject *ob)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
PyHKEYObject *pyhkey = (PyHKEYObject *)ob;
|
|
|
|
return PyUnicode_FromFormat("<PyHKEY:%p>", pyhkey->hkey);
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
PyHKEY_compareFunc(PyObject *ob1, PyObject *ob2)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
PyHKEYObject *pyhkey1 = (PyHKEYObject *)ob1;
|
|
|
|
PyHKEYObject *pyhkey2 = (PyHKEYObject *)ob2;
|
|
|
|
return pyhkey1 == pyhkey2 ? 0 :
|
|
|
|
(pyhkey1 < pyhkey2 ? -1 : 1);
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
2010-10-23 14:37:54 -03:00
|
|
|
static Py_hash_t
|
2000-03-28 16:37:15 -04:00
|
|
|
PyHKEY_hashFunc(PyObject *ob)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
/* Just use the address.
|
|
|
|
XXX - should we use the handle value?
|
|
|
|
*/
|
|
|
|
return _Py_HashPointer(ob);
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static PyNumberMethods PyHKEY_NumberMethods =
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
PyHKEY_binaryFailureFunc, /* nb_add */
|
|
|
|
PyHKEY_binaryFailureFunc, /* nb_subtract */
|
|
|
|
PyHKEY_binaryFailureFunc, /* nb_multiply */
|
|
|
|
PyHKEY_binaryFailureFunc, /* nb_remainder */
|
|
|
|
PyHKEY_binaryFailureFunc, /* nb_divmod */
|
|
|
|
PyHKEY_ternaryFailureFunc, /* nb_power */
|
|
|
|
PyHKEY_unaryFailureFunc, /* nb_negative */
|
|
|
|
PyHKEY_unaryFailureFunc, /* nb_positive */
|
|
|
|
PyHKEY_unaryFailureFunc, /* nb_absolute */
|
|
|
|
PyHKEY_boolFunc, /* nb_bool */
|
|
|
|
PyHKEY_unaryFailureFunc, /* nb_invert */
|
|
|
|
PyHKEY_binaryFailureFunc, /* nb_lshift */
|
|
|
|
PyHKEY_binaryFailureFunc, /* nb_rshift */
|
|
|
|
PyHKEY_binaryFailureFunc, /* nb_and */
|
|
|
|
PyHKEY_binaryFailureFunc, /* nb_xor */
|
|
|
|
PyHKEY_binaryFailureFunc, /* nb_or */
|
|
|
|
PyHKEY_intFunc, /* nb_int */
|
|
|
|
0, /* nb_reserved */
|
|
|
|
PyHKEY_unaryFailureFunc, /* nb_float */
|
2000-03-28 16:37:15 -04:00
|
|
|
};
|
|
|
|
|
2008-07-02 17:50:16 -03:00
|
|
|
static PyObject *PyHKEY_CloseMethod(PyObject *self, PyObject *args);
|
|
|
|
static PyObject *PyHKEY_DetachMethod(PyObject *self, PyObject *args);
|
|
|
|
static PyObject *PyHKEY_Enter(PyObject *self);
|
|
|
|
static PyObject *PyHKEY_Exit(PyObject *self, PyObject *args);
|
2000-03-28 16:37:15 -04:00
|
|
|
|
2008-07-02 17:50:16 -03:00
|
|
|
static struct PyMethodDef PyHKEY_methods[] = {
|
2010-05-09 12:52:27 -03:00
|
|
|
{"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}
|
2008-07-02 17:50:16 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
#define OFF(e) offsetof(PyHKEYObject, e)
|
|
|
|
static PyMemberDef PyHKEY_memberlist[] = {
|
2010-05-09 12:52:27 -03:00
|
|
|
{"handle", T_INT, OFF(hkey), READONLY},
|
|
|
|
{NULL} /* Sentinel */
|
2008-07-02 17:50:16 -03:00
|
|
|
};
|
2000-03-28 16:37:15 -04:00
|
|
|
|
|
|
|
/* The type itself */
|
|
|
|
PyTypeObject PyHKEY_Type =
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
PyVarObject_HEAD_INIT(0, 0) /* fill in type at module init */
|
|
|
|
"PyHKEY",
|
|
|
|
sizeof(PyHKEYObject),
|
|
|
|
0,
|
|
|
|
PyHKEY_deallocFunc, /* tp_dealloc */
|
|
|
|
0, /* tp_print */
|
|
|
|
0, /* tp_getattr */
|
|
|
|
0, /* tp_setattr */
|
|
|
|
0, /* tp_reserved */
|
|
|
|
0, /* tp_repr */
|
|
|
|
&PyHKEY_NumberMethods, /* tp_as_number */
|
|
|
|
0, /* tp_as_sequence */
|
|
|
|
0, /* tp_as_mapping */
|
|
|
|
PyHKEY_hashFunc, /* tp_hash */
|
|
|
|
0, /* tp_call */
|
|
|
|
PyHKEY_strFunc, /* tp_str */
|
|
|
|
0, /* tp_getattro */
|
|
|
|
0, /* tp_setattro */
|
|
|
|
0, /* tp_as_buffer */
|
|
|
|
0, /* tp_flags */
|
|
|
|
PyHKEY_doc, /* tp_doc */
|
|
|
|
0, /*tp_traverse*/
|
|
|
|
0, /*tp_clear*/
|
|
|
|
0, /*tp_richcompare*/
|
|
|
|
0, /*tp_weaklistoffset*/
|
|
|
|
0, /*tp_iter*/
|
|
|
|
0, /*tp_iternext*/
|
|
|
|
PyHKEY_methods, /*tp_methods*/
|
|
|
|
PyHKEY_memberlist, /*tp_members*/
|
2000-03-28 16:37:15 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
|
|
|
|
The PyHKEY object methods
|
|
|
|
|
|
|
|
************************************************************************/
|
|
|
|
static PyObject *
|
|
|
|
PyHKEY_CloseMethod(PyObject *self, PyObject *args)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
if (!PyArg_ParseTuple(args, ":Close"))
|
|
|
|
return NULL;
|
|
|
|
if (!PyHKEY_Close(self))
|
|
|
|
return NULL;
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
PyHKEY_DetachMethod(PyObject *self, PyObject *args)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
void* ret;
|
|
|
|
PyHKEYObject *pThis = (PyHKEYObject *)self;
|
|
|
|
if (!PyArg_ParseTuple(args, ":Detach"))
|
|
|
|
return NULL;
|
|
|
|
ret = (void*)pThis->hkey;
|
|
|
|
pThis->hkey = 0;
|
|
|
|
return PyLong_FromVoidPtr(ret);
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
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.
........
2008-01-08 20:17:24 -04:00
|
|
|
static PyObject *
|
|
|
|
PyHKEY_Enter(PyObject *self)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
Py_XINCREF(self);
|
|
|
|
return self;
|
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.
........
2008-01-08 20:17:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
PyHKEY_Exit(PyObject *self, PyObject *args)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
if (!PyHKEY_Close(self))
|
|
|
|
return NULL;
|
|
|
|
Py_RETURN_NONE;
|
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.
........
2008-01-08 20:17:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-28 16:37:15 -04:00
|
|
|
/************************************************************************
|
|
|
|
The public PyHKEY API (well, not public yet :-)
|
|
|
|
************************************************************************/
|
|
|
|
PyObject *
|
|
|
|
PyHKEY_New(HKEY hInit)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
PyHKEYObject *key = PyObject_NEW(PyHKEYObject, &PyHKEY_Type);
|
|
|
|
if (key)
|
|
|
|
key->hkey = hInit;
|
|
|
|
return (PyObject *)key;
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
PyHKEY_Close(PyObject *ob_handle)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
LONG rc;
|
|
|
|
PyHKEYObject *key;
|
|
|
|
|
|
|
|
if (!PyHKEY_Check(ob_handle)) {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "bad operand type");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
key = (PyHKEYObject *)ob_handle;
|
|
|
|
rc = key->hkey ? RegCloseKey((HKEY)key->hkey) : ERROR_SUCCESS;
|
|
|
|
key->hkey = 0;
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
PyErr_SetFromWindowsErrWithFunction(rc, "RegCloseKey");
|
|
|
|
return rc == ERROR_SUCCESS;
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
PyHKEY_AsHKEY(PyObject *ob, HKEY *pHANDLE, BOOL bNoneOK)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
if (ob == Py_None) {
|
|
|
|
if (!bNoneOK) {
|
|
|
|
PyErr_SetString(
|
|
|
|
PyExc_TypeError,
|
|
|
|
"None is not a valid HKEY in this context");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
*pHANDLE = (HKEY)0;
|
|
|
|
}
|
|
|
|
else if (PyHKEY_Check(ob)) {
|
|
|
|
PyHKEYObject *pH = (PyHKEYObject *)ob;
|
|
|
|
*pHANDLE = pH->hkey;
|
|
|
|
}
|
|
|
|
else if (PyLong_Check(ob)) {
|
|
|
|
/* We also support integers */
|
|
|
|
PyErr_Clear();
|
|
|
|
*pHANDLE = (HKEY)PyLong_AsVoidPtr(ob);
|
|
|
|
if (PyErr_Occurred())
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
PyErr_SetString(
|
|
|
|
PyExc_TypeError,
|
|
|
|
"The object is not a PyHKEY object");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
PyObject *
|
|
|
|
PyHKEY_FromHKEY(HKEY h)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
PyHKEYObject *op;
|
|
|
|
|
|
|
|
/* Inline PyObject_New */
|
|
|
|
op = (PyHKEYObject *) PyObject_MALLOC(sizeof(PyHKEYObject));
|
|
|
|
if (op == NULL)
|
|
|
|
return PyErr_NoMemory();
|
|
|
|
PyObject_INIT(op, &PyHKEY_Type);
|
|
|
|
op->hkey = h;
|
|
|
|
return (PyObject *)op;
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
The module methods
|
|
|
|
************************************************************************/
|
|
|
|
BOOL
|
|
|
|
PyWinObject_CloseHKEY(PyObject *obHandle)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
BOOL ok;
|
|
|
|
if (PyHKEY_Check(obHandle)) {
|
|
|
|
ok = PyHKEY_Close(obHandle);
|
|
|
|
}
|
2000-06-30 14:48:51 -03:00
|
|
|
#if SIZEOF_LONG >= SIZEOF_HKEY
|
2010-05-09 12:52:27 -03:00
|
|
|
else if (PyLong_Check(obHandle)) {
|
|
|
|
long rc = RegCloseKey((HKEY)PyLong_AsLong(obHandle));
|
|
|
|
ok = (rc == ERROR_SUCCESS);
|
|
|
|
if (!ok)
|
|
|
|
PyErr_SetFromWindowsErrWithFunction(rc, "RegCloseKey");
|
|
|
|
}
|
2000-06-30 14:48:51 -03:00
|
|
|
#else
|
2010-05-09 12:52:27 -03:00
|
|
|
else if (PyLong_Check(obHandle)) {
|
|
|
|
long rc = RegCloseKey((HKEY)PyLong_AsVoidPtr(obHandle));
|
|
|
|
ok = (rc == ERROR_SUCCESS);
|
|
|
|
if (!ok)
|
|
|
|
PyErr_SetFromWindowsErrWithFunction(rc, "RegCloseKey");
|
|
|
|
}
|
2000-06-30 14:48:51 -03:00
|
|
|
#endif
|
2010-05-09 12:52:27 -03:00
|
|
|
else {
|
|
|
|
PyErr_SetString(
|
|
|
|
PyExc_TypeError,
|
|
|
|
"A handle must be a HKEY object or an integer");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return ok;
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Private Helper functions for the registry interfaces
|
|
|
|
|
|
|
|
** Note that fixupMultiSZ and countString have both had changes
|
|
|
|
** made to support "incorrect strings". The registry specification
|
|
|
|
** calls for strings to be terminated with 2 null bytes. It seems
|
2000-07-16 09:04:32 -03:00
|
|
|
** some commercial packages install strings which dont conform,
|
2000-03-28 16:37:15 -04:00
|
|
|
** causing this code to fail - however, "regedit" etc still work
|
|
|
|
** with these strings (ie only we dont!).
|
|
|
|
*/
|
|
|
|
static void
|
2007-09-03 04:43:05 -03:00
|
|
|
fixupMultiSZ(wchar_t **str, wchar_t *data, int len)
|
2000-03-28 16:37:15 -04:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
wchar_t *P;
|
|
|
|
int i;
|
|
|
|
wchar_t *Q;
|
|
|
|
|
|
|
|
Q = data + len;
|
|
|
|
for (P = data, i = 0; P < Q && *P != '\0'; P++, i++) {
|
|
|
|
str[i] = P;
|
|
|
|
for(; *P != '\0'; P++)
|
|
|
|
;
|
|
|
|
}
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-09-03 04:43:05 -03:00
|
|
|
countStrings(wchar_t *data, int len)
|
2000-03-28 16:37:15 -04:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
int strings;
|
|
|
|
wchar_t *P;
|
|
|
|
wchar_t *Q = data + len;
|
|
|
|
|
|
|
|
for (P = data, strings = 0; P < Q && *P != '\0'; P++, strings++)
|
|
|
|
for (; P < Q && *P != '\0'; P++)
|
|
|
|
;
|
|
|
|
return strings;
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert PyObject into Registry data.
|
|
|
|
Allocates space as needed. */
|
|
|
|
static BOOL
|
|
|
|
Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
Py_ssize_t i,j;
|
|
|
|
switch (typ) {
|
|
|
|
case REG_DWORD:
|
|
|
|
if (value != Py_None && !PyLong_Check(value))
|
|
|
|
return FALSE;
|
|
|
|
*retDataBuf = (BYTE *)PyMem_NEW(DWORD, 1);
|
|
|
|
if (*retDataBuf==NULL){
|
|
|
|
PyErr_NoMemory();
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
*retDataSize = sizeof(DWORD);
|
|
|
|
if (value == Py_None) {
|
|
|
|
DWORD zero = 0;
|
|
|
|
memcpy(*retDataBuf, &zero, sizeof(DWORD));
|
|
|
|
}
|
|
|
|
else {
|
2012-12-27 12:12:45 -04:00
|
|
|
DWORD d = PyLong_AsUnsignedLong(value);
|
2010-05-09 12:52:27 -03:00
|
|
|
memcpy(*retDataBuf, &d, sizeof(DWORD));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case REG_SZ:
|
|
|
|
case REG_EXPAND_SZ:
|
|
|
|
{
|
2011-11-21 07:43:50 -04:00
|
|
|
if (value != Py_None) {
|
|
|
|
Py_ssize_t len;
|
|
|
|
if (!PyUnicode_Check(value))
|
|
|
|
return FALSE;
|
|
|
|
*retDataBuf = (BYTE*)PyUnicode_AsWideCharString(value, &len);
|
|
|
|
if (*retDataBuf == NULL)
|
|
|
|
return FALSE;
|
|
|
|
*retDataSize = Py_SAFE_DOWNCAST(
|
|
|
|
(len + 1) * sizeof(wchar_t),
|
|
|
|
Py_ssize_t, DWORD);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*retDataBuf = (BYTE *)PyMem_NEW(wchar_t, 1);
|
|
|
|
if (*retDataBuf == NULL) {
|
|
|
|
PyErr_NoMemory();
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
((wchar_t *)*retDataBuf)[0] = L'\0';
|
|
|
|
*retDataSize = 1 * sizeof(wchar_t);
|
|
|
|
}
|
|
|
|
break;
|
2010-05-09 12:52:27 -03:00
|
|
|
}
|
|
|
|
case REG_MULTI_SZ:
|
|
|
|
{
|
|
|
|
DWORD size = 0;
|
|
|
|
wchar_t *P;
|
|
|
|
|
|
|
|
if (value == Py_None)
|
|
|
|
i = 0;
|
|
|
|
else {
|
|
|
|
if (!PyList_Check(value))
|
|
|
|
return FALSE;
|
|
|
|
i = PyList_Size(value);
|
|
|
|
}
|
|
|
|
for (j = 0; j < i; j++)
|
|
|
|
{
|
|
|
|
PyObject *t;
|
2011-11-21 07:43:50 -04:00
|
|
|
wchar_t *wstr;
|
|
|
|
Py_ssize_t len;
|
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
t = PyList_GET_ITEM(value, j);
|
|
|
|
if (!PyUnicode_Check(t))
|
|
|
|
return FALSE;
|
2011-11-21 07:43:50 -04:00
|
|
|
wstr = PyUnicode_AsUnicodeAndSize(t, &len);
|
|
|
|
if (wstr == NULL)
|
|
|
|
return FALSE;
|
|
|
|
size += Py_SAFE_DOWNCAST((len + 1) * sizeof(wchar_t),
|
2010-08-17 17:08:40 -03:00
|
|
|
size_t, DWORD);
|
2010-05-09 12:52:27 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
*retDataSize = size + 2;
|
|
|
|
*retDataBuf = (BYTE *)PyMem_NEW(char,
|
|
|
|
*retDataSize);
|
|
|
|
if (*retDataBuf==NULL){
|
|
|
|
PyErr_NoMemory();
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
P = (wchar_t *)*retDataBuf;
|
|
|
|
|
|
|
|
for (j = 0; j < i; j++)
|
|
|
|
{
|
|
|
|
PyObject *t;
|
2011-11-21 07:43:50 -04:00
|
|
|
wchar_t *wstr;
|
|
|
|
Py_ssize_t len;
|
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
t = PyList_GET_ITEM(value, j);
|
2011-11-21 07:43:50 -04:00
|
|
|
wstr = PyUnicode_AsUnicodeAndSize(t, &len);
|
|
|
|
if (wstr == NULL)
|
|
|
|
return FALSE;
|
|
|
|
wcscpy(P, wstr);
|
|
|
|
P += (len + 1);
|
2010-05-09 12:52:27 -03:00
|
|
|
}
|
|
|
|
/* And doubly-terminate the list... */
|
|
|
|
*P = '\0';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case REG_BINARY:
|
|
|
|
/* ALSO handle ALL unknown data types here. Even if we can't
|
|
|
|
support it natively, we should handle the bits. */
|
|
|
|
default:
|
|
|
|
if (value == Py_None)
|
|
|
|
*retDataSize = 0;
|
|
|
|
else {
|
|
|
|
Py_buffer view;
|
|
|
|
|
|
|
|
if (!PyObject_CheckBuffer(value)) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"Objects of type '%s' can not "
|
|
|
|
"be used as binary registry values",
|
|
|
|
value->ob_type->tp_name);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (PyObject_GetBuffer(value, &view, PyBUF_SIMPLE) < 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
*retDataBuf = (BYTE *)PyMem_NEW(char, view.len);
|
|
|
|
if (*retDataBuf==NULL){
|
|
|
|
PyBuffer_Release(&view);
|
|
|
|
PyErr_NoMemory();
|
|
|
|
return FALSE;
|
|
|
|
}
|
2010-08-17 17:08:40 -03:00
|
|
|
*retDataSize = Py_SAFE_DOWNCAST(view.len, Py_ssize_t, DWORD);
|
2010-05-09 12:52:27 -03:00
|
|
|
memcpy(*retDataBuf, view.buf, view.len);
|
|
|
|
PyBuffer_Release(&view);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert Registry data into PyObject*/
|
|
|
|
static PyObject *
|
2007-09-03 04:43:05 -03:00
|
|
|
Reg2Py(BYTE *retDataBuf, DWORD retDataSize, DWORD typ)
|
2000-03-28 16:37:15 -04:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
PyObject *obData;
|
|
|
|
|
|
|
|
switch (typ) {
|
|
|
|
case REG_DWORD:
|
|
|
|
if (retDataSize == 0)
|
2012-12-27 16:04:42 -04:00
|
|
|
obData = PyLong_FromUnsignedLong(0);
|
2010-05-09 12:52:27 -03:00
|
|
|
else
|
2012-12-27 16:04:42 -04:00
|
|
|
obData = PyLong_FromUnsignedLong(*(int *)retDataBuf);
|
2010-05-09 12:52:27 -03:00
|
|
|
break;
|
|
|
|
case REG_SZ:
|
|
|
|
case REG_EXPAND_SZ:
|
|
|
|
{
|
|
|
|
/* the buffer may or may not have a trailing NULL */
|
|
|
|
wchar_t *data = (wchar_t *)retDataBuf;
|
|
|
|
int len = retDataSize / 2;
|
|
|
|
if (retDataSize && data[len-1] == '\0')
|
|
|
|
retDataSize -= 2;
|
|
|
|
if (retDataSize <= 0)
|
|
|
|
data = L"";
|
2011-09-28 02:41:54 -03:00
|
|
|
obData = PyUnicode_FromWideChar(data, retDataSize/2);
|
2010-05-09 12:52:27 -03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case REG_MULTI_SZ:
|
|
|
|
if (retDataSize == 0)
|
|
|
|
obData = PyList_New(0);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int index = 0;
|
|
|
|
wchar_t *data = (wchar_t *)retDataBuf;
|
|
|
|
int len = retDataSize / 2;
|
|
|
|
int s = countStrings(data, len);
|
|
|
|
wchar_t **str = (wchar_t **)malloc(sizeof(wchar_t *)*s);
|
|
|
|
if (str == NULL)
|
|
|
|
return PyErr_NoMemory();
|
|
|
|
|
|
|
|
fixupMultiSZ(str, data, len);
|
|
|
|
obData = PyList_New(s);
|
|
|
|
if (obData == NULL)
|
|
|
|
return NULL;
|
|
|
|
for (index = 0; index < s; index++)
|
|
|
|
{
|
|
|
|
size_t len = wcslen(str[index]);
|
|
|
|
if (len > INT_MAX) {
|
|
|
|
PyErr_SetString(PyExc_OverflowError,
|
|
|
|
"registry string is too long for a Python string");
|
|
|
|
Py_DECREF(obData);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
PyList_SetItem(obData,
|
|
|
|
index,
|
2011-09-28 02:41:54 -03:00
|
|
|
PyUnicode_FromWideChar(str[index], len));
|
2010-05-09 12:52:27 -03:00
|
|
|
}
|
|
|
|
free(str);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case REG_BINARY:
|
|
|
|
/* ALSO handle ALL unknown data types here. Even if we can't
|
|
|
|
support it natively, we should handle the bits. */
|
|
|
|
default:
|
|
|
|
if (retDataSize == 0) {
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
obData = Py_None;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
obData = PyBytes_FromStringAndSize(
|
|
|
|
(char *)retDataBuf, retDataSize);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return obData;
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* The Python methods */
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
PyCloseKey(PyObject *self, PyObject *args)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
PyObject *obKey;
|
|
|
|
if (!PyArg_ParseTuple(args, "O:CloseKey", &obKey))
|
|
|
|
return NULL;
|
|
|
|
if (!PyHKEY_Close(obKey))
|
|
|
|
return NULL;
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
PyConnectRegistry(PyObject *self, PyObject *args)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
HKEY hKey;
|
|
|
|
PyObject *obKey;
|
|
|
|
wchar_t *szCompName = NULL;
|
|
|
|
HKEY retKey;
|
|
|
|
long rc;
|
|
|
|
if (!PyArg_ParseTuple(args, "ZO:ConnectRegistry", &szCompName, &obKey))
|
|
|
|
return NULL;
|
|
|
|
if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE))
|
|
|
|
return NULL;
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
rc = RegConnectRegistryW(szCompName, hKey, &retKey);
|
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return PyErr_SetFromWindowsErrWithFunction(rc,
|
|
|
|
"ConnectRegistry");
|
|
|
|
return PyHKEY_FromHKEY(retKey);
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
PyCreateKey(PyObject *self, PyObject *args)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
HKEY hKey;
|
|
|
|
PyObject *obKey;
|
|
|
|
wchar_t *subKey;
|
|
|
|
HKEY retKey;
|
|
|
|
long rc;
|
|
|
|
if (!PyArg_ParseTuple(args, "OZ:CreateKey", &obKey, &subKey))
|
|
|
|
return NULL;
|
|
|
|
if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE))
|
|
|
|
return NULL;
|
|
|
|
rc = RegCreateKeyW(hKey, subKey, &retKey);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return PyErr_SetFromWindowsErrWithFunction(rc, "CreateKey");
|
|
|
|
return PyHKEY_FromHKEY(retKey);
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
2010-04-21 20:56:21 -03:00
|
|
|
static PyObject *
|
2010-09-27 14:56:36 -03:00
|
|
|
PyCreateKeyEx(PyObject *self, PyObject *args, PyObject *kwargs)
|
2010-04-21 20:56:21 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
HKEY hKey;
|
2010-09-27 14:56:36 -03:00
|
|
|
PyObject *key;
|
|
|
|
wchar_t *sub_key;
|
2010-05-09 12:52:27 -03:00
|
|
|
HKEY retKey;
|
2010-09-27 14:56:36 -03:00
|
|
|
int reserved = 0;
|
|
|
|
REGSAM access = KEY_WRITE;
|
2010-05-09 12:52:27 -03:00
|
|
|
long rc;
|
2010-09-27 14:56:36 -03:00
|
|
|
|
|
|
|
char *kwlist[] = {"key", "sub_key", "reserved", "access", NULL};
|
|
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OZ|ii:CreateKeyEx", kwlist,
|
|
|
|
&key, &sub_key, &reserved, &access))
|
2010-05-09 12:52:27 -03:00
|
|
|
return NULL;
|
2010-09-27 14:56:36 -03:00
|
|
|
if (!PyHKEY_AsHKEY(key, &hKey, FALSE))
|
2010-05-09 12:52:27 -03:00
|
|
|
return NULL;
|
|
|
|
|
2010-09-27 14:56:36 -03:00
|
|
|
rc = RegCreateKeyExW(hKey, sub_key, reserved, NULL, (DWORD)NULL,
|
|
|
|
access, NULL, &retKey, NULL);
|
2010-05-09 12:52:27 -03:00
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return PyErr_SetFromWindowsErrWithFunction(rc, "CreateKeyEx");
|
|
|
|
return PyHKEY_FromHKEY(retKey);
|
2010-04-21 20:56:21 -03:00
|
|
|
}
|
|
|
|
|
2000-03-28 16:37:15 -04:00
|
|
|
static PyObject *
|
|
|
|
PyDeleteKey(PyObject *self, PyObject *args)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
HKEY hKey;
|
|
|
|
PyObject *obKey;
|
|
|
|
wchar_t *subKey;
|
|
|
|
long rc;
|
|
|
|
if (!PyArg_ParseTuple(args, "Ou:DeleteKey", &obKey, &subKey))
|
|
|
|
return NULL;
|
|
|
|
if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE))
|
|
|
|
return NULL;
|
|
|
|
rc = RegDeleteKeyW(hKey, subKey );
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return PyErr_SetFromWindowsErrWithFunction(rc, "RegDeleteKey");
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
2010-04-21 20:56:21 -03:00
|
|
|
static PyObject *
|
2010-09-27 14:56:36 -03:00
|
|
|
PyDeleteKeyEx(PyObject *self, PyObject *args, PyObject *kwargs)
|
2010-04-21 20:56:21 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
HKEY hKey;
|
2010-09-27 14:56:36 -03:00
|
|
|
PyObject *key;
|
2010-05-09 12:52:27 -03:00
|
|
|
HMODULE hMod;
|
|
|
|
typedef LONG (WINAPI *RDKEFunc)(HKEY, const wchar_t*, REGSAM, int);
|
|
|
|
RDKEFunc pfn = NULL;
|
2010-09-27 14:56:36 -03:00
|
|
|
wchar_t *sub_key;
|
2010-05-09 12:52:27 -03:00
|
|
|
long rc;
|
2010-09-27 14:56:36 -03:00
|
|
|
int reserved = 0;
|
|
|
|
REGSAM access = KEY_WOW64_64KEY;
|
2010-05-09 12:52:27 -03:00
|
|
|
|
2010-09-27 14:56:36 -03:00
|
|
|
char *kwlist[] = {"key", "sub_key", "access", "reserved", NULL};
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Ou|ii:DeleteKeyEx", kwlist,
|
|
|
|
&key, &sub_key, &access, &reserved))
|
2010-05-09 12:52:27 -03:00
|
|
|
return NULL;
|
2010-09-27 14:56:36 -03:00
|
|
|
if (!PyHKEY_AsHKEY(key, &hKey, FALSE))
|
2010-05-09 12:52:27 -03:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* Only available on 64bit platforms, so we must load it
|
|
|
|
dynamically. */
|
2012-01-14 12:54:09 -04:00
|
|
|
hMod = GetModuleHandleW(L"advapi32.dll");
|
2010-05-09 12:52:27 -03:00
|
|
|
if (hMod)
|
|
|
|
pfn = (RDKEFunc)GetProcAddress(hMod,
|
|
|
|
"RegDeleteKeyExW");
|
|
|
|
if (!pfn) {
|
|
|
|
PyErr_SetString(PyExc_NotImplementedError,
|
|
|
|
"not implemented on this platform");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
2010-09-27 14:56:36 -03:00
|
|
|
rc = (*pfn)(hKey, sub_key, access, reserved);
|
2010-05-09 12:52:27 -03:00
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return PyErr_SetFromWindowsErrWithFunction(rc, "RegDeleteKeyEx");
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
2010-04-21 20:56:21 -03:00
|
|
|
}
|
|
|
|
|
2000-03-28 16:37:15 -04:00
|
|
|
static PyObject *
|
|
|
|
PyDeleteValue(PyObject *self, PyObject *args)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
HKEY hKey;
|
|
|
|
PyObject *obKey;
|
|
|
|
wchar_t *subKey;
|
|
|
|
long rc;
|
|
|
|
if (!PyArg_ParseTuple(args, "OZ:DeleteValue", &obKey, &subKey))
|
|
|
|
return NULL;
|
|
|
|
if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE))
|
|
|
|
return NULL;
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
rc = RegDeleteValueW(hKey, subKey);
|
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
if (rc !=ERROR_SUCCESS)
|
|
|
|
return PyErr_SetFromWindowsErrWithFunction(rc,
|
|
|
|
"RegDeleteValue");
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
PyEnumKey(PyObject *self, PyObject *args)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
HKEY hKey;
|
|
|
|
PyObject *obKey;
|
|
|
|
int index;
|
|
|
|
long rc;
|
|
|
|
PyObject *retStr;
|
2010-05-26 14:43:50 -03:00
|
|
|
|
|
|
|
/* The Windows docs claim that the max key name length is 255
|
|
|
|
* characters, plus a terminating nul character. However,
|
|
|
|
* empirical testing demonstrates that it is possible to
|
|
|
|
* create a 256 character key that is missing the terminating
|
|
|
|
* nul. RegEnumKeyEx requires a 257 character buffer to
|
|
|
|
* retrieve such a key name. */
|
|
|
|
wchar_t tmpbuf[257];
|
2012-04-02 12:23:29 -03:00
|
|
|
DWORD len = sizeof(tmpbuf)/sizeof(wchar_t); /* includes NULL terminator */
|
2010-05-09 12:52:27 -03:00
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "Oi:EnumKey", &obKey, &index))
|
|
|
|
return NULL;
|
|
|
|
if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
rc = RegEnumKeyExW(hKey, index, tmpbuf, &len, NULL, NULL, NULL, NULL);
|
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return PyErr_SetFromWindowsErrWithFunction(rc, "RegEnumKeyEx");
|
|
|
|
|
2011-09-28 02:41:54 -03:00
|
|
|
retStr = PyUnicode_FromWideChar(tmpbuf, len);
|
2010-05-09 12:52:27 -03:00
|
|
|
return retStr; /* can be NULL */
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
PyEnumValue(PyObject *self, PyObject *args)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
HKEY hKey;
|
|
|
|
PyObject *obKey;
|
|
|
|
int index;
|
|
|
|
long rc;
|
|
|
|
wchar_t *retValueBuf;
|
2010-08-16 19:11:29 -03:00
|
|
|
BYTE *tmpBuf;
|
2010-05-09 12:52:27 -03:00
|
|
|
BYTE *retDataBuf;
|
2010-05-26 14:43:50 -03:00
|
|
|
DWORD retValueSize, bufValueSize;
|
|
|
|
DWORD retDataSize, bufDataSize;
|
2010-05-09 12:52:27 -03:00
|
|
|
DWORD typ;
|
|
|
|
PyObject *obData;
|
|
|
|
PyObject *retVal;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "Oi:EnumValue", &obKey, &index))
|
|
|
|
return NULL;
|
|
|
|
if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if ((rc = RegQueryInfoKeyW(hKey, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
NULL,
|
|
|
|
&retValueSize, &retDataSize, NULL, NULL))
|
|
|
|
!= ERROR_SUCCESS)
|
|
|
|
return PyErr_SetFromWindowsErrWithFunction(rc,
|
|
|
|
"RegQueryInfoKey");
|
|
|
|
++retValueSize; /* include null terminators */
|
|
|
|
++retDataSize;
|
2010-05-26 14:43:50 -03:00
|
|
|
bufDataSize = retDataSize;
|
|
|
|
bufValueSize = retValueSize;
|
2010-05-09 12:52:27 -03:00
|
|
|
retValueBuf = (wchar_t *)PyMem_Malloc(sizeof(wchar_t) * retValueSize);
|
|
|
|
if (retValueBuf == NULL)
|
|
|
|
return PyErr_NoMemory();
|
|
|
|
retDataBuf = (BYTE *)PyMem_Malloc(retDataSize);
|
|
|
|
if (retDataBuf == NULL) {
|
|
|
|
PyMem_Free(retValueBuf);
|
|
|
|
return PyErr_NoMemory();
|
|
|
|
}
|
|
|
|
|
2010-05-26 14:43:50 -03:00
|
|
|
while (1) {
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
rc = RegEnumValueW(hKey,
|
|
|
|
index,
|
|
|
|
retValueBuf,
|
|
|
|
&retValueSize,
|
|
|
|
NULL,
|
|
|
|
&typ,
|
|
|
|
(BYTE *)retDataBuf,
|
|
|
|
&retDataSize);
|
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
|
|
|
|
if (rc != ERROR_MORE_DATA)
|
|
|
|
break;
|
|
|
|
|
|
|
|
bufDataSize *= 2;
|
2010-08-16 19:11:29 -03:00
|
|
|
tmpBuf = (BYTE *)PyMem_Realloc(retDataBuf, bufDataSize);
|
2010-06-08 17:57:52 -03:00
|
|
|
if (tmpBuf == NULL) {
|
2010-05-26 14:43:50 -03:00
|
|
|
PyErr_NoMemory();
|
|
|
|
retVal = NULL;
|
|
|
|
goto fail;
|
|
|
|
}
|
2010-06-08 17:57:52 -03:00
|
|
|
retDataBuf = tmpBuf;
|
2010-05-26 14:43:50 -03:00
|
|
|
retDataSize = bufDataSize;
|
|
|
|
retValueSize = bufValueSize;
|
|
|
|
}
|
2010-05-09 12:52:27 -03:00
|
|
|
|
|
|
|
if (rc != ERROR_SUCCESS) {
|
|
|
|
retVal = PyErr_SetFromWindowsErrWithFunction(rc,
|
|
|
|
"PyRegEnumValue");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
obData = Reg2Py(retDataBuf, retDataSize, typ);
|
|
|
|
if (obData == NULL) {
|
|
|
|
retVal = NULL;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
retVal = Py_BuildValue("uOi", retValueBuf, obData, typ);
|
|
|
|
Py_DECREF(obData);
|
2003-11-30 18:01:43 -04:00
|
|
|
fail:
|
2010-05-09 12:52:27 -03:00
|
|
|
PyMem_Free(retValueBuf);
|
|
|
|
PyMem_Free(retDataBuf);
|
|
|
|
return retVal;
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
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.
........
2008-01-08 20:17:24 -04:00
|
|
|
static PyObject *
|
|
|
|
PyExpandEnvironmentStrings(PyObject *self, PyObject *args)
|
|
|
|
{
|
2011-11-21 21:27:30 -04:00
|
|
|
wchar_t *retValue = NULL;
|
|
|
|
wchar_t *src;
|
2010-05-09 12:52:27 -03:00
|
|
|
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");
|
|
|
|
}
|
2011-11-21 21:27:30 -04:00
|
|
|
retValue = (wchar_t *)PyMem_Malloc(retValueSize * sizeof(wchar_t));
|
2010-05-09 12:52:27 -03:00
|
|
|
if (retValue == NULL) {
|
|
|
|
return PyErr_NoMemory();
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = ExpandEnvironmentStringsW(src, retValue, retValueSize);
|
|
|
|
if (rc == 0) {
|
|
|
|
PyMem_Free(retValue);
|
|
|
|
return PyErr_SetFromWindowsErrWithFunction(retValueSize,
|
|
|
|
"ExpandEnvironmentStrings");
|
|
|
|
}
|
2011-11-21 21:27:30 -04:00
|
|
|
o = PyUnicode_FromWideChar(retValue, wcslen(retValue));
|
2010-05-09 12:52:27 -03:00
|
|
|
PyMem_Free(retValue);
|
|
|
|
return o;
|
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.
........
2008-01-08 20:17:24 -04:00
|
|
|
}
|
|
|
|
|
2000-03-28 16:37:15 -04:00
|
|
|
static PyObject *
|
|
|
|
PyFlushKey(PyObject *self, PyObject *args)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
HKEY hKey;
|
|
|
|
PyObject *obKey;
|
|
|
|
long rc;
|
|
|
|
if (!PyArg_ParseTuple(args, "O:FlushKey", &obKey))
|
|
|
|
return NULL;
|
|
|
|
if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE))
|
|
|
|
return NULL;
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
rc = RegFlushKey(hKey);
|
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return PyErr_SetFromWindowsErrWithFunction(rc, "RegFlushKey");
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
static PyObject *
|
|
|
|
PyLoadKey(PyObject *self, PyObject *args)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
HKEY hKey;
|
|
|
|
PyObject *obKey;
|
|
|
|
wchar_t *subKey;
|
|
|
|
wchar_t *fileName;
|
|
|
|
|
|
|
|
long rc;
|
|
|
|
if (!PyArg_ParseTuple(args, "Ouu:LoadKey", &obKey, &subKey, &fileName))
|
|
|
|
return NULL;
|
|
|
|
if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE))
|
|
|
|
return NULL;
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
rc = RegLoadKeyW(hKey, subKey, fileName );
|
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return PyErr_SetFromWindowsErrWithFunction(rc, "RegLoadKey");
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2010-09-27 14:56:36 -03:00
|
|
|
PyOpenKey(PyObject *self, PyObject *args, PyObject *kwargs)
|
2000-03-28 16:37:15 -04:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
HKEY hKey;
|
2010-09-27 14:56:36 -03:00
|
|
|
PyObject *key;
|
|
|
|
wchar_t *sub_key;
|
|
|
|
int reserved = 0;
|
2010-05-09 12:52:27 -03:00
|
|
|
HKEY retKey;
|
|
|
|
long rc;
|
2010-09-27 14:56:36 -03:00
|
|
|
REGSAM access = KEY_READ;
|
|
|
|
|
|
|
|
char *kwlist[] = {"key", "sub_key", "reserved", "access", NULL};
|
|
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OZ|ii:OpenKey", kwlist,
|
|
|
|
&key, &sub_key, &reserved, &access))
|
2010-05-09 12:52:27 -03:00
|
|
|
return NULL;
|
2010-09-27 14:56:36 -03:00
|
|
|
if (!PyHKEY_AsHKEY(key, &hKey, FALSE))
|
2010-05-09 12:52:27 -03:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
2010-09-27 14:56:36 -03:00
|
|
|
rc = RegOpenKeyExW(hKey, sub_key, reserved, access, &retKey);
|
2010-05-09 12:52:27 -03:00
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return PyErr_SetFromWindowsErrWithFunction(rc, "RegOpenKeyEx");
|
|
|
|
return PyHKEY_FromHKEY(retKey);
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
PyQueryInfoKey(PyObject *self, PyObject *args)
|
|
|
|
{
|
|
|
|
HKEY hKey;
|
|
|
|
PyObject *obKey;
|
|
|
|
long rc;
|
|
|
|
DWORD nSubKeys, nValues;
|
|
|
|
FILETIME ft;
|
|
|
|
LARGE_INTEGER li;
|
|
|
|
PyObject *l;
|
|
|
|
PyObject *ret;
|
|
|
|
if (!PyArg_ParseTuple(args, "O:QueryInfoKey", &obKey))
|
2010-05-09 12:52:27 -03:00
|
|
|
return NULL;
|
2000-03-28 16:37:15 -04:00
|
|
|
if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE))
|
2010-05-09 12:52:27 -03:00
|
|
|
return NULL;
|
2000-03-28 16:37:15 -04:00
|
|
|
if ((rc = RegQueryInfoKey(hKey, NULL, NULL, 0, &nSubKeys, NULL, NULL,
|
2010-05-09 12:52:27 -03:00
|
|
|
&nValues, NULL, NULL, NULL, &ft))
|
2000-03-28 16:37:15 -04:00
|
|
|
!= ERROR_SUCCESS)
|
2010-05-09 12:52:27 -03:00
|
|
|
return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryInfoKey");
|
2000-03-28 16:37:15 -04:00
|
|
|
li.LowPart = ft.dwLowDateTime;
|
|
|
|
li.HighPart = ft.dwHighDateTime;
|
|
|
|
l = PyLong_FromLongLong(li.QuadPart);
|
|
|
|
if (l == NULL)
|
2010-05-09 12:52:27 -03:00
|
|
|
return NULL;
|
2000-03-28 16:37:15 -04:00
|
|
|
ret = Py_BuildValue("iiO", nSubKeys, nValues, l);
|
|
|
|
Py_DECREF(l);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
PyQueryValue(PyObject *self, PyObject *args)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
HKEY hKey;
|
|
|
|
PyObject *obKey;
|
|
|
|
wchar_t *subKey;
|
|
|
|
long rc;
|
|
|
|
PyObject *retStr;
|
|
|
|
wchar_t *retBuf;
|
2010-05-26 14:43:50 -03:00
|
|
|
DWORD bufSize = 0;
|
|
|
|
DWORD retSize = 0;
|
|
|
|
wchar_t *tmp;
|
2010-05-09 12:52:27 -03:00
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "OZ:QueryValue", &obKey, &subKey))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE))
|
|
|
|
return NULL;
|
2010-05-26 14:43:50 -03:00
|
|
|
|
|
|
|
rc = RegQueryValueW(hKey, subKey, NULL, &retSize);
|
|
|
|
if (rc == ERROR_MORE_DATA)
|
|
|
|
retSize = 256;
|
|
|
|
else if (rc != ERROR_SUCCESS)
|
2010-05-09 12:52:27 -03:00
|
|
|
return PyErr_SetFromWindowsErrWithFunction(rc,
|
|
|
|
"RegQueryValue");
|
2010-05-26 14:43:50 -03:00
|
|
|
|
|
|
|
bufSize = retSize;
|
|
|
|
retBuf = (wchar_t *) PyMem_Malloc(bufSize);
|
2010-05-09 12:52:27 -03:00
|
|
|
if (retBuf == NULL)
|
|
|
|
return PyErr_NoMemory();
|
|
|
|
|
2010-05-26 14:43:50 -03:00
|
|
|
while (1) {
|
|
|
|
retSize = bufSize;
|
|
|
|
rc = RegQueryValueW(hKey, subKey, retBuf, &retSize);
|
|
|
|
if (rc != ERROR_MORE_DATA)
|
|
|
|
break;
|
|
|
|
|
|
|
|
bufSize *= 2;
|
|
|
|
tmp = (wchar_t *) PyMem_Realloc(retBuf, bufSize);
|
|
|
|
if (tmp == NULL) {
|
|
|
|
PyMem_Free(retBuf);
|
|
|
|
return PyErr_NoMemory();
|
|
|
|
}
|
|
|
|
retBuf = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rc != ERROR_SUCCESS) {
|
2010-05-09 12:52:27 -03:00
|
|
|
PyMem_Free(retBuf);
|
|
|
|
return PyErr_SetFromWindowsErrWithFunction(rc,
|
|
|
|
"RegQueryValue");
|
|
|
|
}
|
|
|
|
|
2011-09-28 02:41:54 -03:00
|
|
|
retStr = PyUnicode_FromWideChar(retBuf, wcslen(retBuf));
|
2010-05-09 12:52:27 -03:00
|
|
|
PyMem_Free(retBuf);
|
|
|
|
return retStr;
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
PyQueryValueEx(PyObject *self, PyObject *args)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
HKEY hKey;
|
|
|
|
PyObject *obKey;
|
|
|
|
wchar_t *valueName;
|
|
|
|
|
|
|
|
long rc;
|
2010-05-26 14:43:50 -03:00
|
|
|
BYTE *retBuf, *tmp;
|
|
|
|
DWORD bufSize = 0, retSize;
|
2010-05-09 12:52:27 -03:00
|
|
|
DWORD typ;
|
|
|
|
PyObject *obData;
|
|
|
|
PyObject *result;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "OZ:QueryValueEx", &obKey, &valueName))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE))
|
|
|
|
return NULL;
|
2010-05-26 14:43:50 -03:00
|
|
|
|
|
|
|
rc = RegQueryValueExW(hKey, valueName, NULL, NULL, NULL, &bufSize);
|
|
|
|
if (rc == ERROR_MORE_DATA)
|
|
|
|
bufSize = 256;
|
|
|
|
else if (rc != ERROR_SUCCESS)
|
2010-05-09 12:52:27 -03:00
|
|
|
return PyErr_SetFromWindowsErrWithFunction(rc,
|
|
|
|
"RegQueryValueEx");
|
|
|
|
retBuf = (BYTE *)PyMem_Malloc(bufSize);
|
|
|
|
if (retBuf == NULL)
|
|
|
|
return PyErr_NoMemory();
|
2010-05-26 14:43:50 -03:00
|
|
|
|
|
|
|
while (1) {
|
|
|
|
retSize = bufSize;
|
|
|
|
rc = RegQueryValueExW(hKey, valueName, NULL, &typ,
|
|
|
|
(BYTE *)retBuf, &retSize);
|
|
|
|
if (rc != ERROR_MORE_DATA)
|
|
|
|
break;
|
|
|
|
|
|
|
|
bufSize *= 2;
|
|
|
|
tmp = (char *) PyMem_Realloc(retBuf, bufSize);
|
|
|
|
if (tmp == NULL) {
|
|
|
|
PyMem_Free(retBuf);
|
|
|
|
return PyErr_NoMemory();
|
|
|
|
}
|
|
|
|
retBuf = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rc != ERROR_SUCCESS) {
|
2010-05-09 12:52:27 -03:00
|
|
|
PyMem_Free(retBuf);
|
|
|
|
return PyErr_SetFromWindowsErrWithFunction(rc,
|
|
|
|
"RegQueryValueEx");
|
|
|
|
}
|
|
|
|
obData = Reg2Py(retBuf, bufSize, typ);
|
|
|
|
PyMem_Free(retBuf);
|
|
|
|
if (obData == NULL)
|
|
|
|
return NULL;
|
|
|
|
result = Py_BuildValue("Oi", obData, typ);
|
|
|
|
Py_DECREF(obData);
|
|
|
|
return result;
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
PySaveKey(PyObject *self, PyObject *args)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
HKEY hKey;
|
|
|
|
PyObject *obKey;
|
|
|
|
wchar_t *fileName;
|
|
|
|
LPSECURITY_ATTRIBUTES pSA = NULL;
|
|
|
|
|
|
|
|
long rc;
|
|
|
|
if (!PyArg_ParseTuple(args, "Ou:SaveKey", &obKey, &fileName))
|
|
|
|
return NULL;
|
|
|
|
if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE))
|
|
|
|
return NULL;
|
2000-03-28 16:37:15 -04:00
|
|
|
/* One day we may get security into the core?
|
2010-05-09 12:52:27 -03:00
|
|
|
if (!PyWinObject_AsSECURITY_ATTRIBUTES(obSA, &pSA, TRUE))
|
|
|
|
return NULL;
|
2000-03-28 16:37:15 -04:00
|
|
|
*/
|
2010-05-09 12:52:27 -03:00
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
rc = RegSaveKeyW(hKey, fileName, pSA );
|
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return PyErr_SetFromWindowsErrWithFunction(rc, "RegSaveKey");
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
PySetValue(PyObject *self, PyObject *args)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
HKEY hKey;
|
|
|
|
PyObject *obKey;
|
|
|
|
wchar_t *subKey;
|
|
|
|
wchar_t *str;
|
|
|
|
DWORD typ;
|
|
|
|
DWORD len;
|
|
|
|
long rc;
|
|
|
|
if (!PyArg_ParseTuple(args, "OZiu#:SetValue",
|
|
|
|
&obKey,
|
|
|
|
&subKey,
|
|
|
|
&typ,
|
|
|
|
&str,
|
|
|
|
&len))
|
|
|
|
return NULL;
|
|
|
|
if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE))
|
|
|
|
return NULL;
|
|
|
|
if (typ != REG_SZ) {
|
|
|
|
PyErr_SetString(PyExc_TypeError,
|
|
|
|
"Type must be winreg.REG_SZ");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
rc = RegSetValueW(hKey, subKey, REG_SZ, str, len+1);
|
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return PyErr_SetFromWindowsErrWithFunction(rc, "RegSetValue");
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
PySetValueEx(PyObject *self, PyObject *args)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
HKEY hKey;
|
|
|
|
PyObject *obKey;
|
2011-11-21 21:27:30 -04:00
|
|
|
wchar_t *valueName;
|
2010-05-09 12:52:27 -03:00
|
|
|
PyObject *obRes;
|
|
|
|
PyObject *value;
|
|
|
|
BYTE *data;
|
|
|
|
DWORD len;
|
|
|
|
DWORD typ;
|
|
|
|
|
|
|
|
LONG rc;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "OZOiO:SetValueEx",
|
|
|
|
&obKey,
|
|
|
|
&valueName,
|
|
|
|
&obRes,
|
|
|
|
&typ,
|
|
|
|
&value))
|
|
|
|
return NULL;
|
|
|
|
if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE))
|
|
|
|
return NULL;
|
|
|
|
if (!Py2Reg(value, typ, &data, &len))
|
|
|
|
{
|
|
|
|
if (!PyErr_Occurred())
|
|
|
|
PyErr_SetString(PyExc_ValueError,
|
|
|
|
"Could not convert the data to the specified type.");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
rc = RegSetValueExW(hKey, valueName, 0, typ, data, len);
|
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
PyMem_DEL(data);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return PyErr_SetFromWindowsErrWithFunction(rc,
|
|
|
|
"RegSetValueEx");
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
2008-04-07 00:17:54 -03:00
|
|
|
static PyObject *
|
|
|
|
PyDisableReflectionKey(PyObject *self, PyObject *args)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
HKEY hKey;
|
|
|
|
PyObject *obKey;
|
|
|
|
HMODULE hMod;
|
|
|
|
typedef LONG (WINAPI *RDRKFunc)(HKEY);
|
|
|
|
RDRKFunc pfn = NULL;
|
|
|
|
LONG rc;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "O:DisableReflectionKey", &obKey))
|
|
|
|
return NULL;
|
|
|
|
if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* Only available on 64bit platforms, so we must load it
|
|
|
|
dynamically.*/
|
2012-01-14 12:54:09 -04:00
|
|
|
hMod = GetModuleHandleW(L"advapi32.dll");
|
2010-05-09 12:52:27 -03:00
|
|
|
if (hMod)
|
|
|
|
pfn = (RDRKFunc)GetProcAddress(hMod,
|
|
|
|
"RegDisableReflectionKey");
|
|
|
|
if (!pfn) {
|
|
|
|
PyErr_SetString(PyExc_NotImplementedError,
|
|
|
|
"not implemented on this platform");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
rc = (*pfn)(hKey);
|
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return PyErr_SetFromWindowsErrWithFunction(rc,
|
|
|
|
"RegDisableReflectionKey");
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
2008-04-07 00:17:54 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
PyEnableReflectionKey(PyObject *self, PyObject *args)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
HKEY hKey;
|
|
|
|
PyObject *obKey;
|
|
|
|
HMODULE hMod;
|
|
|
|
typedef LONG (WINAPI *RERKFunc)(HKEY);
|
|
|
|
RERKFunc pfn = NULL;
|
|
|
|
LONG rc;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "O:EnableReflectionKey", &obKey))
|
|
|
|
return NULL;
|
|
|
|
if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* Only available on 64bit platforms, so we must load it
|
|
|
|
dynamically.*/
|
2012-01-14 12:54:09 -04:00
|
|
|
hMod = GetModuleHandleW(L"advapi32.dll");
|
2010-05-09 12:52:27 -03:00
|
|
|
if (hMod)
|
|
|
|
pfn = (RERKFunc)GetProcAddress(hMod,
|
|
|
|
"RegEnableReflectionKey");
|
|
|
|
if (!pfn) {
|
|
|
|
PyErr_SetString(PyExc_NotImplementedError,
|
|
|
|
"not implemented on this platform");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
rc = (*pfn)(hKey);
|
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return PyErr_SetFromWindowsErrWithFunction(rc,
|
|
|
|
"RegEnableReflectionKey");
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
2008-04-07 00:17:54 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
PyQueryReflectionKey(PyObject *self, PyObject *args)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
HKEY hKey;
|
|
|
|
PyObject *obKey;
|
|
|
|
HMODULE hMod;
|
|
|
|
typedef LONG (WINAPI *RQRKFunc)(HKEY, BOOL *);
|
|
|
|
RQRKFunc pfn = NULL;
|
|
|
|
BOOL result;
|
|
|
|
LONG rc;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "O:QueryReflectionKey", &obKey))
|
|
|
|
return NULL;
|
|
|
|
if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* Only available on 64bit platforms, so we must load it
|
|
|
|
dynamically.*/
|
2012-01-14 12:54:09 -04:00
|
|
|
hMod = GetModuleHandleW(L"advapi32.dll");
|
2010-05-09 12:52:27 -03:00
|
|
|
if (hMod)
|
|
|
|
pfn = (RQRKFunc)GetProcAddress(hMod,
|
|
|
|
"RegQueryReflectionKey");
|
|
|
|
if (!pfn) {
|
|
|
|
PyErr_SetString(PyExc_NotImplementedError,
|
|
|
|
"not implemented on this platform");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
rc = (*pfn)(hKey, &result);
|
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return PyErr_SetFromWindowsErrWithFunction(rc,
|
|
|
|
"RegQueryReflectionKey");
|
|
|
|
return PyBool_FromLong(result);
|
2008-04-07 00:17:54 -03:00
|
|
|
}
|
|
|
|
|
2000-03-28 16:37:15 -04:00
|
|
|
static struct PyMethodDef winreg_methods[] = {
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CloseKey", PyCloseKey, METH_VARARGS, CloseKey_doc},
|
|
|
|
{"ConnectRegistry", PyConnectRegistry, METH_VARARGS, ConnectRegistry_doc},
|
|
|
|
{"CreateKey", PyCreateKey, METH_VARARGS, CreateKey_doc},
|
2010-09-27 14:56:36 -03:00
|
|
|
{"CreateKeyEx", (PyCFunction)PyCreateKeyEx,
|
|
|
|
METH_VARARGS | METH_KEYWORDS, CreateKeyEx_doc},
|
2010-05-09 12:52:27 -03:00
|
|
|
{"DeleteKey", PyDeleteKey, METH_VARARGS, DeleteKey_doc},
|
2010-09-27 14:56:36 -03:00
|
|
|
{"DeleteKeyEx", (PyCFunction)PyDeleteKeyEx,
|
|
|
|
METH_VARARGS | METH_KEYWORDS, DeleteKeyEx_doc},
|
2010-05-09 12:52:27 -03:00
|
|
|
{"DeleteValue", PyDeleteValue, METH_VARARGS, DeleteValue_doc},
|
|
|
|
{"DisableReflectionKey", PyDisableReflectionKey, METH_VARARGS, DisableReflectionKey_doc},
|
|
|
|
{"EnableReflectionKey", PyEnableReflectionKey, METH_VARARGS, EnableReflectionKey_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},
|
2010-09-27 14:56:36 -03:00
|
|
|
{"OpenKey", (PyCFunction)PyOpenKey, METH_VARARGS | METH_KEYWORDS,
|
|
|
|
OpenKey_doc},
|
|
|
|
{"OpenKeyEx", (PyCFunction)PyOpenKey, METH_VARARGS | METH_KEYWORDS,
|
|
|
|
OpenKeyEx_doc},
|
2010-05-09 12:52:27 -03:00
|
|
|
{"QueryValue", PyQueryValue, METH_VARARGS, QueryValue_doc},
|
|
|
|
{"QueryValueEx", PyQueryValueEx, METH_VARARGS, QueryValueEx_doc},
|
|
|
|
{"QueryInfoKey", PyQueryInfoKey, METH_VARARGS, QueryInfoKey_doc},
|
|
|
|
{"QueryReflectionKey",PyQueryReflectionKey,METH_VARARGS, QueryReflectionKey_doc},
|
|
|
|
{"SaveKey", PySaveKey, METH_VARARGS, SaveKey_doc},
|
|
|
|
{"SetValue", PySetValue, METH_VARARGS, SetValue_doc},
|
|
|
|
{"SetValueEx", PySetValueEx, METH_VARARGS, SetValueEx_doc},
|
|
|
|
NULL,
|
2000-03-28 16:37:15 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
insint(PyObject * d, char * name, long value)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
PyObject *v = PyLong_FromLong(value);
|
|
|
|
if (!v || PyDict_SetItemString(d, name, v))
|
|
|
|
PyErr_Clear();
|
|
|
|
Py_XDECREF(v);
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#define ADD_INT(val) insint(d, #val, val)
|
|
|
|
|
|
|
|
static void
|
|
|
|
inskey(PyObject * d, char * name, HKEY key)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
PyObject *v = PyLong_FromVoidPtr(key);
|
|
|
|
if (!v || PyDict_SetItemString(d, name, v))
|
|
|
|
PyErr_Clear();
|
|
|
|
Py_XDECREF(v);
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#define ADD_KEY(val) inskey(d, #val, val)
|
|
|
|
|
2008-06-11 02:26:20 -03:00
|
|
|
|
|
|
|
static struct PyModuleDef winregmodule = {
|
2010-05-09 12:52:27 -03:00
|
|
|
PyModuleDef_HEAD_INIT,
|
|
|
|
"winreg",
|
|
|
|
module_doc,
|
|
|
|
-1,
|
|
|
|
winreg_methods,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
2008-06-11 02:26:20 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
PyMODINIT_FUNC PyInit_winreg(void)
|
2000-03-28 16:37:15 -04:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
PyObject *m, *d;
|
|
|
|
m = PyModule_Create(&winregmodule);
|
|
|
|
if (m == NULL)
|
|
|
|
return NULL;
|
|
|
|
d = PyModule_GetDict(m);
|
|
|
|
PyHKEY_Type.tp_doc = PyHKEY_doc;
|
|
|
|
if (PyType_Ready(&PyHKEY_Type) < 0)
|
|
|
|
return NULL;
|
|
|
|
Py_INCREF(&PyHKEY_Type);
|
|
|
|
if (PyDict_SetItemString(d, "HKEYType",
|
|
|
|
(PyObject *)&PyHKEY_Type) != 0)
|
|
|
|
return NULL;
|
2012-12-19 08:33:35 -04:00
|
|
|
Py_INCREF(PyExc_OSError);
|
2010-05-09 12:52:27 -03:00
|
|
|
if (PyDict_SetItemString(d, "error",
|
2012-12-19 08:33:35 -04:00
|
|
|
PyExc_OSError) != 0)
|
2010-05-09 12:52:27 -03:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* Add the relevant constants */
|
|
|
|
ADD_KEY(HKEY_CLASSES_ROOT);
|
|
|
|
ADD_KEY(HKEY_CURRENT_USER);
|
|
|
|
ADD_KEY(HKEY_LOCAL_MACHINE);
|
|
|
|
ADD_KEY(HKEY_USERS);
|
|
|
|
ADD_KEY(HKEY_PERFORMANCE_DATA);
|
2000-03-28 16:37:15 -04:00
|
|
|
#ifdef HKEY_CURRENT_CONFIG
|
2010-05-09 12:52:27 -03:00
|
|
|
ADD_KEY(HKEY_CURRENT_CONFIG);
|
2000-03-28 16:37:15 -04:00
|
|
|
#endif
|
|
|
|
#ifdef HKEY_DYN_DATA
|
2010-05-09 12:52:27 -03:00
|
|
|
ADD_KEY(HKEY_DYN_DATA);
|
2000-03-28 16:37:15 -04:00
|
|
|
#endif
|
2010-05-09 12:52:27 -03:00
|
|
|
ADD_INT(KEY_QUERY_VALUE);
|
|
|
|
ADD_INT(KEY_SET_VALUE);
|
|
|
|
ADD_INT(KEY_CREATE_SUB_KEY);
|
|
|
|
ADD_INT(KEY_ENUMERATE_SUB_KEYS);
|
|
|
|
ADD_INT(KEY_NOTIFY);
|
|
|
|
ADD_INT(KEY_CREATE_LINK);
|
|
|
|
ADD_INT(KEY_READ);
|
|
|
|
ADD_INT(KEY_WRITE);
|
|
|
|
ADD_INT(KEY_EXECUTE);
|
|
|
|
ADD_INT(KEY_ALL_ACCESS);
|
2008-04-07 00:17:54 -03:00
|
|
|
#ifdef KEY_WOW64_64KEY
|
2010-05-09 12:52:27 -03:00
|
|
|
ADD_INT(KEY_WOW64_64KEY);
|
2008-04-07 00:17:54 -03:00
|
|
|
#endif
|
|
|
|
#ifdef KEY_WOW64_32KEY
|
2010-05-09 12:52:27 -03:00
|
|
|
ADD_INT(KEY_WOW64_32KEY);
|
2008-04-07 00:17:54 -03:00
|
|
|
#endif
|
2010-05-09 12:52:27 -03:00
|
|
|
ADD_INT(REG_OPTION_RESERVED);
|
|
|
|
ADD_INT(REG_OPTION_NON_VOLATILE);
|
|
|
|
ADD_INT(REG_OPTION_VOLATILE);
|
|
|
|
ADD_INT(REG_OPTION_CREATE_LINK);
|
|
|
|
ADD_INT(REG_OPTION_BACKUP_RESTORE);
|
|
|
|
ADD_INT(REG_OPTION_OPEN_LINK);
|
|
|
|
ADD_INT(REG_LEGAL_OPTION);
|
|
|
|
ADD_INT(REG_CREATED_NEW_KEY);
|
|
|
|
ADD_INT(REG_OPENED_EXISTING_KEY);
|
|
|
|
ADD_INT(REG_WHOLE_HIVE_VOLATILE);
|
|
|
|
ADD_INT(REG_REFRESH_HIVE);
|
|
|
|
ADD_INT(REG_NO_LAZY_FLUSH);
|
|
|
|
ADD_INT(REG_NOTIFY_CHANGE_NAME);
|
|
|
|
ADD_INT(REG_NOTIFY_CHANGE_ATTRIBUTES);
|
|
|
|
ADD_INT(REG_NOTIFY_CHANGE_LAST_SET);
|
|
|
|
ADD_INT(REG_NOTIFY_CHANGE_SECURITY);
|
|
|
|
ADD_INT(REG_LEGAL_CHANGE_FILTER);
|
|
|
|
ADD_INT(REG_NONE);
|
|
|
|
ADD_INT(REG_SZ);
|
|
|
|
ADD_INT(REG_EXPAND_SZ);
|
|
|
|
ADD_INT(REG_BINARY);
|
|
|
|
ADD_INT(REG_DWORD);
|
|
|
|
ADD_INT(REG_DWORD_LITTLE_ENDIAN);
|
|
|
|
ADD_INT(REG_DWORD_BIG_ENDIAN);
|
|
|
|
ADD_INT(REG_LINK);
|
|
|
|
ADD_INT(REG_MULTI_SZ);
|
|
|
|
ADD_INT(REG_RESOURCE_LIST);
|
|
|
|
ADD_INT(REG_FULL_RESOURCE_DESCRIPTOR);
|
|
|
|
ADD_INT(REG_RESOURCE_REQUIREMENTS_LIST);
|
|
|
|
return m;
|
2000-03-28 16:37:15 -04:00
|
|
|
}
|
|
|
|
|
2007-09-03 04:43:05 -03:00
|
|
|
|