Skip Montanaro wrote:
> > I notice some modules not in modules
> > directory(for example: _warnings、marshal in python directory). Do we need 
> > port those
> > modules to modules directory?
> > 
> > I strongly suspect the answer is "no." Modules which aren't in the
> Modules directory are built directly into the Python executable. Using
> your example of the _warnings module, note that in Makefile.pre.in
> Python/_warnings.o is listed in the PYTHON_OBJS list (as are
> Python/sysmodule.o and Python/marshal.o). This is evidence they are
> built directly into the interpreter itself. Another is that at runtime
> those modules have no __file__ attribute:
> > import marshal
> > marshal.__file__
> > Traceback (most recent call last):
> >   File "<stdin>", line 1, in <module>
> > AttributeError: module 'marshal' has no attribute '__file__'
> > import sys
> > sys.__file__
> > Traceback (most recent call last):
> >   File "<stdin>", line 1, in <module>
> > AttributeError: module 'sys' has no attribute '__file__'
> > import _warnings
> > _warnings.__file__
> > Traceback (most recent call last):
> >   File "<stdin>", line 1, in <module>
> > AttributeError: module '_warnings' has no attribute '__file__'
> > Skip

Hi, skip,
    Thank you for your replay. IMHO, it's because those module is 
builtinmodules, so they have no __file__ attribute and listed in PYTHON_OBJS(I 
am not sure I understand clearly). But I have no clear criteria what module 
should be putted in python directory or modules directory. I found some core 
developer have mentioned this detail 13 years 
ago(https://bugs.python.org/issue1631171).

Best Wishs,
Hai Shi
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/XQD3KSBERANOR5VUFLCZALVUD3DCYKCQ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to