Skip to content

Regression: Importing __hello__ doesn't print "Hello world!" #100136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hugovk opened this issue Dec 9, 2022 · 4 comments
Closed

Regression: Importing __hello__ doesn't print "Hello world!" #100136

hugovk opened this issue Dec 9, 2022 · 4 comments
Labels
3.11 only security fixes 3.12 only security fixes type-bug An unexpected behavior, bug, or error

Comments

@hugovk
Copy link
Member

hugovk commented Dec 9, 2022

Bug report

Importing __hello__ or __phello__ on Python 3.7-3.10 prints "Hello world!"

Importing __hello__ or __phello__ on Python 3.11-3.12 prints nothing.

$ python3.7
Python 3.7.13 (default, Jul  8 2022, 20:05:46)
[Clang 13.1.6 (clang-1316.0.21.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import __hello__
Hello world!
>>> import __phello__
Hello world!
>>>
$ python3.8
Python 3.8.13 (default, Apr 26 2022, 16:12:31)
[Clang 13.1.6 (clang-1316.0.21.2.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import __hello__
Hello world!
>>> import __phello__
Hello world!
>>>
$ python3.9
Python 3.9.13 (main, May 24 2022, 21:13:51)
[Clang 13.1.6 (clang-1316.0.21.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import __hello__
Hello world!
>>> import __phello__
Hello world!
>>>
$ python3.10
Python 3.10.6 (main, Aug 30 2022, 04:58:14) [Clang 13.1.6 (clang-1316.0.21.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import __hello__
Hello world!
>>> import __phello__
Hello world!
>>>
$ python3.11
Python 3.11.1 (v3.11.1:a7a450f84a, Dec  6 2022, 15:24:06) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import __hello__
>>> import __phello__
>>> ^D
$ python3.12
Python 3.12.0a3 (v3.12.0a3:b6bd7ffcbc, Dec  6 2022, 15:26:51) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import __hello__
>>> import __phello__
>>> ^D

And at least as early as 3.11.0a2:

$ ./python.exe
Python 3.11.0a2 (tags/v3.11.0a2:e2b4e4bab9, Dec  9 2022, 16:19:07) [Clang 14.0.0 (clang-1400.0.29.102)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import __phello__
>>> import __hello__
>>>

(I couldn't build 3.11.0a1)

Your environment

  • CPython versions tested on: 3.7.13, 3.8.13, 3.9.13, 3.10.6, 3.11.0a2, 3.11.1, 3.12.0a3
  • Operating system and architecture: macOS M1
@hugovk hugovk added type-bug An unexpected behavior, bug, or error 3.11 only security fixes 3.12 only security fixes labels Dec 9, 2022
@eryksun
Copy link
Contributor

eryksun commented Dec 9, 2022

The behavior was intentionally changed by issue #89182 and pull request #28374. __hello__ and __phello__.spam still print to sys.stdout when run as scripts. When imported, main() has to be called. For example:

>>> import __hello__
>>> __hello__.main()
Hello world!
>>> import __phello__.spam
>>> __phello__.main()
Hello world!
>>> __phello__.spam.main()
Hello world!

@hugovk
Copy link
Member Author

hugovk commented Dec 9, 2022

Okay, thanks.

I saw the old, short and simple version on a list of Python Easter eggs:

https://github.com/OrkoHunter/python-easter-eggs

And searching for Python Easter eggs it often shows up as the first one such as 'The Easiest “Hello World”':

It's less exciting in the new form.

But fine by me if you'd like to close this as correct behaviour.

@eryksun
Copy link
Contributor

eryksun commented Dec 9, 2022

At least import this still prints the text of "The Zen of Python".

@eryksun eryksun closed this as not planned Won't fix, can't repro, duplicate, stale Dec 9, 2022
@zware
Copy link
Member

zware commented Dec 9, 2022

How badly would it break the tests that depend on __hello__ to also call main() if sys.ps1 has a value? Is it worth saving the easter egg? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11 only security fixes 3.12 only security fixes type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants