| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9ae0994 commit 4114a4a
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + # This file exists as a helper for the test.test_frozen module. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,4 @@ | |||
| 1 | + test_frozen | ||
| 2 | + Hello world... | ||
| 3 | + Hello world... | ||
| 4 | + Hello world... | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,26 @@ | |||
| 1 | + # Test the frozen module defined in frozen.c. | ||
| 2 | + | ||
| 3 | + from test_support import TestFailed | ||
| 4 | + import sys, os | ||
| 5 | + | ||
| 6 | + try: | ||
| 7 | + import __hello__ | ||
| 8 | + except ImportError, x: | ||
| 9 | + raise TestFailed, "import __hello__ failed:", x | ||
| 10 | + | ||
| 11 | + try: | ||
| 12 | + import __phello__ | ||
| 13 | + except ImportError, x: | ||
| 14 | + raise TestFailed, "import __phello__ failed:", x | ||
| 15 | + | ||
| 16 | + try: | ||
| 17 | + import __phello__.spam | ||
| 18 | + except ImportError, x: | ||
| 19 | + raise TestFailed, "import __phello__.spam failed:", x | ||
| 20 | + | ||
| 21 | + try: | ||
| 22 | + import __phello__.foo | ||
| 23 | + except ImportError: | ||
| 24 | + pass | ||
| 25 | + else: | ||
| 26 | + raise TestFailed, "import __phello__.foo should have failed" | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,21 +7,28 @@ | |||
| 7 | 7 | define a single frozen module, __hello__. Loading it will print | |
| 8 | 8 | some famous words... */ | |
| 9 | 9 | ||
| 10 | + /* To regenerate this data after the bytecode or marshal format has changed, | ||
| 11 | + go to ../Tools/freeze/ and freeze the hello.py file; then copy and paste | ||
| 12 | + the appropriate bytes from M___main__.c. */ | ||
| 13 | + | ||
| 10 | 14 | static unsigned char M___hello__[] = { | |
| 11 | 15 | 99,0,0,0,0,1,0,0,0,115,15,0,0,0,127,0, | |
| 12 | 16 | 0,127,1,0,100,0,0,71,72,100,1,0,83,40,2,0, | |
| 13 | 17 | 0,0,115,14,0,0,0,72,101,108,108,111,32,119,111,114, | |
| 14 | 18 | 108,100,46,46,46,78,40,0,0,0,0,40,0,0,0,0, | |
| 15 | - 115,8,0,0,0,104,101,108,108,111,46,112,121,115,1,0, | ||
| 16 | - 0,0,63,1,0,115,0,0,0,0, | ||
| 19 | + 40,0,0,0,0,40,0,0,0,0,115,8,0,0,0,104, | ||
| 20 | + 101,108,108,111,46,112,121,115,1,0,0,0,63,1,0,115, | ||
| 21 | + 0,0,0,0, | ||
| 17 | 22 | }; | |
| 18 | 23 | ||
| 24 | + #define SIZE sizeof(M___hello__) | ||
| 25 | + | ||
| 19 | 26 | static struct _frozen _PyImport_FrozenModules[] = { | |
| 20 | 27 | /* Test module */ | |
| 21 | - {"__hello__", M___hello__, 90}, | ||
| 28 | + {"__hello__", M___hello__, SIZE}, | ||
| 22 | 29 | /* Test package (negative size indicates package-ness) */ | |
| 23 | - {"__phello__", M___hello__, -90}, | ||
| 24 | - {"__phello__.spam", M___hello__, 90}, | ||
| 30 | + {"__phello__", M___hello__, -SIZE}, | ||
| 31 | + {"__phello__.spam", M___hello__, SIZE}, | ||
| 25 | 32 | {0, 0, 0} /* sentinel */ | |
| 26 | 33 | }; | |
| 27 | 34 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments