Skip to content

Commit 3b7ef7c

Browse files
committed
Update document for QueryValue and QueryValueEx
1 parent 7b80e4b commit 3b7ef7c

File tree

3 files changed

+22
-17
lines changed

3 files changed

+22
-17
lines changed

Doc/library/winreg.rst

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,8 @@ This module offers the following functions:
378378

379379
.. function:: QueryValue(key, sub_key)
380380

381-
Retrieves the unnamed value for a key, as a string.
381+
Retrieves the unnamed value for a key. This function only works with
382+
:const:`REG_SZ` type values and always returns a :class:`str`.
382383

383384
*key* is an already open key, or one of the predefined
384385
:ref:`HKEY_* constants <hkey-constants>`.
@@ -389,8 +390,8 @@ This module offers the following functions:
389390

390391
Values in the registry have name, type, and data components. This method
391392
retrieves the data for a key's first value that has a ``NULL`` name. But the
392-
underlying API call doesn't return the type, so always use
393-
:func:`QueryValueEx` if possible.
393+
underlying API call doesn't return the type and only supports :const:`REG_SZ`,
394+
so always use :func:`QueryValueEx` if possible.
394395

395396
.. audit-event:: winreg.QueryValue key,sub_key,value_name winreg.QueryValue
396397

@@ -410,11 +411,13 @@ This module offers the following functions:
410411
+-------+-----------------------------------------+
411412
| Index | Meaning |
412413
+=======+=========================================+
413-
| ``0`` | The value of the registry item. |
414+
| ``0`` | The value of the registry item. The |
415+
| | type depends on the registry type (see |
416+
| | :ref:`Value Types <value-types>`). |
414417
+-------+-----------------------------------------+
415418
| ``1`` | An integer giving the registry type for |
416-
| | this value (see table in docs for |
417-
| | :meth:`SetValueEx`) |
419+
| | this value (see :ref:`Value Types |
420+
| | <value-types>`). |
418421
+-------+-----------------------------------------+
419422

420423
.. audit-event:: winreg.QueryValue key,sub_key,value_name winreg.QueryValueEx

PC/clinic/winreg.c.h

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PC/winreg.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,14 +1488,14 @@ Retrieves the unnamed value for a key.
14881488
14891489
Values in the registry have name, type, and data components. This method
14901490
retrieves the data for a key's first value that has a NULL name.
1491-
But since the underlying API call doesn't return the type, you'll
1492-
probably be happier using QueryValueEx; this function is just here for
1493-
completeness.
1491+
But since the underlying API call doesn't return the type and only
1492+
supports REG_SZ, you'll probably be happier using QueryValueEx; this
1493+
function is just here for completeness.
14941494
[clinic start generated code]*/
14951495

14961496
static PyObject *
14971497
winreg_QueryValue_impl(PyObject *module, HKEY key, const wchar_t *sub_key)
1498-
/*[clinic end generated code: output=b665ce9ae391fda9 input=41cafbbf423b21d6]*/
1498+
/*[clinic end generated code: output=b665ce9ae391fda9 input=5399c0495cade4b0]*/
14991499
{
15001500
LONG rc;
15011501
HKEY childKey = key;
@@ -1587,12 +1587,13 @@ Retrieves the type and value of a specified sub-key.
15871587
Behaves mostly like QueryValue(), but also returns the type of the
15881588
specified value name associated with the given open registry key.
15891589
1590-
The return value is a tuple of the value and the type_id.
1590+
The return value is a tuple of (value, type), where type is an integer
1591+
identifying the registry type (e.g., winreg.REG_SZ, winreg.REG_DWORD).
15911592
[clinic start generated code]*/
15921593

15931594
static PyObject *
15941595
winreg_QueryValueEx_impl(PyObject *module, HKEY key, const wchar_t *name)
1595-
/*[clinic end generated code: output=2cdecaa44c8c333e input=cf366cada4836891]*/
1596+
/*[clinic end generated code: output=2cdecaa44c8c333e input=131cf296d605685e]*/
15961597
{
15971598
long rc;
15981599
BYTE *retBuf, *tmp;

0 commit comments

Comments
 (0)