This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Incorrect __name__ assignment
Type: Stage:
Components: macOS Versions: Python 2.3
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: jackjansen Nosy List: elcepi, jackjansen, mwh, terry.reedy
Priority: normal Keywords:

Created on 2004-03-26 00:43 by elcepi, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test.py elcepi, 2004-03-26 00:43 Example file
Messages (6)
msg20318 - (view) Author: El cepi (elcepi) Date: 2004-03-26 00:43
When you use PythonLauncher or PythonIDE the value of 
__name__ is incorrectly assigned.

For example, in the attached file the output is "The module 
has been load" when the module is fun in PythonIDE.

With this you can not disciminate between the code you 
should run when you load the module and when you try to 
run it.

msg20319 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2004-03-30 17:14
Logged In: YES 
user_id=593130

When making a bug report, please include at least the Python 
version.  The system you are running on is sometimes 
essential info also.

I am not familiar with either PythonLauncher or PythonIDE.  
Just PyWin and Idle.  If they are third-party items not part of 
the distribution, then this report should go to their authors.

'When you use' is also somewhat vague.  Saying what 
command line option or menu entry or buttom you used to 
run/load might also get a better answer.
msg20320 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2004-03-31 10:56
Logged In: YES 
user_id=6656

Terry, this bug is in the 'Macintosh' category for a reason :-)
msg20321 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2004-03-31 15:07
Logged In: YES 
user_id=593130

Lesson learned to check that header field.  Inappropriate 
comments withdrawn.
msg20322 - (view) Author: El cepi (elcepi) Date: 2004-03-31 19:14
Logged In: YES 
user_id=1006669

No problem tjreedy

Here are the version information relevant to the report

* PythonIDE
  Version 1.0.1
  Python 2.3.3 (#1 March 12 2004, 13:49:58)
  GCC 3.1 20020420 (prerelease)

* PythonLauncher
  Version 0.1

* Mac OS X 
  Version 10.2.8 (6R73) 
  Darwin Kernel Version 6.8: Wed Sep 10 15:20:55 PDT 2003;
       root:xnu/xnu-344.49.obj~2/RELEASE_PPC

* Machine
  PowerBook G4 (version = 11.3)

This bug cause that your applications behave different when are 
executed from PythonLauncher or PythonIDE than from the shell 

For example, If I double-click the foo.pyc file it is executed by 
PythonLauncher but it execute the code under __name__==’test’ 
instead of under __name__==’__main__’ as append when I run it 
from the shell.
msg20323 - (view) Author: Jack Jansen (jackjansen) * (Python committer) Date: 2004-06-02 21:28
Logged In: YES 
user_id=45365

First off: sorry for not replying sooner, I hadn't seen the bug report.

Second: I don't think this is a bug:-)
In the case of running the script in the PythonIDE: if you want the script 
to be run as a main program you need to check the "Run as __main__" 
menu entry (in the run options popup menu, at the top of the vertical 
scrollbar).

In the case of running the script with PythonLauncher I don't see the 
problem: for me it prints "The module has been run".

If there's a scenario whereby running with PythonLauncher does print 
"The module has been load": please reopen the bug report and provide a 
scenario.
History
Date User Action Args
2022-04-11 14:56:03adminsetgithub: 40082
2004-03-26 00:43:41elcepicreate