summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Objects/fileobject.c29
-rw-r--r--Python/ast.c3
-rw-r--r--Tools/freeze/bkfile.py5
-rwxr-xr-xTools/freeze/freeze.py3
-rw-r--r--Tools/freeze/makefreeze.py7
-rw-r--r--Tools/freeze/makemakefile.py3
-rw-r--r--Tools/freeze/parsesetup.py3
-rwxr-xr-xruntests.sh7
8 files changed, 31 insertions, 29 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index 469eacd..2d9fcf9 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -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 *
diff --git a/Python/ast.c b/Python/ast.c
index b34411b..b313ef2 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -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);
diff --git a/Tools/freeze/bkfile.py b/Tools/freeze/bkfile.py
index c67a6c4..0e895f2 100644
--- a/Tools/freeze/bkfile.py
+++ b/Tools/freeze/bkfile.py
@@ -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
diff --git a/Tools/freeze/freeze.py b/Tools/freeze/freeze.py
index 93b1abc..80db69e 100755
--- a/Tools/freeze/freeze.py
+++ b/Tools/freeze/freeze.py
@@ -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
diff --git a/Tools/freeze/makefreeze.py b/Tools/freeze/makefreeze.py
index e359db9..4cd1e96 100644
--- a/Tools/freeze/makefreeze.py
+++ b/Tools/freeze/makefreeze.py
@@ -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):
diff --git a/Tools/freeze/makemakefile.py b/Tools/freeze/makemakefile.py
index ff8b15a..32e804c 100644
--- a/Tools/freeze/makemakefile.py
+++ b/Tools/freeze/makemakefile.py
@@ -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)
diff --git a/Tools/freeze/parsesetup.py b/Tools/freeze/parsesetup.py
index ae0bc43..1588476 100644
--- a/Tools/freeze/parsesetup.py
+++ b/Tools/freeze/parsesetup.py
@@ -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))
diff --git a/runtests.sh b/runtests.sh
index c90460e..7372d8e 100755
--- a/runtests.sh
+++ b/runtests.sh
@@ -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