danny
unread,Apr 26, 2013, 4:41:40 PM4/26/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
Howdy,
In python 3.3 you no longer need __init__.py in directories to be
interpreted as package namespaces. In my source I have the following tree
src
/apps
/index
/mapping
I removed the __init__.py files as I should be able to, but imports broke.
Specifically:
/opt/python3.3.1/lib/python3.3/site-packages/django/utils/translation/trans_real.py(155)_fetch()
154 app = import_module(appname)
2-> 155 apppath =
os.path.join(os.path.dirname(upath(app.__file__)), 'locale')
notice the app.__file__. In python 3.3 modules are not required to have a
__file__ attribute.
So in particular, I was not able to execute
python3.3 manage.py shell because of the cryptic
*** AttributeError: 'module' object has no attribute '__file__'
which I traced to this line in the Django source.
I don't know if it appears anywhere else, but module.__file__ is no longer
robust in python 3.3.
The poor man's fix is to put the __init__.py's back in.
src
/apps
/index
__init__.py
/mapping
__init__.py
works just fine, but shouldn't be required.
This is on RHEL5.8, but I doubt that matters.
thanks,
Danny