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
371bb50b
Commit
371bb50b
authored
Aug 16, 2008
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug #3542: Support Unicode strings in _msi module.
parent
9abf93d6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
19 deletions
+24
-19
Misc/NEWS
Misc/NEWS
+5
-0
PC/_msi.c
PC/_msi.c
+19
-19
No files found.
Misc/NEWS
View file @
371bb50b
...
...
@@ -49,6 +49,11 @@ Library
- Issue #2523: Fix quadratic behaviour when read()ing a binary file without
asking for a specific length.
Extension Modules
-----------------
- Bug #3542: Support Unicode strings in _msi module.
What's new in Python 3.0b2?
===========================
...
...
PC/_msi.c
View file @
371bb50b
...
...
@@ -18,7 +18,7 @@ static PyObject*
uuidcreate
(
PyObject
*
obj
,
PyObject
*
args
)
{
UUID
result
;
char
*
cresult
;
RPC_WSTR
cresult
;
PyObject
*
oresult
;
/* May return ok, local only, and no address.
...
...
@@ -30,13 +30,13 @@ uuidcreate(PyObject* obj, PyObject*args)
return
NULL
;
}
if
(
UuidToString
(
&
result
,
&
cresult
)
==
RPC_S_OUT_OF_MEMORY
)
{
if
(
UuidToString
W
(
&
result
,
&
cresult
)
==
RPC_S_OUT_OF_MEMORY
)
{
PyErr_SetString
(
PyExc_MemoryError
,
"out of memory in uuidgen"
);
return
NULL
;
}
oresult
=
Py
Bytes_FromString
(
cresult
);
RpcStringFree
(
&
cresult
);
oresult
=
Py
Unicode_FromUnicode
(
cresult
,
wcslen
(
cresult
)
);
RpcStringFree
W
(
&
cresult
);
return
oresult
;
}
...
...
@@ -359,23 +359,23 @@ record_getstring(msiobj* record, PyObject* args)
{
unsigned
int
field
;
unsigned
int
status
;
char
buf
[
2000
];
char
*
res
=
buf
;
WCHAR
buf
[
2000
];
WCHAR
*
res
=
buf
;
DWORD
size
=
sizeof
(
buf
);
PyObject
*
string
;
if
(
!
PyArg_ParseTuple
(
args
,
"I:GetString"
,
&
field
))
return
NULL
;
status
=
MsiRecordGetString
(
record
->
h
,
field
,
res
,
&
size
);
status
=
MsiRecordGetString
W
(
record
->
h
,
field
,
res
,
&
size
);
if
(
status
==
ERROR_MORE_DATA
)
{
res
=
(
char
*
)
malloc
(
size
+
1
);
res
=
(
WCHAR
*
)
malloc
((
size
+
1
)
*
sizeof
(
WCHAR
)
);
if
(
res
==
NULL
)
return
PyErr_NoMemory
();
status
=
MsiRecordGetString
(
record
->
h
,
field
,
res
,
&
size
);
status
=
MsiRecordGetString
W
(
record
->
h
,
field
,
res
,
&
size
);
}
if
(
status
!=
ERROR_SUCCESS
)
return
msierror
((
int
)
status
);
string
=
PyUnicode_From
String
(
res
);
string
=
PyUnicode_From
Unicode
(
res
,
size
);
if
(
buf
!=
res
)
free
(
res
);
return
string
;
...
...
@@ -397,12 +397,12 @@ record_setstring(msiobj* record, PyObject *args)
{
int
status
;
int
field
;
char
*
data
;
Py_UNICODE
*
data
;
if
(
!
PyArg_ParseTuple
(
args
,
"i
s
:SetString"
,
&
field
,
&
data
))
if
(
!
PyArg_ParseTuple
(
args
,
"i
u
:SetString"
,
&
field
,
&
data
))
return
NULL
;
if
((
status
=
MsiRecordSetString
(
record
->
h
,
field
,
data
))
!=
ERROR_SUCCESS
)
if
((
status
=
MsiRecordSetString
W
(
record
->
h
,
field
,
data
))
!=
ERROR_SUCCESS
)
return
msierror
(
status
);
Py_INCREF
(
Py_None
);
...
...
@@ -414,12 +414,12 @@ record_setstream(msiobj* record, PyObject *args)
{
int
status
;
int
field
;
char
*
data
;
Py_UNICODE
*
data
;
if
(
!
PyArg_ParseTuple
(
args
,
"i
s
:SetStream"
,
&
field
,
&
data
))
if
(
!
PyArg_ParseTuple
(
args
,
"i
u
:SetStream"
,
&
field
,
&
data
))
return
NULL
;
if
((
status
=
MsiRecordSetStream
(
record
->
h
,
field
,
data
))
!=
ERROR_SUCCESS
)
if
((
status
=
MsiRecordSetStream
W
(
record
->
h
,
field
,
data
))
!=
ERROR_SUCCESS
)
return
msierror
(
status
);
Py_INCREF
(
Py_None
);
...
...
@@ -586,9 +586,9 @@ summary_setproperty(msiobj* si, PyObject *args)
if
(
!
PyArg_ParseTuple
(
args
,
"iO:SetProperty"
,
&
field
,
&
data
))
return
NULL
;
if
(
Py
Bytes
_Check
(
data
))
{
status
=
MsiSummaryInfoSetProperty
(
si
->
h
,
field
,
VT_LPSTR
,
0
,
NULL
,
Py
Bytes_AsString
(
data
));
if
(
Py
Unicode
_Check
(
data
))
{
status
=
MsiSummaryInfoSetProperty
W
(
si
->
h
,
field
,
VT_LPSTR
,
0
,
NULL
,
Py
Unicode_AsUnicode
(
data
));
}
else
if
(
PyLong_CheckExact
(
data
))
{
long
value
=
PyLong_AsLong
(
data
);
if
(
value
==
-
1
&&
PyErr_Occurred
())
{
...
...
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