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
4a66c279
Commit
4a66c279
authored
Aug 07, 2010
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #9425: Create run_command() subfunction
Use PyUnicode_AsUTF8String() instead of _PyUnicode_AsString()
parent
be4e53a4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
15 deletions
+23
-15
Modules/main.c
Modules/main.c
+23
-15
No files found.
Modules/main.c
View file @
4a66c279
...
...
@@ -253,6 +253,28 @@ static int RunMainFromImporter(wchar_t *filename)
}
}
static
int
run_command
(
wchar_t
*
command
,
PyCompilerFlags
*
cf
)
{
PyObject
*
unicode
,
*
bytes
;
int
ret
;
unicode
=
PyUnicode_FromWideChar
(
command
,
-
1
);
if
(
unicode
==
NULL
)
goto
error
;
bytes
=
PyUnicode_AsUTF8String
(
unicode
);
Py_DECREF
(
unicode
);
if
(
bytes
==
NULL
)
goto
error
;
ret
=
PyRun_SimpleStringFlags
(
PyBytes_AsString
(
bytes
),
cf
);
Py_DECREF
(
bytes
);
return
ret
!=
0
;
error:
PyErr_Print
();
return
1
;
}
/* Main program */
...
...
@@ -564,22 +586,8 @@ Py_Main(int argc, wchar_t **argv)
}
if
(
command
)
{
char
*
commandStr
;
PyObject
*
commandObj
=
PyUnicode_FromWideChar
(
command
,
wcslen
(
command
));
sts
=
run_command
(
command
,
&
cf
);
free
(
command
);
if
(
commandObj
!=
NULL
)
commandStr
=
_PyUnicode_AsString
(
commandObj
);
else
commandStr
=
NULL
;
if
(
commandStr
!=
NULL
)
{
sts
=
PyRun_SimpleStringFlags
(
commandStr
,
&
cf
)
!=
0
;
Py_DECREF
(
commandObj
);
}
else
{
PyErr_Print
();
sts
=
1
;
}
}
else
if
(
module
)
{
sts
=
RunModule
(
module
,
1
);
}
...
...
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