mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-29 20:03:33 +08:00
[!] bug fixed: issue #7717 ( !py command failed to find standart modules )
[!] bug fixed: issue #7718 ( sys.argv[0] does not contain script name ) git-svn-id: https://pykd.svn.codeplex.com/svn@57921 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
2599f9885f
commit
17c51fac01
@ -262,27 +262,20 @@ py( PDEBUG_CLIENT4 client, PCSTR args)
|
|||||||
if ( argsList.size() == 0 )
|
if ( argsList.size() == 0 )
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
|
||||||
if ( argsList.size() > 1 )
|
char **pythonArgs = new char* [ argsList.size() ];
|
||||||
{
|
|
||||||
char **pythonArgs = new char* [ argsList.size() - 1 ];
|
|
||||||
|
|
||||||
for ( size_t i = 0; i < argsList.size() - 1; ++i )
|
for ( size_t i = 0; i < argsList.size(); ++i )
|
||||||
pythonArgs[i] = const_cast<char*>( argsList[i+1].c_str() );
|
pythonArgs[i] = const_cast<char*>( argsList[i].c_str() );
|
||||||
|
|
||||||
PySys_SetArgv( (int)argsList.size() - 1, pythonArgs );
|
PySys_SetArgv( (int)argsList.size(), pythonArgs );
|
||||||
|
|
||||||
delete[] pythonArgs;
|
delete[] pythonArgs;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char *emptyParam = "";
|
|
||||||
|
|
||||||
PySys_SetArgv( 1, &emptyParam );
|
|
||||||
}
|
|
||||||
|
|
||||||
// íàéòè ïóòü ê ôàéëó
|
// íàéòè ïóòü ê ôàéëó
|
||||||
std::string fullFileName;
|
std::string fullFileName;
|
||||||
std::string filePath;
|
std::string filePath;
|
||||||
|
DbgPythonPath dbgPythonPath;
|
||||||
|
|
||||||
if ( dbgPythonPath.findPath( argsList[0], fullFileName, filePath ) )
|
if ( dbgPythonPath.findPath( argsList[0], fullFileName, filePath ) )
|
||||||
{
|
{
|
||||||
@ -453,7 +446,7 @@ pythonpath( PDEBUG_CLIENT4 client, PCSTR args )
|
|||||||
SetupDebugEngine( client, &ext );
|
SetupDebugEngine( client, &ext );
|
||||||
dbgExt = &ext;
|
dbgExt = &ext;
|
||||||
|
|
||||||
DbgPrint::dprintln( dbgPythonPath.getStr() );
|
//DbgPrint::dprintln( dbgPythonPath.getStr() );
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -3,14 +3,12 @@
|
|||||||
#include "dbgpath.h"
|
#include "dbgpath.h"
|
||||||
|
|
||||||
#include <boost/tokenizer.hpp>
|
#include <boost/tokenizer.hpp>
|
||||||
|
#include <boost/python.hpp>
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
DbgPythonPath &dbgPythonPath = DbgPythonPath();
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
DbgPythonPath::DbgPythonPath()
|
DbgPythonPath::DbgPythonPath()
|
||||||
{
|
{
|
||||||
DWORD enviromentSize = 0;
|
DWORD enviromentSize = 0;
|
||||||
@ -62,6 +60,16 @@ DbgPythonPath::findPath(
|
|||||||
std::string &fullFileName,
|
std::string &fullFileName,
|
||||||
std::string &filePath ) const
|
std::string &filePath ) const
|
||||||
{
|
{
|
||||||
|
std::vector< std::string > extPathList;
|
||||||
|
|
||||||
|
boost::python::object sys = boost::python::import( "sys");
|
||||||
|
|
||||||
|
boost::python::list pathList( sys.attr("path") );
|
||||||
|
|
||||||
|
boost::python::ssize_t n = boost::python::len(pathList);
|
||||||
|
for(boost::python::ssize_t i=0;i<n;i++)
|
||||||
|
extPathList.push_back( boost::python::extract<std::string>( pathList[i] ) );
|
||||||
|
|
||||||
bool pyExt = fileName.rfind( ".py" ) == fileName.length() - 3;
|
bool pyExt = fileName.rfind( ".py" ) == fileName.length() - 3;
|
||||||
|
|
||||||
// 1. Èùåì â ðàáî÷åé äèðåêòîðèè
|
// 1. Èùåì â ðàáî÷åé äèðåêòîðèè
|
||||||
@ -97,9 +105,9 @@ DbgPythonPath::findPath(
|
|||||||
|
|
||||||
// 2. Èùåì âî âñåõ äèðåêòîðèÿõ, óêàçàííûõ â m_pathList
|
// 2. Èùåì âî âñåõ äèðåêòîðèÿõ, óêàçàííûõ â m_pathList
|
||||||
|
|
||||||
std::vector<std::string>::const_iterator it = m_pathList.begin();
|
std::vector<std::string>::const_iterator it = extPathList.begin();
|
||||||
|
|
||||||
for ( ; it != m_pathList.end(); ++it )
|
for ( ; it != extPathList.end(); ++it )
|
||||||
{
|
{
|
||||||
DWORD bufSize =
|
DWORD bufSize =
|
||||||
SearchPathA(
|
SearchPathA(
|
||||||
|
@ -27,7 +27,7 @@ private:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern DbgPythonPath& dbgPythonPath;
|
//extern DbgPythonPath& dbgPythonPath;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
Loading…
Reference in New Issue
Block a user