Question regarding the standard library?
george.sakkis at gmail.com
Tue Aug 19 15:10:10 CEST 2008
On Aug 19, 8:16 am, Fredrik Lundh <fred... at pythonware.com> wrote:
> Hussein B wrote:
> > Is the standard library of Python is compiled (you know, the pyc
> > thing)?
> > Is it allowed to edit the source code of the standard library?
> > I'm not talking about submitting the modified code to Python source
> > code repository, I'm just asking if some one can edit the source code
> > in his own machine.
> Python ships with the library sources, and you can of course edit them
> in exactly the same way as you'll edit any other Python file. modules
> in the standard library are no different from your own modules in that
> whether it's a good idea to edit them (unless you're trying to track
> down bugs or provide patches to the maintainers) is a different issue.
A less invasive approach is monkey-patching , i.e. extend or modify
the runtime behavior without altering the original source code. For
instance I recently needed to patch the bug posted at
http://bugs.python.org/issue1651995 and I didn't have write access to
the standard library, so I monkeypatched SGMLParser:
# XXX: monkeypatch SGMLParser to fix bug introduced in 2.5
if sys.version_info[:2] == (2,5):
from sgmllib import SGMLParser
SGMLParser.convert_codepoint = lambda self,codepoint:
More information about the Python-list