[Python-checkins] r76233 - python/branches/py3k/Lib/importlib/_bootstrap.py

Brett Cannon brett at python.org
Fri Nov 13 02:38:06 CET 2009


On Thu, Nov 12, 2009 at 16:47, benjamin.peterson
<python-checkins at python.org> wrote:
> Author: benjamin.peterson
> Date: Fri Nov 13 01:45:32 2009
> New Revision: 76233
>
> Log:
> no need to translate newlines in python code anymore

Sweet! Thanks for this, Benjamin! I always hated having this hack in
the code since I knew it was a nasty performance hit. I was planning
on trying to solve it at some point. Glad you beat me to it. =)

>
> Modified:
>   python/branches/py3k/Lib/importlib/_bootstrap.py
>
> Modified: python/branches/py3k/Lib/importlib/_bootstrap.py
> ==============================================================================
> --- python/branches/py3k/Lib/importlib/_bootstrap.py    (original)
> +++ python/branches/py3k/Lib/importlib/_bootstrap.py    Fri Nov 13 01:45:32 2009
> @@ -344,21 +344,6 @@
>             message = "a source path must exist to load {0}".format(fullname)
>             raise ImportError(message)
>         source = self.get_data(source_path)
> -        # Convert to universal newlines.
> -        line_endings = b'\n'
> -        for index, c in enumerate(source):
> -            if c == ord(b'\n'):
> -                break
> -            elif c == ord(b'\r'):
> -                line_endings = b'\r'
> -                try:
> -                    if source[index+1] == ord(b'\n'):
> -                        line_endings += b'\n'
> -                except IndexError:
> -                    pass
> -                break
> -        if line_endings != b'\n':
> -            source = source.replace(line_endings, b'\n')
>         return compile(source, source_path, 'exec', dont_inherit=True)
>
>     # Never use in implementing import! Imports code within the method.
> _______________________________________________
> Python-checkins mailing list
> Python-checkins at python.org
> http://mail.python.org/mailman/listinfo/python-checkins
>


More information about the Python-checkins mailing list