[Python-checkins] r53800 - in python/trunk: Lib/encodings/__init__.py Misc/NEWS
mal at egenix.com
Fri Feb 16 20:31:41 CET 2007
On 2007-02-16 20:23, Brett Cannon wrote:
> On 2/16/07, M.-A. Lemburg <mal at egenix.com> wrote:
>> On 2007-02-16 00:51, Brett Cannon wrote:
>> > On 2/15/07, M.-A. Lemburg <mal at egenix.com> wrote:
>> >> On 2007-02-15 23:54, brett.cannon wrote:
>> >>> Author: brett.cannon
>> >>> Date: Thu Feb 15 23:54:39 2007
>> >>> New Revision: 53800
>> >>> Modified:
>> >>> python/trunk/Lib/encodings/__init__.py
>> >>> python/trunk/Misc/NEWS
>> >>> Log:
>> >>> Update the encoding package's search function to use absolute
>> imports when
>> >>> calling __import__. This helps make the expected search locations
>> for encoding
>> >>> modules be more explicit.
>> >> Your change does not make the import absolute - to the contrary: we
>> >> now have a relative import.
>> > Right, but I just associate it with the absolute import PEP and the
>> > term. Probably could have called it a "new-style import" or
>> > something.
>> >> Please change that back to the original scheme which is indeed an
>> >> absolute import.
>> > Why? What's wrong with a relative import?
>> Whenever possible we should use absolute imports. Relative imports
>> are really only necessary when you want to make packages relocatable
>> which is not the case for the encodings package.
> True, but my motivation was to enforce importing from the 'encodings'
> package to prevent people from importing modules with side-effects
> that are not in the package.
That was the motivation to add the "'encodings.' +" in front
of the module name :-)
Note that before we made that change, the fact that you could import
codecs from the PYTHONPATH was actually an (undocumented) feature
and used by a few people to be able to easily add their own codec
packages to the global namespace.
The right way to do this is to register your own search function,
of course, which is why we decided to break this feature in favor
of preventing DOS attacks like u"abc".encode('test.testall').
> But absolute imports do the same thing, so I am running regrtest and
> then will check in an absolute import once that is done.
Professional Python Services directly from the Source (#1, Feb 16 2007)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
More information about the Python-checkins