Fix test_frozen.

This commit is contained in:
Guido van Rossum 2007-02-09 23:27:01 +00:00
parent 79139b247b
commit 96bf7e8a37
8 changed files with 87 additions and 87 deletions

View File

@ -12,14 +12,15 @@
the appropriate bytes from M___main__.c. */
static unsigned char M___hello__[] = {
99,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,
0,64,0,0,0,115,9,0,0,0,100,0,0,71,72,100,
1,0,83,40,2,0,0,0,115,14,0,0,0,72,101,108,
108,111,32,119,111,114,108,100,46,46,46,78,40,0,0,0,
0,40,0,0,0,0,40,0,0,0,0,40,0,0,0,0,
115,8,0,0,0,104,101,108,108,111,46,112,121,115,8,0,
0,0,60,109,111,100,117,108,101,62,1,0,0,0,115,0,
0,0,0,
99,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,
0,64,0,0,0,115,14,0,0,0,101,0,0,100,0,0,
131,1,0,1,100,1,0,83,40,2,0,0,0,115,14,0,
0,0,72,101,108,108,111,32,119,111,114,108,100,46,46,46,
78,40,1,0,0,0,116,5,0,0,0,112,114,105,110,116,
40,0,0,0,0,40,0,0,0,0,40,0,0,0,0,115,
8,0,0,0,104,101,108,108,111,46,112,121,115,8,0,0,
0,60,109,111,100,117,108,101,62,1,0,0,0,115,0,0,
0,0,
};
#define SIZE (int)sizeof(M___hello__)

View File

@ -25,7 +25,6 @@ class _BkFile:
self.readline = self.__file.readline
self.readlines = self.__file.readlines
self.seek = self.__file.seek
self.softspace = self.__file.softspace
self.tell = self.__file.tell
self.truncate = self.__file.truncate
self.write = self.__file.write

View File

@ -162,7 +162,7 @@ def main():
# proces option arguments
for o, a in opts:
if o == '-h':
print __doc__
print(__doc__)
return
if o == '-d':
debug = debug + 1
@ -222,7 +222,7 @@ def main():
if win:
extensions_c = 'frozen_extensions.c'
if ishome:
print "(Using Python source directory)"
print("(Using Python source directory)")
binlib = exec_prefix
incldir = os.path.join(prefix, 'Include')
config_h_dir = exec_prefix
@ -310,7 +310,7 @@ def main():
if odir and not os.path.isdir(odir):
try:
os.mkdir(odir)
print "Created output directory", odir
print("Created output directory", odir)
except os.error as msg:
usage('%s: mkdir failed (%s)' % (odir, str(msg)))
base = ''
@ -371,7 +371,7 @@ def main():
if debug > 0:
mf.report()
print
print()
dict = mf.modules
if error_if_any_missing:
@ -479,18 +479,18 @@ def main():
# Done!
if odir:
print 'Now run "make" in', odir,
print 'to build the target:', base_target
print('Now run "make" in', odir, end=' ')
print('to build the target:', base_target)
else:
print 'Now run "make" to build the target:', base_target
print('Now run "make" to build the target:', base_target)
# Print usage message and exit
def usage(msg):
sys.stdout = sys.stderr
print "Error:", msg
print "Use ``%s -h'' for help" % sys.argv[0]
print("Error:", msg)
print("Use ``%s -h'' for help" % sys.argv[0])
sys.exit(2)

View File

@ -1 +1 @@
print 'Hello world...'
print('Hello world...')

View File

@ -40,8 +40,8 @@ def makeconfig(infp, outfp, modules, with_ifdef=0):
def test():
import sys
if not sys.argv[3:]:
print 'usage: python makeconfig.py config.c.in outputfile',
print 'modulename ...'
print('usage: python makeconfig.py config.c.in outputfile', end=' ')
print('modulename ...')
sys.exit(2)
if sys.argv[1] == '-':
infp = sys.stdin

View File

@ -43,7 +43,7 @@ def makefreeze(base, dict, debug=0, entry_point=None, fail_import=()):
outfp = bkfile.open(base + file, 'w')
files.append(file)
if debug:
print "freezing", mod, "..."
print("freezing", mod, "...")
str = marshal.dumps(m.__code__)
size = len(str)
if m.__path__:
@ -53,7 +53,7 @@ def makefreeze(base, dict, debug=0, entry_point=None, fail_import=()):
writecode(outfp, mangled, str)
outfp.close()
if debug:
print "generating table of frozen modules"
print("generating table of frozen modules")
outfp = bkfile.open(base + 'frozen.c', 'w')
for mod, mangled, size in done:
outfp.write('extern unsigned char M_%s[];\n' % mangled)

View File

@ -84,29 +84,29 @@ def test():
import sys
import os
if not sys.argv[1:]:
print 'usage: python parsesetup.py Makefile*|Setup* ...'
print('usage: python parsesetup.py Makefile*|Setup* ...')
sys.exit(2)
for arg in sys.argv[1:]:
base = os.path.basename(arg)
if base[:8] == 'Makefile':
print 'Make style parsing:', arg
print('Make style parsing:', arg)
v = getmakevars(arg)
prdict(v)
elif base[:5] == 'Setup':
print 'Setup style parsing:', arg
print('Setup style parsing:', arg)
m, v = getsetupinfo(arg)
prdict(m)
prdict(v)
else:
print arg, 'is neither a Makefile nor a Setup file'
print '(name must begin with "Makefile" or "Setup")'
print(arg, 'is neither a Makefile nor a Setup file')
print('(name must begin with "Makefile" or "Setup")')
def prdict(d):
keys = d.keys()
keys.sort()
for key in keys:
value = d[key]
print "%-15s" % key, str(value)
print("%-15s" % key, str(value))
if __name__ == '__main__':
test()

View File

@ -52,29 +52,29 @@ def makemakefile(outfp, vars, files, target):
def realwork(vars, moddefns, target):
version_suffix = "%r%r" % sys.version_info[:2]
print "# Makefile for Microsoft Visual C++ generated by freeze.py script"
print
print 'target = %s' % target
print 'pythonhome = %s' % vars['prefix']
print
print 'DEBUG=0 # Set to 1 to use the _d versions of Python.'
print '!IF $(DEBUG)'
print 'debug_suffix=_d'
print 'c_debug=/Zi /Od /DDEBUG /D_DEBUG'
print 'l_debug=/DEBUG'
print 'temp_dir=Build\\Debug'
print '!ELSE'
print 'debug_suffix='
print 'c_debug=/Ox'
print 'l_debug='
print 'temp_dir=Build\\Release'
print '!ENDIF'
print
print("# Makefile for Microsoft Visual C++ generated by freeze.py script")
print()
print('target = %s' % target)
print('pythonhome = %s' % vars['prefix'])
print()
print('DEBUG=0 # Set to 1 to use the _d versions of Python.')
print('!IF $(DEBUG)')
print('debug_suffix=_d')
print('c_debug=/Zi /Od /DDEBUG /D_DEBUG')
print('l_debug=/DEBUG')
print('temp_dir=Build\\Debug')
print('!ELSE')
print('debug_suffix=')
print('c_debug=/Ox')
print('l_debug=')
print('temp_dir=Build\\Release')
print('!ENDIF')
print()
print '# The following line assumes you have built Python using the standard instructions'
print '# Otherwise fix the following line to point to the library.'
print 'pythonlib = "$(pythonhome)/pcbuild/python%s$(debug_suffix).lib"' % version_suffix
print
print('# The following line assumes you have built Python using the standard instructions')
print('# Otherwise fix the following line to point to the library.')
print('pythonlib = "$(pythonhome)/pcbuild/python%s$(debug_suffix).lib"' % version_suffix)
print()
# We only ever write one "entry point" symbol - either
# "main" or "WinMain". Therefore, there is no need to
@ -88,59 +88,59 @@ def realwork(vars, moddefns, target):
target_ext = ".dll"
print "# As the target uses Python%s.dll, we must use this compiler option!" % version_suffix
print "cdl = /MD"
print
print "all: $(target)$(debug_suffix)%s" % (target_ext)
print
print("# As the target uses Python%s.dll, we must use this compiler option!" % version_suffix)
print("cdl = /MD")
print()
print("all: $(target)$(debug_suffix)%s" % (target_ext))
print()
print '$(temp_dir):'
print ' if not exist $(temp_dir)\. mkdir $(temp_dir)'
print
print('$(temp_dir):')
print(' if not exist $(temp_dir)\. mkdir $(temp_dir)')
print()
objects = []
libs = ["shell32.lib", "comdlg32.lib", "wsock32.lib", "user32.lib", "oleaut32.lib"]
for moddefn in moddefns:
print "# Module", moddefn.name
print("# Module", moddefn.name)
for file in moddefn.sourceFiles:
base = os.path.basename(file)
base, ext = os.path.splitext(base)
objects.append(base + ".obj")
print '$(temp_dir)\%s.obj: "%s"' % (base, file)
print "\t@$(CC) -c -nologo /Fo$* $(cdl) $(c_debug) /D BUILD_FREEZE",
print '"-I$(pythonhome)/Include" "-I$(pythonhome)/PC" \\'
print "\t\t$(cflags) $(cdebug) $(cinclude) \\"
print('$(temp_dir)\%s.obj: "%s"' % (base, file))
print("\t@$(CC) -c -nologo /Fo$* $(cdl) $(c_debug) /D BUILD_FREEZE", end=' ')
print('"-I$(pythonhome)/Include" "-I$(pythonhome)/PC" \\')
print("\t\t$(cflags) $(cdebug) $(cinclude) \\")
extra = moddefn.GetCompilerOptions()
if extra:
print "\t\t%s \\" % (' '.join(extra),)
print '\t\t"%s"' % file
print
print("\t\t%s \\" % (' '.join(extra),))
print('\t\t"%s"' % file)
print()
# Add .lib files this module needs
for modlib in moddefn.GetLinkerLibs():
if modlib not in libs:
libs.append(modlib)
print "ADDN_LINK_FILES=",
for addn in vars['addn_link']: print '"%s"' % (addn),
print ; print
print("ADDN_LINK_FILES=", end=' ')
for addn in vars['addn_link']: print('"%s"' % (addn), end=' ')
print() ; print()
print "OBJS=",
for obj in objects: print '"$(temp_dir)\%s"' % (obj),
print ; print
print("OBJS=", end=' ')
for obj in objects: print('"$(temp_dir)\%s"' % (obj), end=' ')
print() ; print()
print "LIBS=",
for lib in libs: print '"%s"' % (lib),
print ; print
print("LIBS=", end=' ')
for lib in libs: print('"%s"' % (lib), end=' ')
print() ; print()
print "$(target)$(debug_suffix)%s: $(temp_dir) $(OBJS)" % (target_ext)
print "\tlink -out:$(target)$(debug_suffix)%s %s" % (target_ext, target_link_flags),
print "\t$(OBJS) \\"
print "\t$(LIBS) \\"
print "\t$(ADDN_LINK_FILES) \\"
print "\t$(pythonlib) $(lcustom) $(l_debug)\\"
print "\t$(resources)"
print
print "clean:"
print "\t-rm -f *.obj"
print "\t-rm -f $(target).exe"
print("$(target)$(debug_suffix)%s: $(temp_dir) $(OBJS)" % (target_ext))
print("\tlink -out:$(target)$(debug_suffix)%s %s" % (target_ext, target_link_flags), end=' ')
print("\t$(OBJS) \\")
print("\t$(LIBS) \\")
print("\t$(ADDN_LINK_FILES) \\")
print("\t$(pythonlib) $(lcustom) $(l_debug)\\")
print("\t$(resources)")
print()
print("clean:")
print("\t-rm -f *.obj")
print("\t-rm -f $(target).exe")