Question regarding the standard library?

Hussein B hubaghdadi at gmail.com
Tue Aug 19 15:23:44 CEST 2008


On Aug 19, 8:10 am, George Sakkis <george.sak... at gmail.com> wrote:
> 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
> > respect.
>
> > 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.
>
> > </F>
>
> A less invasive approach is monkey-patching [1], i.e. extend or modify
> the runtime behavior without altering the original source code. For
> instance I recently needed to patch the bug posted athttp://bugs.python.org/issue1651995and I didn't have write access to
> the standard library, so I monkeypatched SGMLParser:
>
> # XXX: monkeypatch SGMLParser to fix bug introduced in 2.5
> #http://bugs.python.org/issue1651995
> if sys.version_info[:2] == (2,5):
>     from sgmllib import SGMLParser
>     SGMLParser.convert_codepoint = lambda self,codepoint:
> unichr(codepoint)
>
> HTH,
> George
>
> [1]http://en.wikipedia.org/wiki/Monkey_patch

Hmmm, nice to know about it :)



More information about the Python-list mailing list