[issue36514] -m switch revisited

2019-04-03 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

Given a python script in a file named foo.py in the current directory:

* python -m foo  

  Should, and does, work.

* python -m foo.py

  Raises an error, because the command tries to run the submodule "py" of
  module "foo" as the __main__ module. For script files this will raise an
  error because module "foo" is not a package (hence the AttributeError about
  __path__).

  The error might get raised at the end of the script because the interpreter
  executes the module body on import before it looks for attributes and
  submodules.

* python foo

  Does not work because there is no file named "foo". This is expected 
  behaviour. 

* python foo.py

  Works because there is a file named foo.py. The interpreter executes the
  contents of the file.


"python NAME" and "python -m NAME" are not the same, which is why the two 
invocations behave differently. This is expected behaviour and not a bug.

See also "https://docs.python.org/3/using/cmdline.html#cmdoption-m";

--

___
Python tracker 

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



[issue36514] -m switch revisited

2019-04-03 Thread Colin Dick


Colin Dick  added the comment:

No, the first example is expected,
BUT the middle two work
HENCE the last should NOT have a problem either...
No?
Because the middle two work,
so should the last complete without any errors.
There were no code changes,
Therefore the problem is with python

On Wed, 3 Apr 2019, 23:42 Ronald Oussoren  wrote:

>
> Ronald Oussoren  added the comment:
>
> This is not a bug:
>
> * "python -m NAME" runs module (or package) NAME as a script, NAME should
> therefore be a module name and not a filename (and hence not have a .py
> suffix)
>
> * "python NAME" runs a script in file NAME and should therefore by a
> complete file name, including a suffix when the file name has a suffix.
>
> In your examples "python -m vixsd.py" and "python vixsd" correctly raise
> an error.
>
> --
> nosy: +ronaldoussoren
> resolution:  -> not a bug
> stage:  -> resolved
> status: open -> closed
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue36514] -m switch revisited

2019-04-03 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

This is not a bug:

* "python -m NAME" runs module (or package) NAME as a script, NAME should 
therefore be a module name and not a filename (and hence not have a .py suffix)

* "python NAME" runs a script in file NAME and should therefore by a complete 
file name, including a suffix when the file name has a suffix.

In your examples "python -m vixsd.py" and "python vixsd" correctly raise an 
error.

--
nosy: +ronaldoussoren
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue36514] -m switch revisited

2019-04-03 Thread SilentGhost


SilentGhost  added the comment:

Colin, sorry, are you reporting an issue? Because I have trouble understanding 
what is. The examples you've posted seem to work as expected, no?

--
nosy: +SilentGhost

___
Python tracker 

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



[issue36514] -m switch revisited

2019-04-02 Thread Colin Dick


New submission from Colin Dick :

-m switch revisited - see issue 27487
Win 10 64bit
python 3.6.3 & 3.7.3

initially running code using py 3.6.3 with this command
python -m vixsd.py
produced
C:\Python36\python.exe: Error while finding module specification for 'vixsd.py' 
(AttributeError: module 'vixsd' has no attribute '__path__')

updated python from 3.6.3 to 3.7.3

searched & read web
retried the 4 options with & without "-m" & ".py"
results reproduced below

c:\shared\python\vmw>python vixsd
python: can't open file 'vixsd': [Errno 2] No such file or directory

c:\shared\python\vmw>python vixsd.py
A

c:\shared\python\vmw>python -m vixsd
A

c:\shared\python\vmw>python -m vixsd.py
A
C:\Python3\python.exe: Error while finding module specification for 'vixsd.py' 
(ModuleNotFoundError: __path__ attribute not found on 'vixsd' while trying to 
find 'vixsd.py')

while this was initially produced thru my ignorance,
handling all 4 options still does not work correctly
appears to have been a problem at least since
issue 27487

cheers team, keep up the great work
ColinDNZ

--
messages: 339374
nosy: Colin Dick
priority: normal
severity: normal
status: open
title: -m switch revisited
type: behavior
versions: Python 3.7

___
Python tracker 

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