Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
be49244b
Commit
be49244b
authored
Nov 21, 2011
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winreg module avoids the deprecated Unicode API
parent
0293db69
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
24 deletions
+36
-24
PC/winreg.c
PC/winreg.c
+36
-24
No files found.
PC/winreg.c
View file @
be49244b
...
...
@@ -760,25 +760,26 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize)
case
REG_SZ
:
case
REG_EXPAND_SZ
:
{
if
(
value
==
Py_None
)
*
retDataSize
=
1
;
else
{
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
(
2
+
PyUnicode_GET_DATA_SIZE
(
value
),
size_t
,
DWORD
);
(
len
+
1
)
*
sizeof
(
wchar_t
),
Py_s
size_t
,
DWORD
);
}
*
retDataBuf
=
(
BYTE
*
)
PyMem_NEW
(
DWORD
,
*
retDataSize
);
if
(
*
retDataBuf
==
NULL
){
else
{
*
retDataBuf
=
(
BYTE
*
)
PyMem_NEW
(
wchar_t
,
1
);
if
(
*
retDataBuf
==
NULL
)
{
PyErr_NoMemory
();
return
FALSE
;
}
if
(
value
==
Py_None
)
wcscpy
((
wchar_t
*
)
*
retDataBuf
,
L""
);
else
wcscpy
((
wchar_t
*
)
*
retDataBuf
,
PyUnicode_AS_UNICODE
(
value
));
((
wchar_t
*
)
*
retDataBuf
)[
0
]
=
L'\0'
;
*
retDataSize
=
1
*
sizeof
(
wchar_t
);
}
break
;
}
case
REG_MULTI_SZ
:
...
...
@@ -796,10 +797,16 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize)
for
(
j
=
0
;
j
<
i
;
j
++
)
{
PyObject
*
t
;
wchar_t
*
wstr
;
Py_ssize_t
len
;
t
=
PyList_GET_ITEM
(
value
,
j
);
if
(
!
PyUnicode_Check
(
t
))
return
FALSE
;
size
+=
Py_SAFE_DOWNCAST
(
2
+
PyUnicode_GET_DATA_SIZE
(
t
),
wstr
=
PyUnicode_AsUnicodeAndSize
(
t
,
&
len
);
if
(
wstr
==
NULL
)
return
FALSE
;
size
+=
Py_SAFE_DOWNCAST
((
len
+
1
)
*
sizeof
(
wchar_t
),
size_t
,
DWORD
);
}
...
...
@@ -815,10 +822,15 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize)
for
(
j
=
0
;
j
<
i
;
j
++
)
{
PyObject
*
t
;
wchar_t
*
wstr
;
Py_ssize_t
len
;
t
=
PyList_GET_ITEM
(
value
,
j
);
wcscpy
(
P
,
PyUnicode_AS_UNICODE
(
t
));
P
+=
1
+
wcslen
(
PyUnicode_AS_UNICODE
(
t
));
wstr
=
PyUnicode_AsUnicodeAndSize
(
t
,
&
len
);
if
(
wstr
==
NULL
)
return
FALSE
;
wcscpy
(
P
,
wstr
);
P
+=
(
len
+
1
);
}
/* And doubly-terminate the list... */
*
P
=
'\0'
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment