Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Dev

Re: [Python-checkins] peps: Note that ImportError will no longer be raised due to a missing __init__.py

 

 

Python dev RSS feed   Index | Next | Previous | View Threaded


brett at python

Apr 19, 2012, 7:59 PM

Post #1 of 5 (174 views)
Permalink
Re: [Python-checkins] peps: Note that ImportError will no longer be raised due to a missing __init__.py

It's actually an ImportWarning, not Error (or at least that's what I meant
on import-sig). If the module is eventually found then there is no error.

On Thu, Apr 19, 2012 at 18:56, eric.smith <python-checkins [at] python>wrote:

> http://hg.python.org/peps/rev/af61fe9a56fb
> changeset: 4281:af61fe9a56fb
> user: Eric V. Smith <eric [at] trueblade>
> date: Thu Apr 19 18:56:22 2012 -0400
> summary:
> Note that ImportError will no longer be raised due to a missing
> __init__.py file.
>
> files:
> pep-0420.txt | 5 +++++
> 1 files changed, 5 insertions(+), 0 deletions(-)
>
>
> diff --git a/pep-0420.txt b/pep-0420.txt
> --- a/pep-0420.txt
> +++ b/pep-0420.txt
> @@ -148,6 +148,11 @@
> path. With namespace packages, all entries in the path must be
> scanned.
>
> +Note that an ImportError will no longer be raised for a directory
> +lacking an ``__init__.py`` file. Such a directory will now be imported
> +as a namespace package, whereas in prior Python versions an
> +ImportError would be raised.
> +
> At PyCon 2012, we had a discussion about namespace packages at which
> PEP 382 and PEP 402 were rejected, to be replaced by this PEP [1]_.
>
>
> --
> Repository URL: http://hg.python.org/peps
>
> _______________________________________________
> Python-checkins mailing list
> Python-checkins [at] python
> http://mail.python.org/mailman/listinfo/python-checkins
>
>


eric at trueblade

Apr 20, 2012, 1:52 AM

Post #2 of 5 (168 views)
Permalink
Re: [Python-checkins] peps: Note that ImportError will no longer be raised due to a missing __init__.py [In reply to]

On 4/19/2012 10:59 PM, Brett Cannon wrote:
> It's actually an ImportWarning, not Error (or at least that's what I
> meant on import-sig). If the module is eventually found then there is no
> error.

My error. Fixed.

Eric.

>
> On Thu, Apr 19, 2012 at 18:56, eric.smith <python-checkins [at] python
> <mailto:python-checkins [at] python>> wrote:
>
> http://hg.python.org/peps/rev/af61fe9a56fb
> changeset: 4281:af61fe9a56fb
> user: Eric V. Smith <eric [at] trueblade
> <mailto:eric [at] trueblade>>
> date: Thu Apr 19 18:56:22 2012 -0400
> summary:
> Note that ImportError will no longer be raised due to a missing
> __init__.py file.
>
> files:
> pep-0420.txt | 5 +++++
> 1 files changed, 5 insertions(+), 0 deletions(-)
>
>
> diff --git a/pep-0420.txt b/pep-0420.txt
> --- a/pep-0420.txt
> +++ b/pep-0420.txt
> @@ -148,6 +148,11 @@
> path. With namespace packages, all entries in the path must be
> scanned.
>
> +Note that an ImportError will no longer be raised for a directory
> +lacking an ``__init__.py`` file. Such a directory will now be imported
> +as a namespace package, whereas in prior Python versions an
> +ImportError would be raised.
> +
> At PyCon 2012, we had a discussion about namespace packages at which
> PEP 382 and PEP 402 were rejected, to be replaced by this PEP [1]_.
>
>
> --
> Repository URL: http://hg.python.org/peps
>
> _______________________________________________
> Python-checkins mailing list
> Python-checkins [at] python <mailto:Python-checkins [at] python>
> http://mail.python.org/mailman/listinfo/python-checkins
>
>
>
>
> _______________________________________________
> Python-checkins mailing list
> Python-checkins [at] python
> http://mail.python.org/mailman/listinfo/python-checkins

_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


jimjjewett at gmail

Apr 24, 2012, 9:56 AM

Post #3 of 5 (152 views)
Permalink
Re: [Python-checkins] peps: Note that ImportError will no longer be raised due to a missing __init__.py [In reply to]

On Thu, Apr 19, 2012 at 18:56, eric.smith wrote:

> +Note that an ImportError will no longer be raised for a directory
> +lacking an ``__init__.py`` file. Such a directory will now be imported
> +as a namespace package, whereas in prior Python versions an
> +ImportError would be raised.

Given that there is no way to modify the __path__ of a namespace
package (short of restarting python?), *should* it be an error if
there is exactly one directory?

Or is that just a case of "other tools out there, didn't happen to
install them"?

-jJ
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


eric at trueblade

Apr 24, 2012, 10:02 AM

Post #4 of 5 (154 views)
Permalink
Re: [Python-checkins] peps: Note that ImportError will no longer be raised due to a missing __init__.py [In reply to]

> On Thu, Apr 19, 2012 at 18:56, eric.smith wrote:
>
>> +Note that an ImportError will no longer be raised for a directory
>> +lacking an ``__init__.py`` file. Such a directory will now be imported
>> +as a namespace package, whereas in prior Python versions an
>> +ImportError would be raised.
>
> Given that there is no way to modify the __path__ of a namespace
> package (short of restarting python?), *should* it be an error if
> there is exactly one directory?
>
> Or is that just a case of "other tools out there, didn't happen to
> install them"?

Right. If I just install zope.interfaces and no other zope packages, that
shouldn't be an error.

Eric.

_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


ncoghlan at gmail

Apr 24, 2012, 11:12 PM

Post #5 of 5 (149 views)
Permalink
Re: [Python-checkins] peps: Note that ImportError will no longer be raised due to a missing __init__.py [In reply to]

On Wed, Apr 25, 2012 at 2:56 AM, Jim Jewett <jimjjewett [at] gmail> wrote:
> On Thu, Apr 19, 2012 at 18:56, eric.smith wrote:
>
>> +Note that an ImportError will no longer be raised for a directory
>> +lacking an ``__init__.py`` file. Such a directory will now be imported
>> +as a namespace package, whereas in prior Python versions an
>> +ImportError would be raised.
>
> Given that there is no way to modify the __path__ of a namespace
> package (short of restarting python?), *should* it be an error if
> there is exactly one directory?
>
> Or is that just a case of "other tools out there, didn't happen to
> install them"?

Or you installed all of them into the same directory (as distro
packages are likely to do).

Also, a namespace package __path__ is still just a list - quite
amenable to modification after creation. The only thing we're not
currently promising in PEP 420 is a programmatic interface to redo the
scan.

Cheers,
Nick.

--
Nick Coghlan   |   ncoghlan [at] gmail   |   Brisbane, Australia
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com

Python dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.