Kaydet (Commit) 53970395 authored tarafından 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()).
üst 0aa35f87
......@@ -265,24 +265,19 @@ cleanup:
PyObject *
PyFile_FromFile(FILE *fp, char *name, char *mode, int (*close)(FILE *))
{
PyErr_SetString(PyExc_SystemError,
"attempt to create old file from FILE *");
return NULL;
#if 0
PyFileObject *f = (PyFileObject *)PyFile_Type.tp_new(&PyFile_Type,
NULL, NULL);
if (f != NULL) {
PyObject *o_name = PyString_FromString(name);
if (o_name == NULL)
return NULL;
if (fill_file_fields(f, fp, o_name, mode, close) == NULL) {
Py_DECREF(f);
f = NULL;
}
Py_DECREF(o_name);
PyObject *io = NULL, *stream = NULL;
io = PyImport_ImportModule("io");
if (io == NULL)
return NULL;
stream = PyObject_CallMethod(io, "open", "ss", name, mode);
if (stream == NULL) {
Py_XDECREF(io);
return NULL;
}
return (PyObject *) f;
#endif
if (close != NULL)
close(fp);
return stream;
}
PyObject *
......
......@@ -193,8 +193,11 @@ PyAST_FromNode(const node *n, PyCompilerFlags *flags, const char *filename,
if (flags && flags->cf_flags & PyCF_SOURCE_IS_UTF8) {
c.c_encoding = "utf-8";
if (TYPE(n) == encoding_decl) {
#if 0
ast_error(n, "encoding declaration in Unicode string");
goto error;
#endif
n = CHILD(n, 0);
}
} else if (TYPE(n) == encoding_decl) {
c.c_encoding = STR(n);
......
......@@ -21,7 +21,10 @@ class _BkFile:
self.mode = self.__file.mode
self.name = self.__file.name
self.read = self.__file.read
self.readinto = self.__file.readinto
try:
self.readinto = self.__file.readinto
except AttributeError:
pass
self.readline = self.__file.readline
self.readlines = self.__file.readlines
self.seek = self.__file.seek
......
......@@ -386,8 +386,7 @@ def main():
# look for unfrozen modules (builtin and of unknown origin)
builtins = []
unknown = []
mods = dict.keys()
mods.sort()
mods = sorted(dict.keys())
for mod in mods:
if dict[mod].__code__:
continue
......
......@@ -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
done = []
files = []
mods = dict.keys()
mods.sort()
mods = sorted(dict.keys())
for mod in mods:
m = dict[mod]
mangled = "__".join(mod.split("."))
......@@ -81,8 +80,8 @@ def writecode(outfp, mod, str):
outfp.write('unsigned char M_%s[] = {' % mod)
for i in range(0, len(str), 16):
outfp.write('\n\t')
for c in str[i:i+16]:
outfp.write('%d,' % ord(c))
for c in bytes(str[i:i+16]):
outfp.write('%d,' % c)
outfp.write('\n};\n')
## def writecode(outfp, mod, str):
......
......@@ -5,8 +5,7 @@ import os
def makemakefile(outfp, makevars, files, target):
outfp.write("# Makefile generated by freeze.py script\n\n")
keys = makevars.keys()
keys.sort()
keys = sorted(makevars.keys())
for key in keys:
outfp.write("%s=%s\n" % (key, makevars[key]))
outfp.write("\nall: %s\n\n" % target)
......
......@@ -102,8 +102,7 @@ def test():
print('(name must begin with "Makefile" or "Setup")')
def prdict(d):
keys = d.keys()
keys.sort()
keys = sorted(d.keys())
for key in keys:
value = d[key]
print("%-15s" % key, str(value))
......
......@@ -24,6 +24,9 @@ mkdir -p OUT
>BAD
>SKIPPED
# The -uall flag (edit this file to change).
UALL="-uall"
# Compute the list of tests to run.
case $# in
0)
......@@ -38,7 +41,7 @@ esac
for T in $TESTS
do
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
if grep -q "1 test skipped:" OUT/$T.out
then
......@@ -51,5 +54,7 @@ do
else
echo " 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
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