There are other issues left, but these were basics (e.g. keys().sort()).
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 *
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);
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
# 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
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("."))
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):
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)
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))
>BAD
>SKIPPED
+# The -uall flag (edit this file to change).
+UALL="-uall"
+
# Compute the list of tests to run.
case $# in
0)
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
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