[Python-Dev] where is the python "import" implemented

2012-12-10 Thread Isml
Hi, everyone,
    I am testing modifying the pyc file when it is imported. As I know, there is three situation:
    1、runing in the python.exe
 eg: python.exe test.pyc
    in this situation, I find the source on line 1983 in file pythonrun.c
    2、import the pyc from a zip file
    I find the source on line 1132 in zipimport.c
    3、do a normal import
    eg: two file : main.py and testmodule.py
    and in main.py:
    import testmodule
 
    in this situation, I can not find the source code how python implement it. I test a wrong format pyc, and got a error "ImportError: bad magic number",and I search "bad magic number" in the source code,  I find it is in importlib/_bootstrap.py(line 815),but when I modify this error info(eg: test bad magic) and run again, nothing is changed. It seems that the file is not the correct position.___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] 回复: where is the python "import" implemented

2012-12-11 Thread Isml
According to your advice, Now I can see my modified log. It's great! Thanks to Antoine and Martin!
 



Hello,Le Tue, 11 Dec 2012 14:08:27 +0800,"Isml" <76069...@qq.com> a écrit :> Hi, everyone,> I am testing modifying the pyc file when it is imported. As I> know, there is three situation: 1、runing in the python.exe>  eg: python.exe test.pyc> in this situation, I find the source on line 1983 in file> pythonrun.c 2、import the pyc from a zip file> I find the source on line 1132 in zipimport.c> 3、do a normal import> eg: two file : main.py and testmodule.py> and in main.py:> import testmodule>  > in this situation, I can not find the source code how python> implement it. I test a wrong format pyc, and got a error> "ImportError: bad magic number",and I search "bad magic number" in> the source code,  I find it is in importlib/_bootstrap.py(line> 815),but when I modify this error info(eg: test bad magic) and run> again, nothing is changed. It seems that the file is not the correct> position.importlib/_bootstrap.py is indeed the place, but you need to run "make"once you have modified that file. _bootstrap.py is frozen into theexecutable at compile time, because otherwise the bootstrap issues areintractable.RegardsAntoine.___Python-Dev mailing listPython-Dev@python.orghttp://mail.python.org/mailman/listinfo/python-devUnsubscribe: http://mail.python.org/mailman/options/python-dev/76069016%40qq.com
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] compile python 3.3 with bz2 support

2012-12-20 Thread Isml
hi, everyone:
 I want to compile python 3.3 with bz2 support on RedHat 5.5 but fail to do 
that. Here is how I do it:
 1??download bzip2 and compile it(make??make -f Makefile_libbz2_so??make 
install)
 2??chang to python 3.3 source directory : ./configure 
--with-bz2=/usr/local/include
 3??make
 4??make install
  
 after installation complete, I test it??
 [root@localhost Python-3.3.0]# python3 -c "import bz2"
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python3.3/bz2.py", line 21, in 
from _bz2 import BZ2Compressor, BZ2Decompressor
ImportError: No module named '_bz2'

 By the way, RedHat 5.5 has a built-in python 2.4.3. Would it be a problem?___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] compile python 3.3 with bz2 support

2012-12-20 Thread Isml
OK, thanks



-- Original --

From:  "Oleg Broytman";
Date:  Fri, Dec 21, 2012 02:17 PM
To:  "Isml"<76069...@qq.com>; 
Cc:  "python-dev"; 
Subject:  Re: [Python-Dev] compile python 3.3 with bz2 support
Hello.   We are sorry but we cannot help you. This mailing list is to work ondeveloping Python (adding new features to Python itself and fixing bugs);if you're having problems learning, understanding or using Python, pleasefind another forum. Probably python-list/comp.lang.python mailing list/newsgroup is the best place; there are Python developers who participate in it;you may get a faster, and probably more complete, answer there. Seehttp://www.python.org/community/ for other lists/news groups/fora. Thankyou for understanding.On Fri, Dec 21, 2012 at 02:03:40PM +0800, Isml <76069...@qq.com> wrote:> hi, everyone:>  I want to compile python 3.3 with bz2 support on RedHat 5.5 but fail to do that. Here is how I do it:>  1??download bzip2 and compile it(make??make -f Makefile_libbz2_so??make install)>  2??chang to python 3.3 source directory : ./configure --with-bz2=/usr/local/include>  3??make>  4??make install>   >  after installation complete, I test it??>  [root@localhost Python-3.3.0]# python3 -c "import bz2"> Traceback (most recent call last):>   File "", line 1, in >   File "/usr/local/lib/python3.3/bz2.py", line 21, in > from _bz2 import BZ2Compressor, BZ2Decompressor> ImportError: No module named '_bz2'   You have to install bz2 development files (headers and libraries)before recompiling python.>  By the way, RedHat 5.5 has a built-in python 2.4.3. Would it be a problem?   Depends on what are you going to do.Oleg.--  Oleg Broytman    http://phdru.name/    p...@phdru.name   Programmers don't die, they just GOSUB without RETURN.
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com