mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 12:24:52 +08:00
[pykd] fixed: issue 8499 ( !py command crashs with wrong script's path )
git-svn-id: https://pykd.svn.codeplex.com/svn@63927 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
494b59b9ef
commit
30d291750a
@ -566,22 +566,14 @@ py( PDEBUG_CLIENT4 client, PCSTR args)
|
|||||||
std::string filePath;
|
std::string filePath;
|
||||||
DbgPythonPath dbgPythonPath;
|
DbgPythonPath dbgPythonPath;
|
||||||
|
|
||||||
|
|
||||||
if ( dbgPythonPath.findPath( argsList[0], fullFileName, filePath ) )
|
if ( dbgPythonPath.findPath( argsList[0], fullFileName, filePath ) )
|
||||||
{
|
{
|
||||||
DWORD oldCurDirLen = GetCurrentDirectoryA( 0, NULL );
|
|
||||||
|
|
||||||
std::vector<char> oldCurDirCstr(oldCurDirLen);
|
|
||||||
|
|
||||||
GetCurrentDirectoryA( oldCurDirLen, &oldCurDirCstr[0] );
|
|
||||||
|
|
||||||
// SetCurrentDirectoryA( filePath.c_str() );
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
boost::python::object result;
|
boost::python::object result;
|
||||||
|
|
||||||
result = boost::python::exec_file( fullFileName.c_str(), global, global );
|
result = boost::python::exec_file( fullFileName.c_str(), global, global );
|
||||||
|
|
||||||
}
|
}
|
||||||
catch( boost::python::error_already_set const & )
|
catch( boost::python::error_already_set const & )
|
||||||
{
|
{
|
||||||
@ -603,8 +595,6 @@ py( PDEBUG_CLIENT4 client, PCSTR args)
|
|||||||
Py_XDECREF(errtype);
|
Py_XDECREF(errtype);
|
||||||
Py_XDECREF(traceback);
|
Py_XDECREF(traceback);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetCurrentDirectoryA( &oldCurDirCstr[0] );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -86,6 +86,7 @@ DbgPythonPath::findPath(
|
|||||||
|
|
||||||
if ( bufSize > 0 )
|
if ( bufSize > 0 )
|
||||||
{
|
{
|
||||||
|
bufSize += 1;
|
||||||
std::vector<char> fullFileNameCStr(bufSize);
|
std::vector<char> fullFileNameCStr(bufSize);
|
||||||
char *partFileNameCStr = NULL;
|
char *partFileNameCStr = NULL;
|
||||||
|
|
||||||
@ -98,10 +99,12 @@ DbgPythonPath::findPath(
|
|||||||
&partFileNameCStr );
|
&partFileNameCStr );
|
||||||
|
|
||||||
fullFileName = std::string( &fullFileNameCStr[0] );
|
fullFileName = std::string( &fullFileNameCStr[0] );
|
||||||
|
if ( !fullFileName.empty() )
|
||||||
|
{
|
||||||
filePath = std::string( &fullFileNameCStr[0], partFileNameCStr );
|
filePath = std::string( &fullFileNameCStr[0], partFileNameCStr );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 2. Èùåì âî âñåõ äèðåêòîðèÿõ, óêàçàííûõ â m_pathList
|
// 2. Èùåì âî âñåõ äèðåêòîðèÿõ, óêàçàííûõ â m_pathList
|
||||||
|
|
||||||
@ -120,10 +123,11 @@ DbgPythonPath::findPath(
|
|||||||
|
|
||||||
if ( bufSize > 0 )
|
if ( bufSize > 0 )
|
||||||
{
|
{
|
||||||
|
bufSize += 1;
|
||||||
std::vector<char> fullFileNameCStr(bufSize);
|
std::vector<char> fullFileNameCStr(bufSize);
|
||||||
char *partFileNameCStr = NULL;
|
char *partFileNameCStr = NULL;
|
||||||
|
|
||||||
SearchPathA(
|
bufSize = SearchPathA(
|
||||||
(*it).c_str(),
|
(*it).c_str(),
|
||||||
fileName.c_str(),
|
fileName.c_str(),
|
||||||
pyExt ? NULL : ".py",
|
pyExt ? NULL : ".py",
|
||||||
@ -132,11 +136,13 @@ DbgPythonPath::findPath(
|
|||||||
&partFileNameCStr );
|
&partFileNameCStr );
|
||||||
|
|
||||||
fullFileName = std::string( &fullFileNameCStr[0] );
|
fullFileName = std::string( &fullFileNameCStr[0] );
|
||||||
|
if ( !fullFileName.empty() )
|
||||||
|
{
|
||||||
filePath = std::string( &fullFileNameCStr[0], partFileNameCStr );
|
filePath = std::string( &fullFileNameCStr[0], partFileNameCStr );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user