Skip to content

Commit 9e4edd6

Browse files
committed
Change newline format
1 parent f5a8474 commit 9e4edd6

File tree

3 files changed

+107
-107
lines changed

3 files changed

+107
-107
lines changed

src/examples/py2exe/hello.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import sys
2-
3-
from queens import main
4-
5-
main()
1+
import sys
2+
3+
from queens import main
4+
5+
main()

src/examples/py2exe/setup.py

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
# A very simple setup script to create 2 executables.
2-
#
3-
# hello.py is a simple "hello, world" type program, which alse allows
4-
# to explore the environment in which the script runs.
5-
#
6-
# test_wx.py is a simple wxPython program, it will be converted into a
7-
# console-less program.
8-
#
9-
# If you don't have wxPython installed, you should comment out the
10-
# windows = ["test_wx.py"]
11-
# line below.
12-
#
13-
#
14-
# Run the build process by entering 'setup.py py2exe' or
15-
# 'python setup.py py2exe' in a console prompt.
16-
#
17-
# If everything works well, you should find a subdirectory named 'dist'
18-
# containing some files, among them hello.exe and test_wx.exe.
19-
20-
21-
from distutils.core import setup
22-
import py2exe
23-
24-
setup(
25-
# The first three parameters are not required, if at least a
26-
# 'version' is given, then a versioninfo resource is built from
27-
# them and added to the executables.
28-
version = "0.5.0",
29-
description = "py2exe sample script",
30-
name = "py2exe samples",
31-
32-
# targets to build
33-
# windows = ["test_wx.py"],
34-
console = ["hello.py"],
35-
py_modules = ["queens"],
36-
)
1+
# A very simple setup script to create 2 executables.
2+
#
3+
# hello.py is a simple "hello, world" type program, which alse allows
4+
# to explore the environment in which the script runs.
5+
#
6+
# test_wx.py is a simple wxPython program, it will be converted into a
7+
# console-less program.
8+
#
9+
# If you don't have wxPython installed, you should comment out the
10+
# windows = ["test_wx.py"]
11+
# line below.
12+
#
13+
#
14+
# Run the build process by entering 'setup.py py2exe' or
15+
# 'python setup.py py2exe' in a console prompt.
16+
#
17+
# If everything works well, you should find a subdirectory named 'dist'
18+
# containing some files, among them hello.exe and test_wx.exe.
19+
20+
21+
from distutils.core import setup
22+
import py2exe
23+
24+
setup(
25+
# The first three parameters are not required, if at least a
26+
# 'version' is given, then a versioninfo resource is built from
27+
# them and added to the executables.
28+
version = "0.5.0",
29+
description = "py2exe sample script",
30+
name = "py2exe samples",
31+
32+
# targets to build
33+
# windows = ["test_wx.py"],
34+
console = ["hello.py"],
35+
py_modules = ["queens"],
36+
)

src/examples/testmod/hello.py

Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,66 @@
1-
import dis
2-
import os
3-
import sys
4-
5-
# Import function and class from obfuscated module
6-
from queens import main, Queens
7-
8-
# Call obfuscated function
9-
main()
10-
11-
# Check __file__ of obfuscated module "queens" is filename in target machine
12-
import queens
13-
if os.path.abspath(queens.__file__) == os.path.abspath(os.path.join(os.path.dirname(__file__), "queens.py")):
14-
print("The value of __file__ is OK")
15-
16-
# Check __wraparmor__ can't be called out of decorator
17-
try:
18-
from builtins import __wraparmor__
19-
except Exception:
20-
from __builtin__ import __wraparmor__
21-
try:
22-
__wraparmor__(main)
23-
except Exception as e:
24-
print('__wraparmor__ can not be called out of decorator')
25-
26-
# Check filename in trackback
27-
try:
28-
queens.test_exception()
29-
except Exception:
30-
from traceback import print_exc
31-
print_exc()
32-
33-
# Check original func can not be got from exception frame
34-
try:
35-
queens.test_exception()
36-
except Exception:
37-
import inspect
38-
for exc_tb in inspect.trace():
39-
frame = exc_tb[0]
40-
print('Found frame of function %s' % exc_tb[3])
41-
if frame.f_locals.get('func') is None \
42-
and frame.f_locals.get('filename') is None \
43-
and frame.f_locals.get('n') is None:
44-
print('Can not get data from frame.f_locals')
45-
46-
# Check callback
47-
def mycallback():
48-
frame = sys._getframe(1)
49-
if len(frame.f_locals) == 0:
50-
print('Got empty from callback')
51-
queens.test_callback(mycallback)
52-
53-
# Check generator
54-
a = list(queens.simple_generator(10))
55-
if len(a) == 10:
56-
print('Generator works well')
57-
58-
# Check nested
59-
func1 = queens.factory()
60-
func2 = queens.factory()
61-
func1(func2)
62-
print('Shared code object works well')
63-
64-
# Access original func_code will crash: Segmentation fault
65-
# print(dis.dis(main.orig_func))
66-
# print(dis.dis(Queens.solve.orig_func))
1+
import dis
2+
import os
3+
import sys
4+
5+
# Import function and class from obfuscated module
6+
from queens import main, Queens
7+
8+
# Call obfuscated function
9+
main()
10+
11+
# Check __file__ of obfuscated module "queens" is filename in target machine
12+
import queens
13+
if os.path.abspath(queens.__file__) == os.path.abspath(os.path.join(os.path.dirname(__file__), "queens.py")):
14+
print("The value of __file__ is OK")
15+
16+
# Check __wraparmor__ can't be called out of decorator
17+
try:
18+
from builtins import __wraparmor__
19+
except Exception:
20+
from __builtin__ import __wraparmor__
21+
try:
22+
__wraparmor__(main)
23+
except Exception as e:
24+
print('__wraparmor__ can not be called out of decorator')
25+
26+
# Check filename in trackback
27+
try:
28+
queens.test_exception()
29+
except Exception:
30+
from traceback import print_exc
31+
print_exc()
32+
33+
# Check original func can not be got from exception frame
34+
try:
35+
queens.test_exception()
36+
except Exception:
37+
import inspect
38+
for exc_tb in inspect.trace():
39+
frame = exc_tb[0]
40+
print('Found frame of function %s' % exc_tb[3])
41+
if frame.f_locals.get('func') is None \
42+
and frame.f_locals.get('filename') is None \
43+
and frame.f_locals.get('n') is None:
44+
print('Can not get data from frame.f_locals')
45+
46+
# Check callback
47+
def mycallback():
48+
frame = sys._getframe(1)
49+
if len(frame.f_locals) == 0:
50+
print('Got empty from callback')
51+
queens.test_callback(mycallback)
52+
53+
# Check generator
54+
a = list(queens.simple_generator(10))
55+
if len(a) == 10:
56+
print('Generator works well')
57+
58+
# Check nested
59+
func1 = queens.factory()
60+
func2 = queens.factory()
61+
func1(func2)
62+
print('Shared code object works well')
63+
64+
# Access original func_code will crash: Segmentation fault
65+
# print(dis.dis(main.orig_func))
66+
# print(dis.dis(Queens.solve.orig_func))

0 commit comments

Comments
 (0)