From ad20a404a91d425eadd9831ffe0ee3d3d2342771 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Fri, 24 Feb 2023 14:48:34 +0900 Subject: [PATCH] Update __hello__ and __phello__ from cpython --- Lib/__hello__.py | 16 ++++++++++++++++ Lib/__phello__/__init__.py | 7 +++++++ Lib/__phello__/ham/__init__.py | 0 Lib/__phello__/ham/eggs.py | 0 Lib/__phello__/spam.py | 7 +++++++ vm/Lib/python_builtins/__hello__.py | 1 + vm/Lib/python_builtins/__phello__ | 1 + vm/src/frozen.rs | 11 ++++++----- 8 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 Lib/__hello__.py create mode 100644 Lib/__phello__/__init__.py create mode 100644 Lib/__phello__/ham/__init__.py create mode 100644 Lib/__phello__/ham/eggs.py create mode 100644 Lib/__phello__/spam.py create mode 120000 vm/Lib/python_builtins/__hello__.py create mode 120000 vm/Lib/python_builtins/__phello__ diff --git a/Lib/__hello__.py b/Lib/__hello__.py new file mode 100644 index 0000000000..c09d6a4f52 --- /dev/null +++ b/Lib/__hello__.py @@ -0,0 +1,16 @@ +initialized = True + +class TestFrozenUtf8_1: + """\u00b6""" + +class TestFrozenUtf8_2: + """\u03c0""" + +class TestFrozenUtf8_4: + """\U0001f600""" + +def main(): + print("Hello world!") + +if __name__ == '__main__': + main() diff --git a/Lib/__phello__/__init__.py b/Lib/__phello__/__init__.py new file mode 100644 index 0000000000..d37bd2766a --- /dev/null +++ b/Lib/__phello__/__init__.py @@ -0,0 +1,7 @@ +initialized = True + +def main(): + print("Hello world!") + +if __name__ == '__main__': + main() diff --git a/Lib/__phello__/ham/__init__.py b/Lib/__phello__/ham/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Lib/__phello__/ham/eggs.py b/Lib/__phello__/ham/eggs.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Lib/__phello__/spam.py b/Lib/__phello__/spam.py new file mode 100644 index 0000000000..d37bd2766a --- /dev/null +++ b/Lib/__phello__/spam.py @@ -0,0 +1,7 @@ +initialized = True + +def main(): + print("Hello world!") + +if __name__ == '__main__': + main() diff --git a/vm/Lib/python_builtins/__hello__.py b/vm/Lib/python_builtins/__hello__.py new file mode 120000 index 0000000000..f6cae8932f --- /dev/null +++ b/vm/Lib/python_builtins/__hello__.py @@ -0,0 +1 @@ +../../../Lib/__hello__.py \ No newline at end of file diff --git a/vm/Lib/python_builtins/__phello__ b/vm/Lib/python_builtins/__phello__ new file mode 120000 index 0000000000..113aeb1504 --- /dev/null +++ b/vm/Lib/python_builtins/__phello__ @@ -0,0 +1 @@ +../../../Lib/__phello__ \ No newline at end of file diff --git a/vm/src/frozen.rs b/vm/src/frozen.rs index 44bcf23c57..8c809aa372 100644 --- a/vm/src/frozen.rs +++ b/vm/src/frozen.rs @@ -11,11 +11,12 @@ pub fn core_frozen_inits() -> impl Iterator { }; } - ext_modules!( - iter, - source = "initialized = True; print(\"Hello world!\")\n", - module_name = "__hello__", - ); + // keep as example but use file one now + // ext_modules!( + // iter, + // source = "initialized = True; print(\"Hello world!\")\n", + // module_name = "__hello__", + // ); // Python modules that the vm calls into, but are not actually part of the stdlib. They could // in theory be implemented in Rust, but are easiest to do in Python for one reason or another.