Compare commits

...

14 Commits
master ... f13

Author SHA1 Message Date
David Malcolm 2da356fc4f add test.support to the core package (rhbz#596258) 2010-09-08 18:50:14 -04:00
Toshio Kuratomi e9848abbe0 Give up on cherrypicking and just merge the changes over via meld 2010-08-23 01:10:27 -04:00
Toshio Kuratomi 05a8f80b75 - Fix an incompatibility between pyexpat and the system expat-2.0.1 that
led to a segfault running test_pyexpat.py (patch 110; upstream issue
    9054; rhbz#610312)

Conflicts:

	python3.spec
2010-08-22 23:19:21 -04:00
Toshio Kuratomi 211f42f6b6 - Backport two fixes from the f14 branch:
- Fix for lone surrogates, utf8 and certain encode error handlers.
- Fix for segfault in pyexpat
2010-08-22 19:46:53 -04:00
Fedora Release Engineering 60d8dfe6a8 dist-git conversion 2010-07-29 10:53:55 +00:00
dmalcolm aa2fa3b588 - ensure that the compiler is invoked with "-fwrapv" (rhbz#594819)
- reformat whitespace in audioop.c (patch 106)
- CVE-2010-1634: fix various integer overflow checks in the audioop module
    (patch 107)
- CVE-2010-2089: further checks within the audioop module (patch 108)
- CVE-2008-5983: the new PySys_SetArgvEx entry point from r81399 (patch
    109)
2010-06-04 20:03:42 +00:00
dmalcolm 1f5628e46b - exclude test_http_cookies when running selftests, due to hang seen on
http://koji.fedoraproject.org/koji/taskinfo?taskID=2088463 (cancelled
    after
11 hours)
- update python-gdb.py from v5 to py3k version submitted upstream
2010-04-13 17:37:27 +00:00
dmalcolm a24fa2b900 update python-gdb.py from v4 to v5 (improving performance and stability,
adding commands)
2010-04-01 03:24:09 +00:00
dmalcolm 6952be9cf9 - update python-gdb.py from v3 to v4 (fixing infinite recursion on
reference cycles and tracebacks on bytes 0x80-0xff in strings, adding
    handlers for sets and exceptions)
2010-03-25 20:39:43 +00:00
dmalcolm 45206678d1 refresh gdb hooks to v3 (reworking how they are packaged) 2010-03-24 19:59:00 +00:00
dmalcolm cd7ff0649d - update to 3.1.2: http://www.python.org/download/releases/3.1.2/
- drop upstreamed patch 2 (.pyc permissions handling)
- drop upstream patch 5 (fix for the test_tk and test_ttk_* selftests)
- drop upstreamed patch 200 (path-fixing script)
2010-03-22 19:35:52 +00:00
dmalcolm 85bcecda94 - fix typo in libpython.stp (rhbz:575336) 2010-03-20 14:51:38 +00:00
dmalcolm 1e03495a6f - add pyfuntop.stp example (source 7)
- convert usage of $$RPM_BUILD_ROOT to %%{buildroot} throughout, for
    consistency with python.spec
2010-03-12 22:43:52 +00:00
Jesse Keating 743c2e919e Initialize branch F-13 for python3 2010-02-17 03:00:01 +00:00
17 changed files with 5110 additions and 178 deletions

View File

@ -1,2 +1,2 @@
Python-3.1.1.tar.bz2
libpython-36a517ef7848cbd0b3dcc7371f32e47ac4c87eba.tar.gz
Python-3.1.2.tar.bz2

View File

@ -1,21 +0,0 @@
# Makefile for source rpm: python3
# $Id$
NAME := python3
SPECFILE = $(firstword $(wildcard *.spec))
define find-makefile-common
for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$d/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done
endef
MAKEFILE_COMMON := $(shell $(find-makefile-common))
ifeq ($(MAKEFILE_COMMON),)
# attept a checkout
define checkout-makefile-common
test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2
endef
MAKEFILE_COMMON := $(shell $(checkout-makefile-common))
endif
include $(MAKEFILE_COMMON)

View File

@ -1 +0,0 @@
python3-3_1_1-13_fc12:HEAD:python3-3.1.1-13.fc12.src.rpm:1263417721

View File

@ -9,7 +9,7 @@ probe python.function.entry = process("python3").library("LIBRARY_PATH").mark("f
funcname = user_string($arg2);
lineno = $arg3;
}
probe python.function.return = process("python3").("LIBRARY_PATH").mark("function__return")
probe python.function.return = process("python3").library("LIBRARY_PATH").mark("function__return")
{
filename = user_string($arg1);
funcname = user_string($arg2);

21
pyfuntop.stp Normal file
View File

@ -0,0 +1,21 @@
#!/usr/bin/stap
global fn_calls;
probe python.function.entry
{
fn_calls[pid(), filename, funcname, lineno] += 1;
}
probe timer.ms(1000) {
printf("\033[2J\033[1;1H") /* clear screen */
printf("%6s %80s %6s %30s %6s\n",
"PID", "FILENAME", "LINE", "FUNCTION", "CALLS")
foreach ([pid, filename, funcname, lineno] in fn_calls- limit 20) {
printf("%6d %80s %6d %30s %6d\n",
pid, filename, lineno, funcname,
fn_calls[pid, filename, funcname, lineno]);
}
delete fn_calls;
}

View File

@ -1,12 +0,0 @@
--- Lib/importlib/_bootstrap.py.fix-handling-of-readonly-pyc-files 2009-10-22 15:24:57.575015046 -0400
+++ Lib/importlib/_bootstrap.py 2009-10-22 15:25:24.024016069 -0400
@@ -522,8 +522,8 @@ class _PyPycFileLoader(PyPycLoader, _PyF
bytecode_path = self.bytecode_path(name)
if not bytecode_path:
bytecode_path = self._base_path + _suffix_list(imp.PY_COMPILED)[0]
- file = _io.FileIO(bytecode_path, 'w') # Assuming bytes.
try:
+ file = _io.FileIO(bytecode_path, 'w') # Assuming bytes.
with _closing(file) as bytecode_file:
bytecode_file.write(data)
return True

View File

@ -1,10 +0,0 @@
--- Python-3.1.1/Makefile.pre.in.install-tkinter-tests 2009-10-27 20:00:09.814539776 -0400
+++ Python-3.1.1/Makefile.pre.in 2009-10-27 20:01:43.460549947 -0400
@@ -835,6 +835,7 @@ EXTRAPLATDIR= @EXTRAPLATDIR@
MACHDEPS= $(PLATDIR) $(EXTRAPLATDIR)
XMLLIBSUBDIRS= xml xml/dom xml/etree xml/parsers xml/sax
LIBSUBDIRS= tkinter site-packages test test/output test/data \
+ tkinter/test tkinter/test/test_ttk tkinter/test/test_tkinter \
test/decimaltestdata \
encodings \
email email/mime email/test email/test/data \

View File

@ -1,61 +0,0 @@
--- Python-3.1.1.orig/Tools/scripts/pathfix.py 2009-09-24 15:27:04.000000000 -0600
+++ Python-3.1.1/Tools/scripts/pathfix.py 2009-09-25 14:05:04.000000000 -0600
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#!/usr/bin/env python3.1
# Change the #! line occurring in Python scripts. The new interpreter
# pathname must be given with a -i option.
@@ -43,8 +43,8 @@
sys.exit(2)
for o, a in opts:
if o == '-i':
- new_interpreter = a
- if not new_interpreter or new_interpreter[0] != '/' or not args:
+ new_interpreter = a.encode()
+ if not new_interpreter or new_interpreter[0] != b'/'[0] or not args:
err('-i option or file-or-directory missing\n')
err(usage)
sys.exit(2)
@@ -61,7 +61,7 @@
ispythonprog = re.compile('^[a-zA-Z0-9_]+\.py$')
def ispython(name):
- return ispythonprog.match(name) >= 0
+ return bool(ispythonprog.match(name))
def recursedown(dirname):
dbg('recursedown(%r)\n' % (dirname,))
@@ -88,7 +88,7 @@
def fix(filename):
## dbg('fix(%r)\n' % (filename,))
try:
- f = open(filename, 'r')
+ f = open(filename, 'rb')
except IOError as msg:
err('%s: cannot open: %r\n' % (filename, msg))
return 1
@@ -101,7 +101,7 @@
head, tail = os.path.split(filename)
tempname = os.path.join(head, '@' + tail)
try:
- g = open(tempname, 'w')
+ g = open(tempname, 'wb')
except IOError as msg:
f.close()
err('%s: cannot create: %r\n' % (tempname, msg))
@@ -139,11 +139,11 @@
return 0
def fixline(line):
- if not line.startswith('#!'):
+ if not line.startswith(b'#!'):
return line
- if "python" not in line:
+ if b"python" not in line:
return line
- return '#! %s\n' % new_interpreter
+ return b'#!' + new_interpreter + b'\n'
if __name__ == '__main__':
main()

View File

@ -0,0 +1,120 @@
diff -up Python-3.1.2/Doc/c-api/init.rst.CVE-2008-5983 Python-3.1.2/Doc/c-api/init.rst
--- Python-3.1.2/Doc/c-api/init.rst.CVE-2008-5983 2010-01-09 13:48:46.000000000 -0500
+++ Python-3.1.2/Doc/c-api/init.rst 2010-06-04 15:19:26.724089244 -0400
@@ -22,6 +22,7 @@ Initialization, Finalization, and Thread
module: sys
triple: module; search; path
single: PySys_SetArgv()
+ single: PySys_SetArgvEx()
single: Py_Finalize()
Initialize the Python interpreter. In an application embedding Python, this
@@ -31,7 +32,7 @@ Initialization, Finalization, and Thread
the table of loaded modules (``sys.modules``), and creates the fundamental
modules :mod:`builtins`, :mod:`__main__` and :mod:`sys`. It also initializes
the module search path (``sys.path``). It does not set ``sys.argv``; use
- :cfunc:`PySys_SetArgv` for that. This is a no-op when called for a second time
+ :cfunc:`PySys_SetArgvEx` for that. This is a no-op when called for a second time
(without calling :cfunc:`Py_Finalize` first). There is no return value; it is a
fatal error if the initialization fails.
@@ -344,7 +345,7 @@ Initialization, Finalization, and Thread
``sys.version``.
-.. cfunction:: void PySys_SetArgv(int argc, wchar_t **argv)
+.. cfunction:: void PySys_SetArgvEx(int argc, wchar_t **argv, int updatepath)
.. index::
single: main()
@@ -359,14 +360,41 @@ Initialization, Finalization, and Thread
string. If this function fails to initialize :data:`sys.argv`, a fatal
condition is signalled using :cfunc:`Py_FatalError`.
- This function also prepends the executed script's path to :data:`sys.path`.
- If no script is executed (in the case of calling ``python -c`` or just the
- interactive interpreter), the empty string is used instead.
+ If *updatepath* is zero, this is all the function does. If *updatepath*
+ is non-zero, the function also modifies :data:`sys.path` according to the
+ following algorithm:
+
+ - If the name of an existing script is passed in ``argv[0]``, the absolute
+ path of the directory where the script is located is prepended to
+ :data:`sys.path`.
+ - Otherwise (that is, if *argc* is 0 or ``argv[0]`` doesn't point
+ to an existing file name), an empty string is prepended to
+ :data:`sys.path`, which is the same as prepending the current working
+ directory (``"."``).
+
+ .. note::
+ It is recommended that applications embedding the Python interpreter
+ for purposes other than executing a single script pass 0 as *updatepath*,
+ and update :data:`sys.path` themselves if desired.
+ See `CVE-2008-5983 <http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-5983>`_.
+
+ On versions before 3.1.3, you can achieve the same effect by manually
+ popping the first :data:`sys.path` element after having called
+ :cfunc:`PySys_SetArgv`, for example using::
+
+ PyRun_SimpleString("import sys; sys.path.pop(0)\n");
+
+ .. versionadded:: 3.1.3
.. XXX impl. doesn't seem consistent in allowing 0/NULL for the params;
check w/ Guido.
+.. cfunction:: void PySys_SetArgv(int argc, wchar_t **argv)
+
+ This function works like :cfunc:`PySys_SetArgv` with *updatepath* set to 1.
+
+
.. cfunction:: void Py_SetPythonHome(wchar_t *home)
Set the default "home" directory, that is, the location of the standard
diff -up Python-3.1.2/Include/sysmodule.h.CVE-2008-5983 Python-3.1.2/Include/sysmodule.h
--- Python-3.1.2/Include/sysmodule.h.CVE-2008-5983 2008-04-13 09:53:33.000000000 -0400
+++ Python-3.1.2/Include/sysmodule.h 2010-06-04 15:19:26.721088968 -0400
@@ -10,6 +10,7 @@ extern "C" {
PyAPI_FUNC(PyObject *) PySys_GetObject(const char *);
PyAPI_FUNC(int) PySys_SetObject(const char *, PyObject *);
PyAPI_FUNC(void) PySys_SetArgv(int, wchar_t **);
+PyAPI_FUNC(void) PySys_SetArgvEx(int, wchar_t **, int);
PyAPI_FUNC(void) PySys_SetPath(const wchar_t *);
PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...)
diff -up Python-3.1.2/Misc/NEWS.CVE-2008-5983 Python-3.1.2/Misc/NEWS
diff -up Python-3.1.2/Python/sysmodule.c.CVE-2008-5983 Python-3.1.2/Python/sysmodule.c
--- Python-3.1.2/Python/sysmodule.c.CVE-2008-5983 2010-06-04 15:19:26.000000000 -0400
+++ Python-3.1.2/Python/sysmodule.c 2010-06-04 15:20:59.932964188 -0400
@@ -1561,7 +1561,7 @@ _wrealpath(const wchar_t *path, wchar_t
#endif
void
-PySys_SetArgv(int argc, wchar_t **argv)
+PySys_SetArgvEx(int argc, wchar_t **argv, int updatepath)
{
#if defined(HAVE_REALPATH)
wchar_t fullpath[MAXPATHLEN];
@@ -1574,7 +1574,7 @@ PySys_SetArgv(int argc, wchar_t **argv)
Py_FatalError("no mem for sys.argv");
if (PySys_SetObject("argv", av) != 0)
Py_FatalError("can't assign sys.argv");
- if (path != NULL) {
+ if (updatepath && path != NULL) {
wchar_t *argv0 = argv[0];
wchar_t *p = NULL;
Py_ssize_t n = 0;
@@ -1661,6 +1661,12 @@ PySys_SetArgv(int argc, wchar_t **argv)
Py_DECREF(av);
}
+void
+PySys_SetArgv(int argc, wchar_t **argv)
+{
+ PySys_SetArgvEx(argc, argv, 1);
+}
+
/* APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Adapted from code submitted by Just van Rossum.

View File

@ -0,0 +1,209 @@
--- python/branches/py3k/Modules/audioop.c 2010/05/09 15:52:27 81032
+++ python/branches/py3k/Modules/audioop.c 2010/05/11 13:09:58 81081
@@ -834,7 +834,7 @@
audioop_tostereo(PyObject *self, PyObject *args)
{
signed char *cp, *ncp;
- int len, new_len, size, val1, val2, val = 0;
+ int len, size, val1, val2, val = 0;
double fac1, fac2, fval, maxval;
PyObject *rv;
int i;
@@ -851,14 +851,13 @@
return 0;
}
- new_len = len*2;
- if (new_len < 0) {
+ if (len > INT_MAX/2) {
PyErr_SetString(PyExc_MemoryError,
"not enough memory for output buffer");
return 0;
}
- rv = PyBytes_FromStringAndSize(NULL, new_len);
+ rv = PyBytes_FromStringAndSize(NULL, len*2);
if ( rv == 0 )
return 0;
ncp = (signed char *)PyBytes_AsString(rv);
@@ -1021,7 +1020,7 @@
{
signed char *cp;
unsigned char *ncp;
- int len, new_len, size, size2, val = 0;
+ int len, size, size2, val = 0;
PyObject *rv;
int i, j;
@@ -1035,13 +1034,12 @@
return 0;
}
- new_len = (len/size)*size2;
- if (new_len < 0) {
+ if (len/size > INT_MAX/size2) {
PyErr_SetString(PyExc_MemoryError,
"not enough memory for output buffer");
return 0;
}
- rv = PyBytes_FromStringAndSize(NULL, new_len);
+ rv = PyBytes_FromStringAndSize(NULL, (len/size)*size2);
if ( rv == 0 )
return 0;
ncp = (unsigned char *)PyBytes_AsString(rv);
@@ -1077,7 +1075,6 @@
int chan, d, *prev_i, *cur_i, cur_o;
PyObject *state, *samps, *str, *rv = NULL;
int bytes_per_frame;
- size_t alloc_size;
weightA = 1;
weightB = 0;
@@ -1120,14 +1117,13 @@
inrate /= d;
outrate /= d;
- alloc_size = sizeof(int) * (unsigned)nchannels;
- if (alloc_size < (unsigned)nchannels) {
+ if ((size_t)nchannels > PY_SIZE_MAX/sizeof(int)) {
PyErr_SetString(PyExc_MemoryError,
"not enough memory for output buffer");
return 0;
}
- prev_i = (int *) malloc(alloc_size);
- cur_i = (int *) malloc(alloc_size);
+ prev_i = (int *) malloc(nchannels * sizeof(int));
+ cur_i = (int *) malloc(nchannels * sizeof(int));
if (prev_i == NULL || cur_i == NULL) {
(void) PyErr_NoMemory();
goto exit;
@@ -1164,25 +1160,16 @@
ceiling(len*outrate/inrate) output frames, and each frame
requires bytes_per_frame bytes. Computing this
without spurious overflow is the challenge; we can
- settle for a reasonable upper bound, though. */
- int ceiling; /* the number of output frames */
- int nbytes; /* the number of output bytes needed */
- int q = len / inrate;
- /* Now len = q * inrate + r exactly (with r = len % inrate),
- and this is less than q * inrate + inrate = (q+1)*inrate.
- So a reasonable upper bound on len*outrate/inrate is
- ((q+1)*inrate)*outrate/inrate =
- (q+1)*outrate.
- */
- ceiling = (q+1) * outrate;
- nbytes = ceiling * bytes_per_frame;
- /* See whether anything overflowed; if not, get the space. */
- if (q+1 < 0 ||
- ceiling / outrate != q+1 ||
- nbytes / bytes_per_frame != ceiling)
+ settle for a reasonable upper bound, though, in this
+ case ceiling(len/inrate) * outrate. */
+
+ /* compute ceiling(len/inrate) without overflow */
+ int q = len > 0 ? 1 + (len - 1) / inrate : 0;
+ if (outrate > INT_MAX / q / bytes_per_frame)
str = NULL;
else
- str = PyBytes_FromStringAndSize(NULL, nbytes);
+ str = PyBytes_FromStringAndSize(NULL,
+ q * outrate * bytes_per_frame);
if (str == NULL) {
PyErr_SetString(PyExc_MemoryError,
@@ -1300,7 +1287,7 @@
unsigned char *cp;
unsigned char cval;
signed char *ncp;
- int len, new_len, size, val;
+ int len, size, val;
PyObject *rv;
int i;
@@ -1313,18 +1300,17 @@
return 0;
}
- new_len = len*size;
- if (new_len < 0) {
+ if (len > INT_MAX/size) {
PyErr_SetString(PyExc_MemoryError,
"not enough memory for output buffer");
return 0;
}
- rv = PyBytes_FromStringAndSize(NULL, new_len);
+ rv = PyBytes_FromStringAndSize(NULL, len*size);
if ( rv == 0 )
return 0;
ncp = (signed char *)PyBytes_AsString(rv);
- for ( i=0; i < new_len; i += size ) {
+ for ( i=0; i < len*size; i += size ) {
cval = *cp++;
val = st_ulaw2linear16(cval);
@@ -1374,7 +1360,7 @@
unsigned char *cp;
unsigned char cval;
signed char *ncp;
- int len, new_len, size, val;
+ int len, size, val;
PyObject *rv;
int i;
@@ -1387,18 +1373,17 @@
return 0;
}
- new_len = len*size;
- if (new_len < 0) {
+ if (len > INT_MAX/size) {
PyErr_SetString(PyExc_MemoryError,
"not enough memory for output buffer");
return 0;
}
- rv = PyBytes_FromStringAndSize(NULL, new_len);
+ rv = PyBytes_FromStringAndSize(NULL, len*size);
if ( rv == 0 )
return 0;
ncp = (signed char *)PyBytes_AsString(rv);
- for ( i=0; i < new_len; i += size ) {
+ for ( i=0; i < len*size; i += size ) {
cval = *cp++;
val = st_alaw2linear16(cval);
@@ -1523,7 +1508,7 @@
{
signed char *cp;
signed char *ncp;
- int len, new_len, size, valpred, step, delta, index, sign, vpdiff;
+ int len, size, valpred, step, delta, index, sign, vpdiff;
PyObject *rv, *str, *state;
int i, inputbuffer = 0, bufferstep;
@@ -1545,13 +1530,12 @@
} else if ( !PyArg_ParseTuple(state, "ii", &valpred, &index) )
return 0;
- new_len = len*size*2;
- if (new_len < 0) {
+ if (len > (INT_MAX/2)/size) {
PyErr_SetString(PyExc_MemoryError,
"not enough memory for output buffer");
return 0;
}
- str = PyBytes_FromStringAndSize(NULL, new_len);
+ str = PyBytes_FromStringAndSize(NULL, len*size*2);
if ( str == 0 )
return 0;
ncp = (signed char *)PyBytes_AsString(str);
@@ -1559,7 +1543,7 @@
step = stepsizeTable[index];
bufferstep = 0;
- for ( i=0; i < new_len; i += size ) {
+ for ( i=0; i < len*size*2; i += size ) {
/* Step 1 - get the delta value and compute next index */
if ( bufferstep ) {
delta = inputbuffer & 0xf;

View File

@ -0,0 +1,313 @@
diff -up Python-3.1.2/Modules/audioop.c.CVE-2010-2089 Python-3.1.2/Modules/audioop.c
--- Python-3.1.2/Modules/audioop.c.CVE-2010-2089 2010-06-04 14:55:04.281964205 -0400
+++ Python-3.1.2/Modules/audioop.c 2010-06-04 15:04:32.896088959 -0400
@@ -295,6 +295,29 @@ static int stepsizeTable[89] = {
static PyObject *AudioopError;
+static int
+audioop_check_size(int size)
+{
+ if ( size != 1 && size != 2 && size != 4 ) {
+ PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
+static int
+audioop_check_parameters(int len, int size)
+{
+ if (!audioop_check_size(size))
+ return 0;
+ if ( len % size != 0 ) {
+ PyErr_SetString(AudioopError, "not a whole number of frames");
+ return 0;
+ }
+ return 1;
+}
+
static PyObject *
audioop_getsample(PyObject *self, PyObject *args)
{
@@ -304,10 +327,8 @@ audioop_getsample(PyObject *self, PyObje
if ( !PyArg_ParseTuple(args, "s#ii:getsample", &cp, &len, &size, &i) )
return 0;
- if ( size != 1 && size != 2 && size != 4 ) {
- PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
- return 0;
- }
+ if (!audioop_check_parameters(len, size))
+ return NULL;
if ( i < 0 || i >= len/size ) {
PyErr_SetString(AudioopError, "Index out of range");
return 0;
@@ -328,10 +349,8 @@ audioop_max(PyObject *self, PyObject *ar
if ( !PyArg_ParseTuple(args, "s#i:max", &cp, &len, &size) )
return 0;
- if ( size != 1 && size != 2 && size != 4 ) {
- PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
- return 0;
- }
+ if (!audioop_check_parameters(len, size))
+ return NULL;
for ( i=0; i<len; i+= size) {
if ( size == 1 ) val = (int)*CHARP(cp, i);
else if ( size == 2 ) val = (int)*SHORTP(cp, i);
@@ -352,10 +371,8 @@ audioop_minmax(PyObject *self, PyObject
if (!PyArg_ParseTuple(args, "s#i:minmax", &cp, &len, &size))
return NULL;
- if (size != 1 && size != 2 && size != 4) {
- PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
+ if (!audioop_check_parameters(len, size))
return NULL;
- }
for (i = 0; i < len; i += size) {
if (size == 1) val = (int) *CHARP(cp, i);
else if (size == 2) val = (int) *SHORTP(cp, i);
@@ -376,10 +393,8 @@ audioop_avg(PyObject *self, PyObject *ar
if ( !PyArg_ParseTuple(args, "s#i:avg", &cp, &len, &size) )
return 0;
- if ( size != 1 && size != 2 && size != 4 ) {
- PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
- return 0;
- }
+ if (!audioop_check_parameters(len, size))
+ return NULL;
for ( i=0; i<len; i+= size) {
if ( size == 1 ) val = (int)*CHARP(cp, i);
else if ( size == 2 ) val = (int)*SHORTP(cp, i);
@@ -403,10 +418,8 @@ audioop_rms(PyObject *self, PyObject *ar
if ( !PyArg_ParseTuple(args, "s#i:rms", &cp, &len, &size) )
return 0;
- if ( size != 1 && size != 2 && size != 4 ) {
- PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
- return 0;
- }
+ if (!audioop_check_parameters(len, size))
+ return NULL;
for ( i=0; i<len; i+= size) {
if ( size == 1 ) val = (int)*CHARP(cp, i);
else if ( size == 2 ) val = (int)*SHORTP(cp, i);
@@ -614,10 +627,8 @@ audioop_avgpp(PyObject *self, PyObject *
if ( !PyArg_ParseTuple(args, "s#i:avgpp", &cp, &len, &size) )
return 0;
- if ( size != 1 && size != 2 && size != 4 ) {
- PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
- return 0;
- }
+ if (!audioop_check_parameters(len, size))
+ return NULL;
/* Compute first delta value ahead. Also automatically makes us
** skip the first extreme value
*/
@@ -671,10 +682,8 @@ audioop_maxpp(PyObject *self, PyObject *
if ( !PyArg_ParseTuple(args, "s#i:maxpp", &cp, &len, &size) )
return 0;
- if ( size != 1 && size != 2 && size != 4 ) {
- PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
- return 0;
- }
+ if (!audioop_check_parameters(len, size))
+ return NULL;
/* Compute first delta value ahead. Also automatically makes us
** skip the first extreme value
*/
@@ -722,10 +731,8 @@ audioop_cross(PyObject *self, PyObject *
if ( !PyArg_ParseTuple(args, "s#i:cross", &cp, &len, &size) )
return 0;
- if ( size != 1 && size != 2 && size != 4 ) {
- PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
- return 0;
- }
+ if (!audioop_check_parameters(len, size))
+ return NULL;
ncross = -1;
prevval = 17; /* Anything <> 0,1 */
for ( i=0; i<len; i+= size) {
@@ -751,6 +758,9 @@ audioop_mul(PyObject *self, PyObject *ar
if ( !PyArg_ParseTuple(args, "s#id:mul", &cp, &len, &size, &factor ) )
return 0;
+ if (!audioop_check_parameters(len, size))
+ return NULL;
+
if ( size == 1 ) maxval = (double) 0x7f;
else if ( size == 2 ) maxval = (double) 0x7fff;
else if ( size == 4 ) maxval = (double) 0x7fffffff;
@@ -793,6 +803,14 @@ audioop_tomono(PyObject *self, PyObject
if ( !PyArg_ParseTuple(args, "s*idd:tomono",
&pcp, &size, &fac1, &fac2 ) )
return 0;
+
+ if (!audioop_check_parameters(len, size))
+ return NULL;
+ if ( ((len / size) & 1) != 0 ) {
+ PyErr_SetString(AudioopError, "not a whole number of frames");
+ return NULL;
+ }
+
cp = pcp.buf;
len = pcp.len;
@@ -843,6 +861,9 @@ audioop_tostereo(PyObject *self, PyObjec
&cp, &len, &size, &fac1, &fac2 ) )
return 0;
+ if (!audioop_check_parameters(len, size))
+ return NULL;
+
if ( size == 1 ) maxval = (double) 0x7f;
else if ( size == 2 ) maxval = (double) 0x7fff;
else if ( size == 4 ) maxval = (double) 0x7fffffff;
@@ -901,6 +922,9 @@ audioop_add(PyObject *self, PyObject *ar
&cp1, &len1, &cp2, &len2, &size ) )
return 0;
+ if (!audioop_check_parameters(len1, size))
+ return NULL;
+
if ( len1 != len2 ) {
PyErr_SetString(AudioopError, "Lengths should be the same");
return 0;
@@ -955,10 +979,8 @@ audioop_bias(PyObject *self, PyObject *a
&cp, &len, &size , &bias) )
return 0;
- if ( size != 1 && size != 2 && size != 4) {
- PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
- return 0;
- }
+ if (!audioop_check_parameters(len, size))
+ return NULL;
rv = PyBytes_FromStringAndSize(NULL, len);
if ( rv == 0 )
@@ -991,10 +1013,8 @@ audioop_reverse(PyObject *self, PyObject
&cp, &len, &size) )
return 0;
- if ( size != 1 && size != 2 && size != 4 ) {
- PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
- return 0;
- }
+ if (!audioop_check_parameters(len, size))
+ return NULL;
rv = PyBytes_FromStringAndSize(NULL, len);
if ( rv == 0 )
@@ -1028,11 +1048,10 @@ audioop_lin2lin(PyObject *self, PyObject
&cp, &len, &size, &size2) )
return 0;
- if ( (size != 1 && size != 2 && size != 4) ||
- (size2 != 1 && size2 != 2 && size2 != 4)) {
- PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
- return 0;
- }
+ if (!audioop_check_parameters(len, size))
+ return NULL;
+ if (!audioop_check_size(size2))
+ return NULL;
if (len/size > INT_MAX/size2) {
PyErr_SetString(PyExc_MemoryError,
@@ -1082,10 +1101,8 @@ audioop_ratecv(PyObject *self, PyObject
&nchannels, &inrate, &outrate, &state,
&weightA, &weightB))
return NULL;
- if (size != 1 && size != 2 && size != 4) {
- PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
+ if (!audioop_check_size(size))
return NULL;
- }
if (nchannels < 1) {
PyErr_SetString(AudioopError, "# of channels should be >= 1");
return NULL;
@@ -1261,10 +1278,8 @@ audioop_lin2ulaw(PyObject *self, PyObjec
&cp, &len, &size) )
return 0 ;
- if ( size != 1 && size != 2 && size != 4) {
- PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
- return 0;
- }
+ if (!audioop_check_parameters(len, size))
+ return NULL;
rv = PyBytes_FromStringAndSize(NULL, len/size);
if ( rv == 0 )
@@ -1295,10 +1310,8 @@ audioop_ulaw2lin(PyObject *self, PyObjec
&cp, &len, &size) )
return 0;
- if ( size != 1 && size != 2 && size != 4) {
- PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
- return 0;
- }
+ if (!audioop_check_size(size))
+ return NULL;
if (len > INT_MAX/size) {
PyErr_SetString(PyExc_MemoryError,
@@ -1334,10 +1347,8 @@ audioop_lin2alaw(PyObject *self, PyObjec
&cp, &len, &size) )
return 0;
- if ( size != 1 && size != 2 && size != 4) {
- PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
- return 0;
- }
+ if (!audioop_check_parameters(len, size))
+ return NULL;
rv = PyBytes_FromStringAndSize(NULL, len/size);
if ( rv == 0 )
@@ -1368,10 +1379,8 @@ audioop_alaw2lin(PyObject *self, PyObjec
&cp, &len, &size) )
return 0;
- if ( size != 1 && size != 2 && size != 4) {
- PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
- return 0;
- }
+ if (!audioop_check_size(size))
+ return NULL;
if (len > INT_MAX/size) {
PyErr_SetString(PyExc_MemoryError,
@@ -1409,10 +1418,8 @@ audioop_lin2adpcm(PyObject *self, PyObje
return 0;
- if ( size != 1 && size != 2 && size != 4) {
- PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
- return 0;
- }
+ if (!audioop_check_parameters(len, size))
+ return NULL;
str = PyBytes_FromStringAndSize(NULL, len/(size*2));
if ( str == 0 )
@@ -1516,10 +1523,8 @@ audioop_adpcm2lin(PyObject *self, PyObje
&cp, &len, &size, &state) )
return 0;
- if ( size != 1 && size != 2 && size != 4) {
- PyErr_SetString(AudioopError, "Size should be 1, 2 or 4");
- return 0;
- }
+ if (!audioop_check_size(size))
+ return NULL;
/* Decode state, should have (value, step) */
if ( state == Py_None ) {

View File

@ -0,0 +1,14 @@
Index: Modules/pyexpat.c
===================================================================
--- Modules/pyexpat.c (revision 81539)
+++ Modules/pyexpat.c (working copy)
@@ -415,6 +415,9 @@
PyObject *args;
PyObject *temp;
+ if (!have_handler(self, CharacterData))
+ return -1;
+
args = PyTuple_New(1);
if (args == NULL)
return -1;

File diff suppressed because it is too large Load Diff

1380
python-gdb.py Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,184 @@
Index: Python-3.1.2/Objects/unicodeobject.c
===================================================================
--- Python-3.1.2.orig/Objects/unicodeobject.c
+++ Python-3.1.2/Objects/unicodeobject.c
@@ -159,6 +159,12 @@ static PyObject *unicode_encode_call_err
const Py_UNICODE *unicode, Py_ssize_t size, PyObject **exceptionObject,
Py_ssize_t startpos, Py_ssize_t endpos, Py_ssize_t *newpos);
+static void raise_encode_exception(PyObject **exceptionObject,
+ const char *encoding,
+ const Py_UNICODE *unicode, Py_ssize_t size,
+ Py_ssize_t startpos, Py_ssize_t endpos,
+ const char *reason);
+
/* Same for linebreaks */
static unsigned char ascii_linebreak[] = {
0, 0, 0, 0, 0, 0, 0, 0,
@@ -2453,67 +2459,98 @@ PyUnicode_EncodeUTF8(const Py_UNICODE *s
for (i = 0; i < size;) {
Py_UCS4 ch = s[i++];
- if (ch < 0x80)
+ if (ch < 0x80) {
/* Encode ASCII */
*p++ = (char) ch;
- else if (ch < 0x0800) {
+ } else if (ch < 0x0800) {
/* Encode Latin-1 */
*p++ = (char)(0xc0 | (ch >> 6));
*p++ = (char)(0x80 | (ch & 0x3f));
- }
- else {
- /* Encode UCS2 Unicode ordinals */
- if (ch < 0x10000) {
+ } else if (0xD800 <= ch && ch <= 0xDFFF) {
#ifndef Py_UNICODE_WIDE
- /* Special case: check for high surrogate */
- if (0xD800 <= ch && ch <= 0xDBFF && i != size) {
- Py_UCS4 ch2 = s[i];
- /* Check for low surrogate and combine the two to
- form a UCS4 value */
- if (0xDC00 <= ch2 && ch2 <= 0xDFFF) {
- ch = ((ch - 0xD800) << 10 | (ch2 - 0xDC00)) + 0x10000;
- i++;
- goto encodeUCS4;
- }
- /* Fall through: handles isolated high surrogates */
- }
+ /* Special case: check for high and low surrogate */
+ if (ch <= 0xDBFF && i != size && 0xDC00 <= s[i] && s[i] <= 0xDFFF) {
+ Py_UCS4 ch2 = s[i];
+ /* Combine the two surrogates to form a UCS4 value */
+ ch = ((ch - 0xD800) << 10 | (ch2 - 0xDC00)) + 0x10000;
+ i++;
+
+ /* Encode UCS4 Unicode ordinals */
+ *p++ = (char)(0xf0 | (ch >> 18));
+ *p++ = (char)(0x80 | ((ch >> 12) & 0x3f));
+ *p++ = (char)(0x80 | ((ch >> 6) & 0x3f));
+ *p++ = (char)(0x80 | (ch & 0x3f));
+
+ } else {
#endif
- if (ch >= 0xd800 && ch <= 0xdfff) {
- Py_ssize_t newpos;
- PyObject *rep;
- char *prep;
- int k;
- rep = unicode_encode_call_errorhandler
- (errors, &errorHandler, "utf-8", "surrogates not allowed",
- s, size, &exc, i-1, i, &newpos);
- if (!rep)
- goto error;
- /* Implementation limitations: only support error handler that return
- bytes, and only support up to four replacement bytes. */
- if (!PyBytes_Check(rep)) {
- PyErr_SetString(PyExc_TypeError, "error handler should have returned bytes");
- Py_DECREF(rep);
+ Py_ssize_t newpos;
+ PyObject *rep;
+ Py_ssize_t repsize, k;
+ rep = unicode_encode_call_errorhandler
+ (errors, &errorHandler, "utf-8", "surrogates not allowed",
+ s, size, &exc, i-1, i, &newpos);
+ if (!rep)
+ goto error;
+
+ if (PyBytes_Check(rep))
+ repsize = PyBytes_GET_SIZE(rep);
+ else
+ repsize = PyUnicode_GET_SIZE(rep);
+
+ if (repsize > 4) {
+ Py_ssize_t offset;
+
+ if (result == NULL)
+ offset = p - stackbuf;
+ else
+ offset = p - PyBytes_AS_STRING(result);
+
+ if (nallocated > PY_SSIZE_T_MAX - repsize + 4) {
+ /* integer overflow */
+ PyErr_NoMemory();
goto error;
}
- if (PyBytes_Size(rep) > 4) {
- PyErr_SetString(PyExc_TypeError, "error handler returned too many bytes");
- Py_DECREF(rep);
- goto error;
+ nallocated += repsize - 4;
+ if (result != NULL) {
+ if (_PyBytes_Resize(&result, nallocated) < 0)
+ goto error;
+ } else {
+ result = PyBytes_FromStringAndSize(NULL, nallocated);
+ if (result == NULL)
+ goto error;
+ Py_MEMCPY(PyBytes_AS_STRING(result), stackbuf, offset);
}
- prep = PyBytes_AsString(rep);
- for(k = PyBytes_Size(rep); k > 0; k--)
+ p = PyBytes_AS_STRING(result) + offset;
+ }
+
+ if (PyBytes_Check(rep)) {
+ char *prep = PyBytes_AS_STRING(rep);
+ for(k = repsize; k > 0; k--)
*p++ = *prep++;
- Py_DECREF(rep);
- continue;
-
+ } else /* rep is unicode */ {
+ Py_UNICODE *prep = PyUnicode_AS_UNICODE(rep);
+ Py_UNICODE c;
+
+ for(k=0; k<repsize; k++) {
+ c = prep[k];
+ if (0x80 <= c) {
+ raise_encode_exception(&exc, "utf-8", s, size,
+ i-1, i, "surrogates not allowed");
+ goto error;
+ }
+ *p++ = (char)prep[k];
+ }
}
- *p++ = (char)(0xe0 | (ch >> 12));
- *p++ = (char)(0x80 | ((ch >> 6) & 0x3f));
- *p++ = (char)(0x80 | (ch & 0x3f));
- continue;
+ Py_DECREF(rep);
+#ifndef Py_UNICODE_WIDE
}
- encodeUCS4:
+#endif
+ } else if (ch < 0x10000) {
+ *p++ = (char)(0xe0 | (ch >> 12));
+ *p++ = (char)(0x80 | ((ch >> 6) & 0x3f));
+ *p++ = (char)(0x80 | (ch & 0x3f));
+ } else /* ch >= 0x10000 */ {
/* Encode UCS4 Unicode ordinals */
*p++ = (char)(0xf0 | (ch >> 18));
*p++ = (char)(0x80 | ((ch >> 12) & 0x3f));
Index: Python-3.1.2/Lib/test/test_codecs.py
===================================================================
--- Python-3.1.2.orig/Lib/test/test_codecs.py
+++ Python-3.1.2/Lib/test/test_codecs.py
@@ -571,6 +571,16 @@ class UTF8Test(ReadTest):
def test_lone_surrogates(self):
self.assertRaises(UnicodeEncodeError, "\ud800".encode, "utf-8")
self.assertRaises(UnicodeDecodeError, b"\xed\xa0\x80".decode, "utf-8")
+ self.assertEqual("[\uDC80]".encode("utf-8", "backslashreplace"),
+ b'[\\udc80]')
+ self.assertEqual("[\uDC80]".encode("utf-8", "xmlcharrefreplace"),
+ b'[&#56448;]')
+ self.assertEqual("[\uDC80]".encode("utf-8", "surrogateescape"),
+ b'[\x80]')
+ self.assertEqual("[\uDC80]".encode("utf-8", "ignore"),
+ b'[]')
+ self.assertEqual("[\uDC80]".encode("utf-8", "replace"),
+ b'[?]')
def test_surrogatepass_handler(self):
self.assertEquals("abc\ud800def".encode("utf-8", "surrogatepass"),

View File

@ -38,8 +38,8 @@
Summary: Version 3 of the Python programming language aka Python 3000
Name: python3
Version: %{pybasever}.1
Release: 26%{?dist}
Version: %{pybasever}.2
Release: 8%{?dist}
License: Python
Group: Development/Languages
Source: http://python.org/ftp/python/%{version}/Python-%{version}.tar.bz2
@ -72,9 +72,13 @@ Source3: macros.pybytecompile
# See https://fedoraproject.org/wiki/Features/EasierPythonDebugging for more
# information
#
# Downloaded from:
# http://fedorapeople.org/gitweb?p=dmalcolm/public_git/libpython.git;a=snapshot;h=36a517ef7848cbd0b3dcc7371f32e47ac4c87eba;sf=tgz
Source4: libpython-36a517ef7848cbd0b3dcc7371f32e47ac4c87eba.tar.gz
# This is the version from
# http://bugs.python.org/issue8380
#
# This is Tools/gdb/libpython.py from:
# http://bugs.python.org/file16902/port-gdb7-hooks-to-py3k.patch
# when applied to r80008 of the py3k branch
Source4: python-gdb.py
# Systemtap tapset to make it easier to use the systemtap static probes
# (actually a template; LIBRARY_PATH will get fixed up during install)
@ -85,6 +89,11 @@ Source5: libpython.stp
# Written by wcohen, mjw, dmalcolm; not yet sent upstream
Source6: systemtap-example.stp
# Another example systemtap script that uses the tapset
# Written by dmalcolm; not yet sent upstream
Source7: pyfuntop.stp
Patch0: python-3.1.1-config.patch
@ -92,11 +101,6 @@ Patch0: python-3.1.1-config.patch
# Was Patch0 in ivazquez' python3000 specfile:
Patch1: Python-3.1.1-rpath.patch
# Fixup importlib/_bootstrap.py so that it correctly handles being unable to
# open .pyc files for writing
# Sent upstream as http://bugs.python.org/issue7187
Patch2: python-3.1.1-importlib-fix-handling-of-readonly-pyc-files.patch
# The four TestMIMEAudio tests fail due to "audiotest.au" not being packaged.
# It's simplest to remove them:
Patch3: python-3.1.1-remove-mimeaudio-tests.patch
@ -108,13 +112,6 @@ Patch3: python-3.1.1-remove-mimeaudio-tests.patch
# the expected value in this test:
Patch4: python-3.1.1-apply-our-changes-to-expected-shebang-for-test_imp.patch
# test_tk test_ttk_guionly and test_ttk_textonly all rely on tkinter/test, but
# upstream's Makefile.pre.in doesn't install that subdirectory; patch it so that
# it does:
Patch5: python-3.1.1-install-tkinter-tests.patch
# (The resulting test support code is in the tkinter subpackage, but
# this is not a major problem)
# Patch the Makefile.pre.in so that the generated Makefile doesn't try to build
# a libpythonMAJOR.MINOR.a (bug 550692):
Patch6: python-3.1.1-no-static-lib.patch
@ -132,9 +129,30 @@ Patch8: python-3.1.1-systemtap.patch
Patch102: python-3.1.1-lib64.patch
# http://bugs.python.org/issue6999 -- fixed in r75062
Patch200: python-3.1.1-pathfix.patch
# This is the Modules/audioop.c part of the whitespace cleanup in r81032, to make it
# easier to apply subsequent security fixes:
Patch106: python-3.1.2-reformat-audioop.c.patch
# CVE-2010-1634: fix various integer overflow checks in the audioop module
# This is the difference from r81032 to r81081 (i.e r81047 and r81081)
Patch107: python-3.1.2-CVE-2010-1634.patch
# CVE-2010-2089: verify sizes/lengths within audioop module:
Patch108: python-3.1.2-CVE-2010-2089.patch
# CVE-2008-5983: the new PySys_SetArgvEx entry point from r81400 (backported to
# the old layout before the whitespace cleanup of release31-maint in r81033):
Patch109: python-3.1.2-CVE-2008-5983.patch
# Fix an incompatibility between pyexpat and the system expat-2.0.1 that led to
# a segfault running test_pyexpat.py (rhbz:610312)
# Sent upstream as http://bugs.python.org/issue9054
Patch110: python-3.1.2-fix-expat-issue9054.patch
# Fix encoding to utf8 when lone surrogates are present and error handler is
# set to ignore, replace, or others that return a unicode str.
# http://bugs.python.org/issue8092
Patch111: python3-r80382-r80385-lone-surrogate-and-utf8-error-handler.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: readline-devel, openssl-devel, gmp-devel
@ -217,15 +235,10 @@ python 3 code that uses more than just unittest and/or test_support.py.
%setup -q -n Python-%{version}
chmod +x %{SOURCE1}
# Unpack source archive 4 into this same dir without deleting (-D; -T suppress
# trying to unpack source 0 again):
%if 0%{?with_gdb_hooks}
%setup -q -n Python-%{version} -T -D -a 4
%endif # with_gdb_hooks
%if 0%{?with_systemtap}
# Provide an example of usage of the tapset:
cp -a %{SOURCE6} .
cp -a %{SOURCE7} .
%endif # with_systemtap
# Ensure that we're using the system copy of various libraries, rather than
@ -246,10 +259,8 @@ rm -r Modules/zlib || exit 1
#
%patch0 -p1 -b .config
%patch1 -p1 -b .rpath
%patch2 -p0 -b .fix-handling-of-readonly-pyc-files
%patch3 -p1 -b .remove-mimeaudio-tests
%patch4 -p1 -b .apply-our-changes-to-expected-shebang
%patch5 -p1 -b .install-tkinter-tests
%patch6 -p1 -b .no-static-lib
%patch7 -p1 -b .expat
%if 0%{?with_systemtap}
@ -260,7 +271,14 @@ rm -r Modules/zlib || exit 1
%patch102 -p1 -b .lib64
%endif
%patch200 -p1 -b .pathfix
%patch106 -p3 -b .reformat-audioop
%patch107 -p3 -b .CVE-2010-1634
%patch108 -p1 -b .CVE-2010-2089
%patch109 -p1 -b .CVE-2008-5983
%patch110 -p0 -b .fix-expat-issue9054
%patch111 -p1 -b .surrogate-utf8
# Currently (2010-01-15), http://docs.python.org/library is for 2.6, and there
# are many differences between 2.6 and the Python 3 library.
@ -273,10 +291,10 @@ sed --in-place \
Lib/pydoc.py || exit 1
%build
export CFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE -fPIC"
export CXXFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE -fPIC"
export CFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE -fPIC -fwrapv"
export CXXFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE -fPIC -fwrapv"
export CPPFLAGS="`pkg-config --cflags-only-I libffi`"
export OPT="$RPM_OPT_FLAGS -D_GNU_SOURCE -fPIC"
export OPT="$RPM_OPT_FLAGS -D_GNU_SOURCE -fPIC -fwrapv"
export LINKCC="gcc"
export CFLAGS="$CFLAGS `pkg-config --cflags openssl`"
export LDFLAGS="$LDFLAGS `pkg-config --libs-only-L openssl`"
@ -302,10 +320,10 @@ make OPT="$CFLAGS" %{?_smp_mflags}
%install
rm -fr $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT%{_prefix} $RPM_BUILD_ROOT%{_mandir}
rm -fr %{buildroot}
mkdir -p %{buildroot}%{_prefix} %{buildroot}%{_mandir}
make install DESTDIR=$RPM_BUILD_ROOT INSTALL="install -p"
make install DESTDIR=%{buildroot} INSTALL="install -p"
mkdir -p ${RPM_BUILD_ROOT}%{pylibdir}/site-packages
@ -321,17 +339,17 @@ cp -ar Tools/pynche ${RPM_BUILD_ROOT}%{pylibdir}/Tools/
cp -ar Tools/scripts ${RPM_BUILD_ROOT}%{pylibdir}/Tools/
# Documentation tools
install -m755 -d $RPM_BUILD_ROOT%{pylibdir}/Doc
cp -ar Doc/tools $RPM_BUILD_ROOT%{pylibdir}/Doc/
install -m755 -d %{buildroot}%{pylibdir}/Doc
cp -ar Doc/tools %{buildroot}%{pylibdir}/Doc/
# Demo scripts
cp -ar Demo $RPM_BUILD_ROOT%{pylibdir}/
cp -ar Demo %{buildroot}%{pylibdir}/
# Fix for bug #136654
rm -f $RPM_BUILD_ROOT%{pylibdir}/email/test/data/audiotest.au $RPM_BUILD_ROOT%{pylibdir}/test/audiotest.au
rm -f %{buildroot}%{pylibdir}/email/test/data/audiotest.au %{buildroot}%{pylibdir}/test/audiotest.au
%if "%{_lib}" == "lib64"
install -d $RPM_BUILD_ROOT/usr/lib/python%{pybasever}/site-packages
install -d %{buildroot}/usr/lib/python%{pybasever}/site-packages
%endif
# Make python3-devel multilib-ready (bug #192747, #139911)
@ -343,9 +361,9 @@ install -d $RPM_BUILD_ROOT/usr/lib/python%{pybasever}/site-packages
%else
%global _pyconfig_h %{_pyconfig32_h}
%endif
mv $RPM_BUILD_ROOT%{_includedir}/python%{pybasever}/pyconfig.h \
$RPM_BUILD_ROOT%{_includedir}/python%{pybasever}/%{_pyconfig_h}
cat > $RPM_BUILD_ROOT%{_includedir}/python%{pybasever}/pyconfig.h << EOF
mv %{buildroot}%{_includedir}/python%{pybasever}/pyconfig.h \
%{buildroot}%{_includedir}/python%{pybasever}/%{_pyconfig_h}
cat > %{buildroot}%{_includedir}/python%{pybasever}/pyconfig.h << EOF
#include <bits/wordsize.h>
#if __WORDSIZE == 32
@ -358,51 +376,51 @@ cat > $RPM_BUILD_ROOT%{_includedir}/python%{pybasever}/pyconfig.h << EOF
EOF
# Fix for bug 201434: make sure distutils looks at the right pyconfig.h file
sed -i -e "s/'pyconfig.h'/'%{_pyconfig_h}'/" $RPM_BUILD_ROOT%{pylibdir}/distutils/sysconfig.py
sed -i -e "s/'pyconfig.h'/'%{_pyconfig_h}'/" %{buildroot}%{pylibdir}/distutils/sysconfig.py
# Switch all shebangs to refer to the specific Python version.
LD_LIBRARY_PATH=. ./python Tools/scripts/pathfix.py -i "%{_bindir}/python%{pybasever}" $RPM_BUILD_ROOT
LD_LIBRARY_PATH=. ./python Tools/scripts/pathfix.py -i "%{_bindir}/python%{pybasever}" %{buildroot}
# Remove shebang lines from .py files that aren't executable, and
# remove executability from .py files that don't have a shebang line:
find $RPM_BUILD_ROOT -name \*.py \
find %{buildroot} -name \*.py \
\( \( \! -perm /u+x,g+x,o+x -exec sed -e '/^#!/Q 0' -e 'Q 1' {} \; \
-print -exec sed -i '1d' {} \; \) -o \( \
-perm /u+x,g+x,o+x ! -exec grep -m 1 -q '^#!' {} \; \
-exec chmod a-x {} \; \) \)
# .xpm and .xbm files should not be executable:
find $RPM_BUILD_ROOT \
find %{buildroot} \
\( -name \*.xbm -o -name \*.xpm -o -name \*.xpm.1 \) \
-exec chmod a-x {} \;
# Remove executable flag from files that shouldn't have it:
chmod a-x \
$RPM_BUILD_ROOT%{pylibdir}/Demo/comparisons/patterns \
$RPM_BUILD_ROOT%{pylibdir}/distutils/tests/Setup.sample \
$RPM_BUILD_ROOT%{pylibdir}/Demo/rpc/test \
$RPM_BUILD_ROOT%{pylibdir}/Tools/README \
$RPM_BUILD_ROOT%{pylibdir}/Demo/scripts/newslist.doc \
$RPM_BUILD_ROOT%{pylibdir}/Demo/md5test/foo
%{buildroot}%{pylibdir}/Demo/comparisons/patterns \
%{buildroot}%{pylibdir}/distutils/tests/Setup.sample \
%{buildroot}%{pylibdir}/Demo/rpc/test \
%{buildroot}%{pylibdir}/Tools/README \
%{buildroot}%{pylibdir}/Demo/scripts/newslist.doc \
%{buildroot}%{pylibdir}/Demo/md5test/foo
# Get rid of DOS batch files:
find $RPM_BUILD_ROOT -name \*.bat -exec rm {} \;
find %{buildroot} -name \*.bat -exec rm {} \;
# Get rid of backup files:
find $RPM_BUILD_ROOT/ -name "*~" -exec rm -f {} \;
find %{buildroot}/ -name "*~" -exec rm -f {} \;
find . -name "*~" -exec rm -f {} \;
rm -f $RPM_BUILD_ROOT%{pylibdir}/LICENSE.txt
rm -f %{buildroot}%{pylibdir}/LICENSE.txt
# Junk, no point in putting in -test sub-pkg
rm -f ${RPM_BUILD_ROOT}/%{pylibdir}/idlelib/testcode.py*
# Get rid of stray patch file from buildroot:
rm -f $RPM_BUILD_ROOT%{pylibdir}/test/test_imp.py.apply-our-changes-to-expected-shebang # from patch 4
rm -f %{buildroot}%{pylibdir}/test/test_imp.py.apply-our-changes-to-expected-shebang # from patch 4
# Fix end-of-line encodings:
find $RPM_BUILD_ROOT/ -name \*.py -exec sed -i 's/\r//' {} \;
find %{buildroot}/ -name \*.py -exec sed -i 's/\r//' {} \;
# Fix an encoding:
iconv -f iso8859-1 -t utf-8 $RPM_BUILD_ROOT/%{pylibdir}/Demo/rpc/README > README.conv && mv -f README.conv $RPM_BUILD_ROOT/%{pylibdir}/Demo/rpc/README
iconv -f iso8859-1 -t utf-8 %{buildroot}/%{pylibdir}/Demo/rpc/README > README.conv && mv -f README.conv %{buildroot}/%{pylibdir}/Demo/rpc/README
# Note that
# %{pylibdir}/Demo/distutils/test2to3/setup.py
@ -414,16 +432,16 @@ iconv -f iso8859-1 -t utf-8 $RPM_BUILD_ROOT/%{pylibdir}/Demo/rpc/README > README
LD_LIBRARY_PATH=. /usr/lib/rpm/brp-python-bytecompile ./python
# Fixup permissions for shared libraries from non-standard 555 to standard 755:
find $RPM_BUILD_ROOT \
find %{buildroot} \
-perm 555 -exec chmod 755 {} \;
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/rpm
install -m 644 %{SOURCE2} $RPM_BUILD_ROOT/%{_sysconfdir}/rpm
install -m 644 %{SOURCE3} $RPM_BUILD_ROOT/%{_sysconfdir}/rpm
mkdir -p %{buildroot}/%{_sysconfdir}/rpm
install -m 644 %{SOURCE2} %{buildroot}/%{_sysconfdir}/rpm
install -m 644 %{SOURCE3} %{buildroot}/%{_sysconfdir}/rpm
# Ensure that the curses module was linked against libncursesw.so, rather than
# libncurses.so (bug 539917)
ldd $RPM_BUILD_ROOT/%{dynload_dir}/_curses*.so \
ldd %{buildroot}/%{dynload_dir}/_curses*.so \
| grep curses \
| grep libncurses.so && (echo "_curses.so linked against libncurses.so" ; exit 1)
@ -439,7 +457,7 @@ ldd $RPM_BUILD_ROOT/%{dynload_dir}/_curses*.so \
#
%if 0%{?with_gdb_hooks}
mkdir -p %{buildroot}%{_prefix}/lib/debug/%{_libdir}
cp libpython/libpython.py %{buildroot}%{_prefix}/lib/debug/%{_libdir}/%{py_INSTSONAME}.debug-gdb.py
cp %{SOURCE4} %{buildroot}%{_prefix}/lib/debug/%{_libdir}/%{py_INSTSONAME}.debug-gdb.py
%endif # with_gdb_hooks
#
@ -464,9 +482,9 @@ sed \
%check
# Run the upstream test suite, using the "runtests.sh" harness from the upstream
# tarball.
# I'm seeing occasional hangs in "test_httplib" when running the test suite inside
# Koji. For that reason I exclude that one.
LD_LIBRARY_PATH=$(pwd) ./runtests.sh -x test_httplib
# I'm seeing occasional hangs in some http tests when running the test suite
# inside Koji. For that reason I exclude them
LD_LIBRARY_PATH=$(pwd) ./runtests.sh -x test_httplib test_http_cookies
# Note that we're running the tests using the version of the code in the builddir,
# not in the buildroot.
@ -515,7 +533,7 @@ done
# the build, due to permissions issues.
%clean
rm -fr $RPM_BUILD_ROOT
rm -fr %{buildroot}
%post libs -p /sbin/ldconfig
@ -627,6 +645,7 @@ rm -fr $RPM_BUILD_ROOT
%{pylibdir}/sqlite3/*.py*
%dir %{pylibdir}/test
%{pylibdir}/test/__init__.py*
%{pylibdir}/test/support.py*
%{pylibdir}/urllib
%{pylibdir}/wsgiref
%{pylibdir}/xml
@ -649,7 +668,7 @@ rm -fr $RPM_BUILD_ROOT
%{_libdir}/%{py_INSTSONAME}
%if 0%{?with_systemtap}
%{tapsetdir}/%{libpython_stp}
%doc systemtap-example.stp
%doc systemtap-example.stp pyfuntop.stp
%endif
%files devel
@ -691,6 +710,8 @@ rm -fr $RPM_BUILD_ROOT
%{pylibdir}/json/tests
%{pylibdir}/sqlite3/test
%{pylibdir}/test
%exclude %{pylibdir}/test/__init__.py*
%exclude %{pylibdir}/test/support.py*
%{dynload_dir}/_ctypes_test.so
%{dynload_dir}/_testcapimodule.so
%{pylibdir}/lib2to3/tests
@ -713,6 +734,55 @@ rm -fr $RPM_BUILD_ROOT
%changelog
* Wed Sep 8 2010 David Malcolm <dmalcolm@redhat.com> - 3.1.2-8
- add test.support to the core package (rhbz#596258)
* Sun Aug 22 2010 Toshio Kuratomi <toshio@fedoraproject.org> - 3.1.2-7
- Backport from F14:
- Fix for lone surrogates, utf8 and certain encode error handlers.
- Fix an incompatibility between pyexpat and the system expat-2.0.1 that led to
a segfault running test_pyexpat.py (patch 110; upstream issue 9054; rhbz#610312)
* Fri Jun 4 2010 David Malcolm <dmalcolm@redhat.com> - 3.1.2-6
- ensure that the compiler is invoked with "-fwrapv" (rhbz#594819)
- reformat whitespace in audioop.c (patch 106)
- CVE-2010-1634: fix various integer overflow checks in the audioop
module (patch 107)
- CVE-2010-2089: further checks within the audioop module (patch 108)
- CVE-2008-5983: the new PySys_SetArgvEx entry point from r81399 (patch 109)
* Tue Apr 13 2010 David Malcolm <dmalcolm@redhat.com> - 3.1.2-5
- exclude test_http_cookies when running selftests, due to hang seen on
http://koji.fedoraproject.org/koji/taskinfo?taskID=2088463 (cancelled after
11 hours)
- update python-gdb.py from v5 to py3k version submitted upstream
* Wed Mar 31 2010 David Malcolm <dmalcolm@redhat.com> - 3.1.2-4
- update python-gdb.py from v4 to v5 (improving performance and stability,
adding commands)
* Thu Mar 25 2010 David Malcolm <dmalcolm@redhat.com> - 3.1.2-3
- update python-gdb.py from v3 to v4 (fixing infinite recursion on reference
cycles and tracebacks on bytes 0x80-0xff in strings, adding handlers for sets
and exceptions)
* Wed Mar 24 2010 David Malcolm <dmalcolm@redhat.com> - 3.1.2-2
- refresh gdb hooks to v3 (reworking how they are packaged)
* Sun Mar 21 2010 David Malcolm <dmalcolm@redhat.com> - 3.1.2-1
- update to 3.1.2: http://www.python.org/download/releases/3.1.2/
- drop upstreamed patch 2 (.pyc permissions handling)
- drop upstream patch 5 (fix for the test_tk and test_ttk_* selftests)
- drop upstreamed patch 200 (path-fixing script)
* Sat Mar 20 2010 David Malcolm <dmalcolm@redhat.com> - 3.1.1-28
- fix typo in libpython.stp (rhbz:575336)
* Fri Mar 12 2010 David Malcolm <dmalcolm@redhat.com> - 3.1.1-27
- add pyfuntop.stp example (source 7)
- convert usage of $$RPM_BUILD_ROOT to %%{buildroot} throughout, for
consistency with python.spec
* Mon Feb 15 2010 Thomas Spura <tomspur@fedoraproject.org> - 3.1.1-26
- rebuild for new package of redhat-rpm-config (rhbz:564527)
- use 'install -p' when running 'make install'

View File

@ -1,2 +1 @@
d1ddd9f16e3c6a51c7208f33518cd674 Python-3.1.1.tar.bz2
e9b2198d72a406698c8de07467654204 libpython-36a517ef7848cbd0b3dcc7371f32e47ac4c87eba.tar.gz
45350b51b58a46b029fb06c61257e350 Python-3.1.2.tar.bz2