[issue21784] __init__.py can be a directory

2014-10-06 Thread Georg Brandl

Georg Brandl added the comment:

I agree, closing.

--
nosy: +georg.brandl
resolution:  - wont fix
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21784
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21784] __init__.py can be a directory

2014-06-20 Thread Terry J. Reedy

Changes by Terry J. Reedy tjre...@udel.edu:


--
versions:  -Python 3.1, Python 3.2, Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21784
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21784] __init__.py can be a directory

2014-06-20 Thread Raymond Hettinger

Raymond Hettinger added the comment:

 So maybe a check was dropped by mistake?

Why do we care?  For the most part, Linux treats directories as files (if I do 
a mkdir twice, the error is mkdir: tmp: File exists.  We don't care about the 
other flags rwx so why should we care about d?

Python should avoid adding superfluous checks when it doesn't have to.

 Anyways, it doesn't bother me too much.

AFAICT, it hasn't bothered anyone.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21784
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21784] __init__.py can be a directory

2014-06-17 Thread Berker Peksag

Berker Peksag added the comment:

I think this is related to PEP 420.

$ tree pkg/
pkg/
├── foobar.py

$ python3.2 -c from pkg import foobar
Traceback (most recent call last):
  File string, line 1, in module
ImportError: No module named pkg

But, with Python 3.3 and newer:

$ python3.3 -c from pkg import foobar
hello

See 
https://docs.python.org/3/whatsnew/3.3.html#pep-420-implicit-namespace-packages 
for the whatsnew entry.

--
nosy: +berker.peksag, eric.smith
resolution:  - not a bug
stage:  - resolved
status: open - pending

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21784
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21784] __init__.py can be a directory

2014-06-17 Thread abraithwaite

abraithwaite added the comment:

Interesting.  I saw the same behavior on 2.7.7 as well:

$ python2
Python 2.7.7 (default, Jun  3 2014, 01:46:20) 
[GCC 4.9.0 20140521 (prerelease)] on linux2
Type help, copyright, credits or license for more information.
 from pkg import foobar
 foobar
module 'pkg.foobar' from 'pkg/foobar.py'
 

Anyways, it doesn't bother me too much.  I opened a ticket because I couldn't 
find an already open bug about it or any reference to it on google (although 
the keywords aren't great for google searches).

Cheers!

--
resolution: not a bug - 
status: pending - open

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21784
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21784] __init__.py can be a directory

2014-06-17 Thread STINNER Victor

STINNER Victor added the comment:

See also the issue #7732.

--
nosy: +haypo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21784
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21784] __init__.py can be a directory

2014-06-17 Thread STINNER Victor

STINNER Victor added the comment:

I remember that I added an check in Python 3.2 on the file type to explicitly 
reject directories:
http://hg.python.org/cpython/rev/125887a41a6f

+if (stat(buf, statbuf) == 0  S_ISDIR(statbuf.st_mode))
+/* it's a directory */
+fp = NULL;
+else

I wrote this change in the C code, I didn't report the change to the Python 
code (importlib).

A huge work was also done in importlib to reduce the number of calls to stat(). 
So maybe a check was dropped by mistake?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21784
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21784] __init__.py can be a directory

2014-06-16 Thread abraithwaite

New submission from abraithwaite:

Is this expected?  It was very confusing when I cloned a repo that didn't have 
the __init__.py there when I had just made it, but of course git doesn't track 
files, only directories.  I had accidentaly done mkdir instead of touch.

$ mkdir pkg/__init__.py
$ touch pkg/foobar.py
$ python
Python 3.4.1 (default, May 19 2014, 17:23:49) 
[GCC 4.9.0 20140507 (prerelease)] on linux
Type help, copyright, credits or license for more information.
 from pkg import foobar
 foobar
module 'pkg.foobar' from '/home/abraithwaite/pkg/foobar.py'


--
assignee: docs@python
components: Documentation
messages: 220787
nosy: abraithwaite, docs@python
priority: normal
severity: normal
status: open
title: __init__.py can be a directory
type: behavior
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21784
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21784] __init__.py can be a directory

2014-06-16 Thread abraithwaite

abraithwaite added the comment:

 but of course git doesn't track files, only directories.

but of course git doesn't track *directories*, only *files*.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21784
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21784] __init__.py can be a directory

2014-06-16 Thread Raymond Hettinger

Raymond Hettinger added the comment:

 Is this expected? 

It is a little weird but usually problematic.  The cause that import checks for 
the existence of '__init__.py' but doesn't then add isfile() or  isdir() check 
which would be unnecessary 99.9% of the time.

I classify this a harmless oddity.

--
nosy: +rhettinger
priority: normal - low

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21784
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com