Commit 05f66a91 authored by Guido van Rossum's avatar Guido van Rossum

Minimal changes to make the "freeze" tool work again.

There are other issues left, but these were basics (e.g. keys().sort()).
parent 96c56ecc
...@@ -265,24 +265,19 @@ cleanup: ...@@ -265,24 +265,19 @@ cleanup:
PyObject * PyObject *
PyFile_FromFile(FILE *fp, char *name, char *mode, int (*close)(FILE *)) PyFile_FromFile(FILE *fp, char *name, char *mode, int (*close)(FILE *))
{ {
PyErr_SetString(PyExc_SystemError, PyObject *io = NULL, *stream = NULL;
"attempt to create old file from FILE *");
io = PyImport_ImportModule("io");
if (io == NULL)
return NULL; return NULL;
#if 0 stream = PyObject_CallMethod(io, "open", "ss", name, mode);
PyFileObject *f = (PyFileObject *)PyFile_Type.tp_new(&PyFile_Type, if (stream == NULL) {
NULL, NULL); Py_XDECREF(io);
if (f != NULL) {
PyObject *o_name = PyString_FromString(name);
if (o_name == NULL)
return NULL; return NULL;
if (fill_file_fields(f, fp, o_name, mode, close) == NULL) {
Py_DECREF(f);
f = NULL;
}
Py_DECREF(o_name);
} }
return (PyObject *) f; if (close != NULL)
#endif close(fp);
return stream;
} }
PyObject * PyObject *
......
...@@ -193,8 +193,11 @@ PyAST_FromNode(const node *n, PyCompilerFlags *flags, const char *filename, ...@@ -193,8 +193,11 @@ PyAST_FromNode(const node *n, PyCompilerFlags *flags, const char *filename,
if (flags && flags->cf_flags & PyCF_SOURCE_IS_UTF8) { if (flags && flags->cf_flags & PyCF_SOURCE_IS_UTF8) {
c.c_encoding = "utf-8"; c.c_encoding = "utf-8";
if (TYPE(n) == encoding_decl) { if (TYPE(n) == encoding_decl) {
#if 0
ast_error(n, "encoding declaration in Unicode string"); ast_error(n, "encoding declaration in Unicode string");
goto error; goto error;
#endif
n = CHILD(n, 0);
} }
} else if (TYPE(n) == encoding_decl) { } else if (TYPE(n) == encoding_decl) {
c.c_encoding = STR(n); c.c_encoding = STR(n);
......
...@@ -21,7 +21,10 @@ class _BkFile: ...@@ -21,7 +21,10 @@ class _BkFile:
self.mode = self.__file.mode self.mode = self.__file.mode
self.name = self.__file.name self.name = self.__file.name
self.read = self.__file.read self.read = self.__file.read
try:
self.readinto = self.__file.readinto self.readinto = self.__file.readinto
except AttributeError:
pass
self.readline = self.__file.readline self.readline = self.__file.readline
self.readlines = self.__file.readlines self.readlines = self.__file.readlines
self.seek = self.__file.seek self.seek = self.__file.seek
......
...@@ -386,8 +386,7 @@ def main(): ...@@ -386,8 +386,7 @@ def main():
# look for unfrozen modules (builtin and of unknown origin) # look for unfrozen modules (builtin and of unknown origin)
builtins = [] builtins = []
unknown = [] unknown = []
mods = dict.keys() mods = sorted(dict.keys())
mods.sort()
for mod in mods: for mod in mods:
if dict[mod].__code__: if dict[mod].__code__:
continue continue
......
...@@ -33,8 +33,7 @@ def makefreeze(base, dict, debug=0, entry_point=None, fail_import=()): ...@@ -33,8 +33,7 @@ def makefreeze(base, dict, debug=0, entry_point=None, fail_import=()):
if entry_point is None: entry_point = default_entry_point if entry_point is None: entry_point = default_entry_point
done = [] done = []
files = [] files = []
mods = dict.keys() mods = sorted(dict.keys())
mods.sort()
for mod in mods: for mod in mods:
m = dict[mod] m = dict[mod]
mangled = "__".join(mod.split(".")) mangled = "__".join(mod.split("."))
...@@ -81,8 +80,8 @@ def writecode(outfp, mod, str): ...@@ -81,8 +80,8 @@ def writecode(outfp, mod, str):
outfp.write('unsigned char M_%s[] = {' % mod) outfp.write('unsigned char M_%s[] = {' % mod)
for i in range(0, len(str), 16): for i in range(0, len(str), 16):
outfp.write('\n\t') outfp.write('\n\t')
for c in str[i:i+16]: for c in bytes(str[i:i+16]):
outfp.write('%d,' % ord(c)) outfp.write('%d,' % c)
outfp.write('\n};\n') outfp.write('\n};\n')
## def writecode(outfp, mod, str): ## def writecode(outfp, mod, str):
......
...@@ -5,8 +5,7 @@ import os ...@@ -5,8 +5,7 @@ import os
def makemakefile(outfp, makevars, files, target): def makemakefile(outfp, makevars, files, target):
outfp.write("# Makefile generated by freeze.py script\n\n") outfp.write("# Makefile generated by freeze.py script\n\n")
keys = makevars.keys() keys = sorted(makevars.keys())
keys.sort()
for key in keys: for key in keys:
outfp.write("%s=%s\n" % (key, makevars[key])) outfp.write("%s=%s\n" % (key, makevars[key]))
outfp.write("\nall: %s\n\n" % target) outfp.write("\nall: %s\n\n" % target)
......
...@@ -102,8 +102,7 @@ def test(): ...@@ -102,8 +102,7 @@ def test():
print('(name must begin with "Makefile" or "Setup")') print('(name must begin with "Makefile" or "Setup")')
def prdict(d): def prdict(d):
keys = d.keys() keys = sorted(d.keys())
keys.sort()
for key in keys: for key in keys:
value = d[key] value = d[key]
print("%-15s" % key, str(value)) print("%-15s" % key, str(value))
......
...@@ -24,6 +24,9 @@ mkdir -p OUT ...@@ -24,6 +24,9 @@ mkdir -p OUT
>BAD >BAD
>SKIPPED >SKIPPED
# The -uall flag (edit this file to change).
UALL="-uall"
# Compute the list of tests to run. # Compute the list of tests to run.
case $# in case $# in
0) 0)
...@@ -38,7 +41,7 @@ esac ...@@ -38,7 +41,7 @@ esac
for T in $TESTS for T in $TESTS
do do
echo -n $T echo -n $T
if $PYTHON Lib/test/regrtest.py -uall $T >OUT/$T.out 2>&1 if $PYTHON Lib/test/regrtest.py $UALL $T >OUT/$T.out 2>&1
then then
if grep -q "1 test skipped:" OUT/$T.out if grep -q "1 test skipped:" OUT/$T.out
then then
...@@ -51,5 +54,7 @@ do ...@@ -51,5 +54,7 @@ do
else else
echo " BAD" echo " BAD"
echo $T >>BAD echo $T >>BAD
echo "---------- Re-running test in verbose mode ----------" >>OUT/$T
$PYTHON Lib/test/regrtest.py -v $UALL $T >>OUT/$T.out 2>&1
fi fi
done done
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment