classification
Title: is_package missing so can't use -m
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: rejected
Dependencies: 18058 Superseder:
Assigned To: brett.cannon Nosy List: acooke, barry, brett.cannon, christian.heimes
Priority: normal Keywords:

Created on 2013-07-10 12:36 by acooke, last changed 2017-02-18 11:51 by ncoghlan. This issue is now closed.

Messages (5)
msg192799 - (view) Author: andrew cooke (acooke) Date: 2013-07-10 12:36
Using python 3.3, if I try to run __main__ I see this error:

Traceback (most recent call last):                                              
  File "/usr/local/lib/python3.3/runpy.py", line 140, in _run_module_as_main    
    mod_name, loader, code, fname = _get_module_details(mod_name)               
  File "/usr/local/lib/python3.3/runpy.py", line 105, in _get_module_details    
    if loader.is_package(mod_name):                                             
AttributeError: 'NamespaceLoader' object has no attribute 'is_package'          

My directory structure is:

> tree .
.
├── README.md
├── src
│   └── simplessl
│       ├── ca.py
│       ├── __main__.py
│       ├── req.py
│       └── utils.py
└── ssl.iml

i assume this is related to http://bugs.python.org/issue18058 but don't understand why this is not a bugfix that can be back-ported.  this appears to be a bug to me...
msg192801 - (view) Author: andrew cooke (acooke) Date: 2013-07-10 12:37
can't see how to edit posts, so adding as a comment, this is what triggers the bug:

> PYTHONPATH=src python -m simplessl
msg192802 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2013-07-10 12:41
You can't edit posts. :)

I was going to ask how you are running __main__ but you were faster than me.
msg192803 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2013-07-10 12:52
The solution from issue #18058 can't be backported because it would expose a new public API on the NamespaceLoader class. It would also introduce new functionality which would differ between Python 3.3.2 and Python 3.3.3 which can't really be classified as a bugfix since it's new functionality that didn't exist previously.

You're also not losing any abilities by not having this in Python 3.3. All it means is that the status quo holds compared to Python 3.2 in that normal packages are the only way to execute a package with __main__ defined, while Python 3.4 gains the ability to also support namespace packages.

Because of all of these points, I'm closing this issue as rejected (sorry; I know it would be handy to have but I just can't justify it).
msg192843 - (view) Author: andrew cooke (acooke) Date: 2013-07-10 23:05
in case anyone else ends up here through google...

the problem described here is not related to the linked issue.  it was just a missing `__init__.py` in the module (plus sucky error messages).

the following works fine:

.
├── README.md
├── src
│   └── simplessl                                                               
│       ├── ca.py                                                               
│       ├── __init__.py                                                         
│       ├── __main__.py                                                         
│       ├── req.py                                                              
│       └── utils.py                                                            
└── ssl.iml
History
Date User Action Args
2017-02-18 11:51:14ncoghlansetstage: resolved
2013-07-10 23:05:45acookesetmessages: + msg192843
2013-07-10 13:16:42barrysetnosy: + barry
2013-07-10 12:52:41brett.cannonsetstatus: open -> closed
versions: - Python 3.4
messages: + msg192803

dependencies: + Define is_package for NamespaceLoader
components: + Library (Lib), - Installation
resolution: rejected
2013-07-10 12:41:12christian.heimessetversions: + Python 3.4
nosy: + christian.heimes, brett.cannon

messages: + msg192802

assignee: brett.cannon
type: behavior
2013-07-10 12:37:47acookesetmessages: + msg192801
2013-07-10 12:36:24acookecreate