", line 1, in -toplevel-
d['primary'] # entry was automatically removed
- File "C:/PY24/lib/weakref.py", line 46, in __getitem__
+ File "C:/python25/lib/weakref.py", line 46, in __getitem__
o = self.data[key]()
KeyError: 'primary'
\end{verbatim}
Modified: stackless/branches/release25-maint/Include/fileobject.h
==============================================================================
--- stackless/branches/release25-maint/Include/fileobject.h (original)
+++ stackless/branches/release25-maint/Include/fileobject.h Tue May 8 11:04:01 2007
@@ -57,6 +57,11 @@
char *Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *);
size_t Py_UniversalNewlineFread(char *, size_t, FILE *, PyObject *);
+/* A routine to do sanity checking on the file mode string. returns
+ non-zero on if an exception occurred
+*/
+int _PyFile_SanitizeMode(char *mode);
+
#ifdef __cplusplus
}
#endif
Modified: stackless/branches/release25-maint/LICENSE
==============================================================================
--- stackless/branches/release25-maint/LICENSE (original)
+++ stackless/branches/release25-maint/LICENSE Tue May 8 11:04:01 2007
@@ -52,6 +52,7 @@
2.4.1 2.4 2005 PSF yes
2.4.2 2.4.1 2005 PSF yes
2.4.3 2.4.2 2006 PSF yes
+ 2.4.4 2.4.3 2006 PSF yes
2.5 2.4 2006 PSF yes
2.5.1 2.5 2007 PSF yes
Modified: stackless/branches/release25-maint/Lib/Bastion.py
==============================================================================
--- stackless/branches/release25-maint/Lib/Bastion.py (original)
+++ stackless/branches/release25-maint/Lib/Bastion.py Tue May 8 11:04:01 2007
@@ -97,7 +97,7 @@
"""
- raise RuntimeError, "This code is not secure in Python 2.2 and 2.3"
+ raise RuntimeError, "This code is not secure in Python 2.2 and later"
# Note: we define *two* ad-hoc functions here, get1 and get2.
# Both are intended to be called in the same way: get(name).
Modified: stackless/branches/release25-maint/Lib/CGIHTTPServer.py
==============================================================================
--- stackless/branches/release25-maint/Lib/CGIHTTPServer.py (original)
+++ stackless/branches/release25-maint/Lib/CGIHTTPServer.py Tue May 8 11:04:01 2007
@@ -107,7 +107,7 @@
"""Execute a CGI script."""
path = self.path
dir, rest = self.cgi_info
-
+
i = path.find('/', len(dir) + 1)
while i >= 0:
nextdir = path[:i]
Modified: stackless/branches/release25-maint/Lib/_strptime.py
==============================================================================
--- stackless/branches/release25-maint/Lib/_strptime.py (original)
+++ stackless/branches/release25-maint/Lib/_strptime.py Tue May 8 11:04:01 2007
@@ -299,17 +299,16 @@
global _TimeRE_cache, _regex_cache
_cache_lock.acquire()
try:
- time_re = _TimeRE_cache
- locale_time = time_re.locale_time
- if _getlang() != locale_time.lang:
+ if _getlang() != _TimeRE_cache.locale_time.lang:
_TimeRE_cache = TimeRE()
- _regex_cache = {}
+ _regex_cache.clear()
if len(_regex_cache) > _CACHE_MAX_SIZE:
_regex_cache.clear()
+ locale_time = _TimeRE_cache.locale_time
format_regex = _regex_cache.get(format)
if not format_regex:
try:
- format_regex = time_re.compile(format)
+ format_regex = _TimeRE_cache.compile(format)
# KeyError raised when a bad format is found; can be specified as
# \\, in which case it was a stray % but with a space after it
except KeyError, err:
Modified: stackless/branches/release25-maint/Lib/cgitb.py
==============================================================================
--- stackless/branches/release25-maint/Lib/cgitb.py (original)
+++ stackless/branches/release25-maint/Lib/cgitb.py Tue May 8 11:04:01 2007
@@ -167,7 +167,7 @@
exception = ['%s: %s' % (strong(pydoc.html.escape(str(etype))),
pydoc.html.escape(str(evalue)))]
- if type(evalue) is types.InstanceType:
+ if isinstance(evalue, BaseException):
for name in dir(evalue):
if name[:1] == '_': continue
value = pydoc.html.repr(getattr(evalue, name))
@@ -239,7 +239,7 @@
frames.append('\n%s\n' % '\n'.join(rows))
exception = ['%s: %s' % (str(etype), str(evalue))]
- if type(evalue) is types.InstanceType:
+ if isinstance(evalue, BaseException):
for name in dir(evalue):
value = pydoc.text.repr(getattr(evalue, name))
exception.append('\n%s%s = %s' % (" "*4, name, value))
Modified: stackless/branches/release25-maint/Lib/distutils/command/build_ext.py
==============================================================================
--- stackless/branches/release25-maint/Lib/distutils/command/build_ext.py (original)
+++ stackless/branches/release25-maint/Lib/distutils/command/build_ext.py Tue May 8 11:04:01 2007
@@ -533,7 +533,8 @@
if self.swig_cpp:
log.warn("--swig-cpp is deprecated - use --swig-opts=-c++")
- if self.swig_cpp or ('-c++' in self.swig_opts):
+ if self.swig_cpp or ('-c++' in self.swig_opts) or \
+ ('-c++' in extension.swig_opts):
target_ext = '.cpp'
else:
target_ext = '.c'
Modified: stackless/branches/release25-maint/Lib/distutils/unixccompiler.py
==============================================================================
--- stackless/branches/release25-maint/Lib/distutils/unixccompiler.py (original)
+++ stackless/branches/release25-maint/Lib/distutils/unixccompiler.py Tue May 8 11:04:01 2007
@@ -82,7 +82,7 @@
except ValueError:
pass
- # Check if the SDK that is used during compilation actually exists,
+ # Check if the SDK that is used during compilation actually exists,
# the universal build requires the usage of a universal SDK and not all
# users have that installed by default.
sysroot = None
Modified: stackless/branches/release25-maint/Lib/email/__init__.py
==============================================================================
--- stackless/branches/release25-maint/Lib/email/__init__.py (original)
+++ stackless/branches/release25-maint/Lib/email/__init__.py Tue May 8 11:04:01 2007
@@ -4,7 +4,7 @@
"""A package for parsing, handling, and generating email messages."""
-__version__ = '4.0.1'
+__version__ = '4.0.2'
__all__ = [
# Old names
Modified: stackless/branches/release25-maint/Lib/encodings/utf_8_sig.py
==============================================================================
--- stackless/branches/release25-maint/Lib/encodings/utf_8_sig.py (original)
+++ stackless/branches/release25-maint/Lib/encodings/utf_8_sig.py Tue May 8 11:04:01 2007
@@ -44,14 +44,19 @@
self.first = True
def _buffer_decode(self, input, errors, final):
- if self.first and codecs.BOM_UTF8.startswith(input): # might be a BOM
+ if self.first:
if len(input) < 3:
- # not enough data to decide if this really is a BOM
- # => try again on the next call
- return (u"", 0)
- (output, consumed) = codecs.utf_8_decode(input[3:], errors, final)
- self.first = False
- return (output, consumed+3)
+ if codecs.BOM_UTF8.startswith(input):
+ # not enough data to decide if this really is a BOM
+ # => try again on the next call
+ return (u"", 0)
+ else:
+ self.first = None
+ else:
+ self.first = None
+ if input[:3] == codecs.BOM_UTF8:
+ (output, consumed) = codecs.utf_8_decode(input[3:], errors, final)
+ return (output, consumed+3)
return codecs.utf_8_decode(input, errors, final)
def reset(self):
Modified: stackless/branches/release25-maint/Lib/ftplib.py
==============================================================================
--- stackless/branches/release25-maint/Lib/ftplib.py (original)
+++ stackless/branches/release25-maint/Lib/ftplib.py Tue May 8 11:04:01 2007
@@ -332,7 +332,7 @@
# 1xx or error messages for LIST), so we just discard
# this response.
if resp[0] == '2':
- resp = self.getresp()
+ resp = self.getresp()
if resp[0] != '1':
raise error_reply, resp
else:
@@ -342,7 +342,7 @@
resp = self.sendcmd(cmd)
# See above.
if resp[0] == '2':
- resp = self.getresp()
+ resp = self.getresp()
if resp[0] != '1':
raise error_reply, resp
conn, sockaddr = sock.accept()
Modified: stackless/branches/release25-maint/Lib/lib-tk/tkSimpleDialog.py
==============================================================================
--- stackless/branches/release25-maint/Lib/lib-tk/tkSimpleDialog.py (original)
+++ stackless/branches/release25-maint/Lib/lib-tk/tkSimpleDialog.py Tue May 8 11:04:01 2007
@@ -50,9 +50,9 @@
# If the master is not viewable, don't
# make the child transient, or else it
# would be opened withdrawn
- if parent.winfo_viewable():
+ if parent.winfo_viewable():
self.transient(parent)
-
+
if title:
self.title(title)
Modified: stackless/branches/release25-maint/Lib/locale.py
==============================================================================
--- stackless/branches/release25-maint/Lib/locale.py (original)
+++ stackless/branches/release25-maint/Lib/locale.py Tue May 8 11:04:01 2007
@@ -19,9 +19,11 @@
# Yuck: LC_MESSAGES is non-standard: can't tell whether it exists before
# trying the import. So __all__ is also fiddled at the end of the file.
-__all__ = ["setlocale","Error","localeconv","strcoll","strxfrm",
- "format","str","atof","atoi","LC_CTYPE","LC_COLLATE",
- "LC_TIME","LC_MONETARY","LC_NUMERIC", "LC_ALL","CHAR_MAX"]
+__all__ = ["getlocale", "getdefaultlocale", "getpreferredencoding", "Error",
+ "setlocale", "resetlocale", "localeconv", "strcoll", "strxfrm",
+ "str", "atof", "atoi", "format", "format_string", "currency",
+ "normalize", "LC_CTYPE", "LC_COLLATE", "LC_TIME", "LC_MONETARY",
+ "LC_NUMERIC", "LC_ALL", "CHAR_MAX"]
try:
Modified: stackless/branches/release25-maint/Lib/rexec.py
==============================================================================
--- stackless/branches/release25-maint/Lib/rexec.py (original)
+++ stackless/branches/release25-maint/Lib/rexec.py Tue May 8 11:04:01 2007
@@ -181,7 +181,7 @@
"""
- raise RuntimeError, "This code is not secure in Python 2.2 and 2.3"
+ raise RuntimeError, "This code is not secure in Python 2.2 and later"
ihooks._Verbose.__init__(self, verbose)
# XXX There's a circular reference here:
Modified: stackless/branches/release25-maint/Lib/subprocess.py
==============================================================================
--- stackless/branches/release25-maint/Lib/subprocess.py (original)
+++ stackless/branches/release25-maint/Lib/subprocess.py Tue May 8 11:04:01 2007
@@ -596,7 +596,7 @@
# either have to redirect all three or none. If the subprocess
# user has only redirected one or two handles, we are
# automatically creating PIPEs for the rest. We should close
- # these after the process is started. See bug #1124861.
+ # these after the process is started. See bug #1124861.
if mswindows:
if stdin is None and p2cwrite is not None:
os.close(p2cwrite)
@@ -628,7 +628,7 @@
return data
- def __del__(self):
+ def __del__(self, sys=sys):
if not self._child_created:
# We didn't get to successfully create a child process.
return
@@ -1142,7 +1142,7 @@
# we can write up to PIPE_BUF bytes without risk
# blocking. POSIX defines PIPE_BUF >= 512
bytes_written = os.write(self.stdin.fileno(), buffer(input, input_offset, 512))
- input_offset += bytes_written
+ input_offset += bytes_written
if input_offset >= len(input):
self.stdin.close()
write_set.remove(self.stdin)
Modified: stackless/branches/release25-maint/Lib/tarfile.py
==============================================================================
--- stackless/branches/release25-maint/Lib/tarfile.py (original)
+++ stackless/branches/release25-maint/Lib/tarfile.py Tue May 8 11:04:01 2007
@@ -963,7 +963,7 @@
stn(prefix, 155)
]
- buf += struct.pack("%ds" % BLOCKSIZE, "".join(parts))
+ buf += "".join(parts).ljust(BLOCKSIZE, NUL)
chksum = calc_chksums(buf[-BLOCKSIZE:])[0]
buf = buf[:-364] + "%06o\0" % chksum + buf[-357:]
self.buf = buf
@@ -1044,7 +1044,9 @@
can be determined, `mode' is overridden by `fileobj's mode.
`fileobj' is not closed, when TarFile is closed.
"""
- self.name = os.path.abspath(name)
+ self.name = name
+ if self.name is not None:
+ self.name = os.path.abspath(name)
if len(mode) > 1 or mode not in "raw":
raise ValueError("mode must be 'r', 'a' or 'w'")
@@ -1842,7 +1844,7 @@
tarinfo.type = DIRTYPE
# Directory names should have a '/' at the end.
- if tarinfo.isdir():
+ if tarinfo.isdir() and not tarinfo.name.endswith("/"):
tarinfo.name += "/"
self.members.append(tarinfo)
Modified: stackless/branches/release25-maint/Lib/test/README
==============================================================================
--- stackless/branches/release25-maint/Lib/test/README (original)
+++ stackless/branches/release25-maint/Lib/test/README Tue May 8 11:04:01 2007
@@ -15,7 +15,7 @@
one of these options. Each option requires writing a test module using the
conventions of the selected option:
- - PyUnit_ based tests
+ - unittest_ based tests
- doctest_ based tests
- "traditional" Python test modules
@@ -28,27 +28,26 @@
able to refer to the C and Python code in the CVS repository when writing
your regression test cases.
-.. _PyUnit:
.. _unittest: http://www.python.org/doc/current/lib/module-unittest.html
.. _doctest: http://www.python.org/doc/current/lib/module-doctest.html
-PyUnit based tests
+unittest-based tests
------------------
-The PyUnit_ framework is based on the ideas of unit testing as espoused
+The unittest_ framework is based on the ideas of unit testing as espoused
by Kent Beck and the `Extreme Programming`_ (XP) movement. The specific
interface provided by the framework is tightly based on the JUnit_
Java implementation of Beck's original SmallTalk test framework. Please
see the documentation of the unittest_ module for detailed information on
-the interface and general guidelines on writing PyUnit based tests.
+the interface and general guidelines on writing unittest-based tests.
The test_support helper module provides two functions for use by
-PyUnit based tests in the Python regression testing framework:
+unittest-based tests in the Python regression testing framework:
-- ``run_unittest()`` takes a ``unittest.TestCase`` derived class as a
- parameter and runs the tests defined in that class
+- ``run_unittest()`` takes a number of ``unittest.TestCase`` derived class as
+ parameters and runs the tests defined in those classes.
- ``run_suite()`` takes a populated ``TestSuite`` instance and runs the
- tests
+ tests.
``run_suite()`` is preferred because unittest files typically grow multiple
test classes, and you might as well be prepared.
@@ -63,7 +62,7 @@
latter information makes it easier to find the source for the test
than the docstring.
-All PyUnit-based tests in the Python test suite use boilerplate that
+All unittest-based tests in the Python test suite use boilerplate that
looks like this (with minor variations)::
import unittest
@@ -415,7 +414,7 @@
This is rarely required with the "traditional" Python tests, and
you shouldn't create a module global with name test_main unless
you're specifically exploiting this gimmick. This usage does
- prove useful with PyUnit-based tests as well, however; defining
+ prove useful with unittest-based tests as well, however; defining
a ``test_main()`` which is run by regrtest and a script-stub in the
test module ("``if __name__ == '__main__': test_main()``") allows
the test to be used like any other Python test and also work
Modified: stackless/branches/release25-maint/Lib/test/string_tests.py
==============================================================================
--- stackless/branches/release25-maint/Lib/test/string_tests.py (original)
+++ stackless/branches/release25-maint/Lib/test/string_tests.py Tue May 8 11:04:01 2007
@@ -2,7 +2,7 @@
Common tests shared by test_str, test_unicode, test_userstring and test_string.
"""
-import unittest, string, sys
+import unittest, string, sys, struct
from test import test_support
from UserList import UserList
@@ -671,7 +671,7 @@
def test_replace_overflow(self):
# Check for overflow checking on 32 bit machines
- if sys.maxint != 2147483647:
+ if sys.maxint != 2147483647 or struct.calcsize("P") > 4:
return
A2_16 = "A" * (2**16)
self.checkraises(OverflowError, A2_16, "replace", "", A2_16)
Modified: stackless/branches/release25-maint/Lib/test/test_codecs.py
==============================================================================
--- stackless/branches/release25-maint/Lib/test/test_codecs.py (original)
+++ stackless/branches/release25-maint/Lib/test/test_codecs.py Tue May 8 11:04:01 2007
@@ -430,6 +430,11 @@
# SF bug #1601501: check that the codec works with a buffer
unicode("\xef\xbb\xbf", "utf-8-sig")
+ def test_bom(self):
+ d = codecs.getincrementaldecoder("utf-8-sig")()
+ s = u"spam"
+ self.assertEqual(d.decode(s.encode("utf-8-sig")), s)
+
class EscapeDecodeTest(unittest.TestCase):
def test_empty(self):
self.assertEquals(codecs.escape_decode(""), ("", 0))
@@ -916,7 +921,7 @@
self.assertEquals(f.readlines(), [u'\ud55c\n', u'\uae00'])
class EncodedFileTest(unittest.TestCase):
-
+
def test_basic(self):
f = StringIO.StringIO('\xed\x95\x9c\n\xea\xb8\x80')
ef = codecs.EncodedFile(f, 'utf-16-le', 'utf-8')
Modified: stackless/branches/release25-maint/Lib/test/test_curses.py
==============================================================================
--- stackless/branches/release25-maint/Lib/test/test_curses.py (original)
+++ stackless/branches/release25-maint/Lib/test/test_curses.py Tue May 8 11:04:01 2007
@@ -245,7 +245,7 @@
if hasattr(curses, 'resizeterm'):
lines, cols = curses.LINES, curses.COLS
curses.resizeterm(lines - 1, cols + 1)
-
+
if curses.LINES != lines - 1 or curses.COLS != cols + 1:
raise RuntimeError, "Expected resizeterm to update LINES and COLS"
Modified: stackless/branches/release25-maint/Lib/test/test_descr.py
==============================================================================
--- stackless/branches/release25-maint/Lib/test/test_descr.py (original)
+++ stackless/branches/release25-maint/Lib/test/test_descr.py Tue May 8 11:04:01 2007
@@ -1216,7 +1216,7 @@
except NameError:
pass
else:
- # _unicode_to_string used to modify slots in certain circumstances
+ # _unicode_to_string used to modify slots in certain circumstances
slots = (unicode("foo"), unicode("bar"))
class C(object):
__slots__ = slots
@@ -1231,7 +1231,7 @@
except (TypeError, UnicodeEncodeError):
pass
else:
- raise TestFailed, "[unichr(128)] slots not caught"
+ raise TestFailed, "[unichr(128)] slots not caught"
# Test leaks
class Counted(object):
Modified: stackless/branches/release25-maint/Lib/test/test_format.py
==============================================================================
--- stackless/branches/release25-maint/Lib/test/test_format.py (original)
+++ stackless/branches/release25-maint/Lib/test/test_format.py Tue May 8 11:04:01 2007
@@ -1,5 +1,7 @@
from test.test_support import verbose, have_unicode, TestFailed
import sys
+from test.test_support import MAX_Py_ssize_t
+maxsize = MAX_Py_ssize_t
# test string formatting operator (I am not sure if this is being tested
# elsewhere but, surely, some of the given cases are *not* tested because
@@ -238,11 +240,11 @@
test_exc('%o', Foobar(), TypeError,
"expected string or Unicode object, long found")
-if sys.maxint == 2**31-1:
+if maxsize == 2**31-1:
# crashes 2.2.1 and earlier:
try:
- "%*d"%(sys.maxint, -127)
+ "%*d"%(maxsize, -127)
except MemoryError:
pass
else:
- raise TestFailed, '"%*d"%(sys.maxint, -127) should fail'
+ raise TestFailed, '"%*d"%(maxsize, -127) should fail'
Modified: stackless/branches/release25-maint/Lib/test/test_import.py
==============================================================================
--- stackless/branches/release25-maint/Lib/test/test_import.py (original)
+++ stackless/branches/release25-maint/Lib/test/test_import.py Tue May 8 11:04:01 2007
@@ -224,13 +224,13 @@
test_import_initless_directory_warning()
def test_infinite_reload():
- # Bug #742342 reports that Python segfaults (infinite recursion in C)
- # when faced with self-recursive reload()ing.
+ # Bug #742342 reports that Python segfaults (infinite recursion in C)
+ # when faced with self-recursive reload()ing.
- sys.path.insert(0, os.path.dirname(__file__))
- try:
- import infinite_reload
- finally:
- sys.path.pop(0)
+ sys.path.insert(0, os.path.dirname(__file__))
+ try:
+ import infinite_reload
+ finally:
+ sys.path.pop(0)
test_infinite_reload()
Modified: stackless/branches/release25-maint/Lib/test/test_index.py
==============================================================================
--- stackless/branches/release25-maint/Lib/test/test_index.py (original)
+++ stackless/branches/release25-maint/Lib/test/test_index.py Tue May 8 11:04:01 2007
@@ -1,7 +1,10 @@
import unittest
from test import test_support
import operator
+import sys
from sys import maxint
+maxsize = test_support.MAX_Py_ssize_t
+minsize = -maxsize-1
class oldstyle:
def __index__(self):
@@ -185,7 +188,7 @@
def _getitem_helper(self, base):
class GetItem(base):
def __len__(self):
- return maxint
+ return maxint #cannot return long here
def __getitem__(self, key):
return key
def __getslice__(self, i, j):
@@ -193,8 +196,8 @@
x = GetItem()
self.assertEqual(x[self.pos], self.pos)
self.assertEqual(x[self.neg], self.neg)
- self.assertEqual(x[self.neg:self.pos], (-1, maxint))
- self.assertEqual(x[self.neg:self.pos:1].indices(maxint), (0, maxint, 1))
+ self.assertEqual(x[self.neg:self.pos], (maxint+minsize, maxsize))
+ self.assertEqual(x[self.neg:self.pos:1].indices(maxsize), (0, maxsize, 1))
def test_getitem(self):
self._getitem_helper(object)
Modified: stackless/branches/release25-maint/Lib/test/test_itertools.py
==============================================================================
--- stackless/branches/release25-maint/Lib/test/test_itertools.py (original)
+++ stackless/branches/release25-maint/Lib/test/test_itertools.py Tue May 8 11:04:01 2007
@@ -5,6 +5,8 @@
import sys
import operator
import random
+maxsize = test_support.MAX_Py_ssize_t
+minsize = -maxsize-1
def onearg(x):
'Test function of one argument'
@@ -52,7 +54,7 @@
self.assertEqual(take(2, zip('abc',count(3))), [('a', 3), ('b', 4)])
self.assertRaises(TypeError, count, 2, 3)
self.assertRaises(TypeError, count, 'a')
- self.assertRaises(OverflowError, list, islice(count(sys.maxint-5), 10))
+ self.assertRaises(OverflowError, list, islice(count(maxsize-5), 10))
c = count(3)
self.assertEqual(repr(c), 'count(3)')
c.next()
@@ -285,7 +287,7 @@
self.assertRaises(ValueError, islice, xrange(10), 1, 'a')
self.assertRaises(ValueError, islice, xrange(10), 'a', 1, 1)
self.assertRaises(ValueError, islice, xrange(10), 1, 'a', 1)
- self.assertEqual(len(list(islice(count(), 1, 10, sys.maxint))), 1)
+ self.assertEqual(len(list(islice(count(), 1, 10, maxsize))), 1)
def test_takewhile(self):
data = [1, 3, 5, 20, 2, 4, 6, 8]
Modified: stackless/branches/release25-maint/Lib/test/test_locale.py
==============================================================================
--- stackless/branches/release25-maint/Lib/test/test_locale.py (original)
+++ stackless/branches/release25-maint/Lib/test/test_locale.py Tue May 8 11:04:01 2007
@@ -7,7 +7,7 @@
oldlocale = locale.setlocale(locale.LC_NUMERIC)
if sys.platform.startswith("win"):
- tlocs = ("en",)
+ tlocs = ("En", "English")
else:
tlocs = ("en_US.UTF-8", "en_US.US-ASCII", "en_US")
Modified: stackless/branches/release25-maint/Lib/test/test_mailbox.py
==============================================================================
--- stackless/branches/release25-maint/Lib/test/test_mailbox.py (original)
+++ stackless/branches/release25-maint/Lib/test/test_mailbox.py Tue May 8 11:04:01 2007
@@ -681,11 +681,11 @@
box = self._factory(self._path, factory=dummy_factory)
folder = box.add_folder('folder1')
self.assert_(folder._factory is dummy_factory)
-
+
folder1_alias = box.get_folder('folder1')
self.assert_(folder1_alias._factory is dummy_factory)
-
+
class _TestMboxMMDF(TestMailbox):
@@ -767,15 +767,15 @@
key1 = self._box.add(msg)
self._box.flush()
self._box.close()
-
+
self._box = self._factory(self._path)
self._box.lock()
key2 = self._box.add(msg)
self._box.flush()
self.assert_(self._box._locked)
self._box.close()
-
-
+
+
class TestMbox(_TestMboxMMDF):
@@ -805,7 +805,7 @@
def dummy_factory (s):
return None
self._box = self._factory(self._path, dummy_factory)
-
+
new_folder = self._box.add_folder('foo.bar')
folder0 = self._box.get_folder('foo.bar')
folder0.add(self._template % 'bar')
@@ -901,7 +901,7 @@
self.assert_(self._box.get_sequences() ==
{'foo':[1, 2, 3, 4, 5],
'unseen':[1], 'bar':[3], 'replied':[3]})
-
+
def _get_lock_path(self):
return os.path.join(self._path, '.mh_sequences.lock')
Modified: stackless/branches/release25-maint/Lib/test/test_old_mailbox.py
==============================================================================
--- stackless/branches/release25-maint/Lib/test/test_old_mailbox.py (original)
+++ stackless/branches/release25-maint/Lib/test/test_old_mailbox.py Tue May 8 11:04:01 2007
@@ -116,7 +116,7 @@
def tearDown(self):
os.unlink(self._path)
-
+
def test_from_regex (self):
# Testing new regex from bug #1633678
f = open(self._path, 'w')
Modified: stackless/branches/release25-maint/Lib/test/test_pty.py
==============================================================================
--- stackless/branches/release25-maint/Lib/test/test_pty.py (original)
+++ stackless/branches/release25-maint/Lib/test/test_pty.py Tue May 8 11:04:01 2007
@@ -115,6 +115,24 @@
os._exit(4)
else:
debug("Waiting for child (%d) to finish."%pid)
+ # In verbose mode, we have to consume the debug output from the child or
+ # the child will block, causing this test to hang in the parent's
+ # waitpid() call. The child blocks after a platform-dependent amount of
+ # data is written to its fd. On Linux 2.6, it's 4000 bytes and the child
+ # won't block, but on OS X even the small writes in the child above will
+ # block it. Also on Linux, the read() will throw an OSError (input/output
+ # error) when it tries to read past the end of the buffer but the child's
+ # already exited, so catch and discard those exceptions. It's not worth
+ # checking for EIO.
+ while True:
+ try:
+ data = os.read(master_fd, 80)
+ except OSError:
+ break
+ if not data:
+ break
+ sys.stdout.write(data.replace('\r\n', '\n'))
+
##line = os.read(master_fd, 80)
##lines = line.replace('\r\n', '\n').split('\n')
##if False and lines != ['In child, calling os.setsid()',
Modified: stackless/branches/release25-maint/Lib/test/test_re.py
==============================================================================
--- stackless/branches/release25-maint/Lib/test/test_re.py (original)
+++ stackless/branches/release25-maint/Lib/test/test_re.py Tue May 8 11:04:01 2007
@@ -610,7 +610,7 @@
for typecode in 'cbBuhHiIlLfd':
a = array.array(typecode)
self.assertEqual(re.compile("bla").match(a), None)
- self.assertEqual(re.compile("").match(a).groups(), ())
+ self.assertEqual(re.compile("").match(a).groups(), ())
def run_re_tests():
from test.re_tests import benchmarks, tests, SUCCEED, FAIL, SYNTAX_ERROR
Modified: stackless/branches/release25-maint/Lib/test/test_sax.py
==============================================================================
--- stackless/branches/release25-maint/Lib/test/test_sax.py (original)
+++ stackless/branches/release25-maint/Lib/test/test_sax.py Tue May 8 11:04:01 2007
@@ -252,7 +252,7 @@
gen.endDocument()
return result.getvalue() == start+''
-
+
# ===== Xmlfilterbase
def test_filter_basic():
Modified: stackless/branches/release25-maint/Lib/test/test_set.py
==============================================================================
--- stackless/branches/release25-maint/Lib/test/test_set.py (original)
+++ stackless/branches/release25-maint/Lib/test/test_set.py Tue May 8 11:04:01 2007
@@ -288,7 +288,7 @@
self.assertEqual(sum(elem.hash_count for elem in d), n)
if hasattr(s, 'symmetric_difference_update'):
s.symmetric_difference_update(d)
- self.assertEqual(sum(elem.hash_count for elem in d), n)
+ self.assertEqual(sum(elem.hash_count for elem in d), n)
d2 = dict.fromkeys(set(d))
self.assertEqual(sum(elem.hash_count for elem in d), n)
d3 = dict.fromkeys(frozenset(d))
@@ -500,7 +500,7 @@
set.__init__(self, iterable)
class TestSetSubclassWithKeywordArgs(TestSet):
-
+
def test_keywords_in_subclass(self):
'SF bug #1486663 -- this used to erroneously raise a TypeError'
SetSubclassWithKeywordArgs(newarg=1)
@@ -1487,7 +1487,7 @@
test_classes = (
TestSet,
TestSetSubclass,
- TestSetSubclassWithKeywordArgs,
+ TestSetSubclassWithKeywordArgs,
TestFrozenSet,
TestFrozenSetSubclass,
TestSetOfSets,
Modified: stackless/branches/release25-maint/Lib/test/test_strptime.py
==============================================================================
--- stackless/branches/release25-maint/Lib/test/test_strptime.py (original)
+++ stackless/branches/release25-maint/Lib/test/test_strptime.py Tue May 8 11:04:01 2007
@@ -505,6 +505,35 @@
self.failIfEqual(locale_time_id,
id(_strptime._TimeRE_cache.locale_time))
+ def test_TimeRE_recreation(self):
+ # The TimeRE instance should be recreated upon changing the locale.
+ locale_info = locale.getlocale(locale.LC_TIME)
+ try:
+ locale.setlocale(locale.LC_TIME, ('en_US', 'UTF8'))
+ except locale.Error:
+ return
+ try:
+ _strptime.strptime('10', '%d')
+ # Get id of current cache object.
+ first_time_re_id = id(_strptime._TimeRE_cache)
+ try:
+ # Change the locale and force a recreation of the cache.
+ locale.setlocale(locale.LC_TIME, ('de_DE', 'UTF8'))
+ _strptime.strptime('10', '%d')
+ # Get the new cache object's id.
+ second_time_re_id = id(_strptime._TimeRE_cache)
+ # They should not be equal.
+ self.failIfEqual(first_time_re_id, second_time_re_id)
+ # Possible test locale is not supported while initial locale is.
+ # If this is the case just suppress the exception and fall-through
+ # to the reseting to the original locale.
+ except locale.Error:
+ pass
+ # Make sure we don't trample on the locale setting once we leave the
+ # test.
+ finally:
+ locale.setlocale(locale.LC_TIME, locale_info)
+
def test_main():
test_support.run_unittest(
Modified: stackless/branches/release25-maint/Lib/test/test_syntax.py
==============================================================================
--- stackless/branches/release25-maint/Lib/test/test_syntax.py (original)
+++ stackless/branches/release25-maint/Lib/test/test_syntax.py Tue May 8 11:04:01 2007
@@ -373,7 +373,7 @@
... elif 1:
... pass
Traceback (most recent call last):
- ...
+ ...
SyntaxError: can't assign to function call (, line 2)
>>> if 1:
@@ -381,7 +381,7 @@
... elif 1:
... x() = 1
Traceback (most recent call last):
- ...
+ ...
SyntaxError: can't assign to function call (, line 4)
>>> if 1:
@@ -391,7 +391,7 @@
... else:
... pass
Traceback (most recent call last):
- ...
+ ...
SyntaxError: can't assign to function call (, line 2)
>>> if 1:
@@ -401,7 +401,7 @@
... else:
... pass
Traceback (most recent call last):
- ...
+ ...
SyntaxError: can't assign to function call (, line 4)
>>> if 1:
@@ -411,7 +411,7 @@
... else:
... x() = 1
Traceback (most recent call last):
- ...
+ ...
SyntaxError: can't assign to function call (, line 6)
"""
Modified: stackless/branches/release25-maint/Lib/test/test_tarfile.py
==============================================================================
--- stackless/branches/release25-maint/Lib/test/test_tarfile.py (original)
+++ stackless/branches/release25-maint/Lib/test/test_tarfile.py Tue May 8 11:04:01 2007
@@ -191,6 +191,13 @@
except:
pass
+ def test_dirtype(self):
+ for tarinfo in self.tar:
+ if tarinfo.isdir():
+ self.assert_(tarinfo.name.endswith("/"))
+ self.assert_(not tarinfo.name[:-1].endswith("/"))
+
+
class ReadStreamTest(ReadTest):
sep = "|"
@@ -626,15 +633,21 @@
self.assertEqual(tarfile.filemode(07111), '---s--s--t')
class OpenFileobjTest(BaseTest):
- # Test for SF bug #1496501.
def test_opener(self):
+ # Test for SF bug #1496501.
fobj = StringIO.StringIO("foo\n")
try:
- tarfile.open("", "r", fileobj=fobj)
+ tarfile.open("", mode="r", fileobj=fobj)
except tarfile.ReadError:
self.assertEqual(fobj.tell(), 0, "fileobj's position has moved")
+ def test_fileobj(self):
+ # Test for SF bug #1695229, opening a tarfile without
+ # a name argument.
+ tarfile.open(mode="r", fileobj=open(tarname("")))
+ tarfile.TarFile(mode="r", fileobj=open(tarname("")))
+
if bz2:
# Bzip2 TestCases
class ReadTestBzip2(ReadTestGzip):
Modified: stackless/branches/release25-maint/Lib/urllib2.py
==============================================================================
--- stackless/branches/release25-maint/Lib/urllib2.py (original)
+++ stackless/branches/release25-maint/Lib/urllib2.py Tue May 8 11:04:01 2007
@@ -55,7 +55,10 @@
# set up authentication info
authinfo = urllib2.HTTPBasicAuthHandler()
-authinfo.add_password('realm', 'host', 'username', 'password')
+authinfo.add_password(realm='PDQ Application',
+ uri='https://mahler:8092/site-updates.py',
+ user='klem',
+ passwd='geheim$parole')
proxy_support = urllib2.ProxyHandler({"http" : "http://ahad-haam:3128"})
Modified: stackless/branches/release25-maint/Misc/NEWS
==============================================================================
--- stackless/branches/release25-maint/Misc/NEWS (original)
+++ stackless/branches/release25-maint/Misc/NEWS Tue May 8 11:04:01 2007
@@ -4,6 +4,37 @@
(editors: check NEWS.help for information about editing NEWS using ReST.)
+What's New in Python 2.5.2c1?
+=============================
+
+*Release date: XX-XXX-XXXX*
+
+Library
+-------
+
+- Bug #1290505: Properly clear time.strptime's locale cache when the locale
+ changes between calls. Backport of r54646 and r54647.
+
+- Bug #1706381: Specifying the SWIG option "-c++" in the setup.py file
+ (as opposed to the command line) will now write file names ending in
+ ".cpp" too.
+
+- Patch #1695229: Fix a regression with tarfile.open() and a missing name
+ argument.
+
+- tarfile.py: Fix directory names to have only one trailing slash.
+
+- Fix test_pty.py to not hang on OS X (and theoretically other *nixes) when
+ run in verbose mode.
+
+
+Documentation
+-------------
+
+- Bug #1569057: Document that calling file.next() on a file open for writing
+ has undefined behaviour. Backport of r54712.
+
+
What's New in Python 2.5.1?
=============================
@@ -483,6 +514,8 @@
Documentation
-------------
+- Patch #1698768: updated the "using Python on the Mac" intro.
+
- Patch #1489771: the syntax rules in Python Reference Manual were
updated to reflect the current Python syntax.
@@ -588,6 +621,8 @@
- Fix bsddb test_basics.test06_Transactions to check the version
number properly.
+- Fix utf-8-sig incremental decoder, which didn't recognise a BOM when the
+ first chunk fed to the decoder started with a BOM, but was longer than 3 bytes.
Documentation
-------------
Modified: stackless/branches/release25-maint/Misc/build.sh
==============================================================================
--- stackless/branches/release25-maint/Misc/build.sh (original)
+++ stackless/branches/release25-maint/Misc/build.sh Tue May 8 11:04:01 2007
@@ -47,11 +47,12 @@
FAILURE_SUBJECT="Python Regression Test Failures"
#FAILURE_MAILTO="YOUR_ACCOUNT at gmail.com"
FAILURE_MAILTO="python-checkins at python.org"
+#FAILURE_CC="optional--uncomment and set to desired address"
REMOTE_SYSTEM="neal at dinsdale.python.org"
-REMOTE_DIR="/data/ftp.python.org/pub/docs.python.org/dev/"
+REMOTE_DIR="/data/ftp.python.org/pub/docs.python.org/dev/2.5"
RESULT_FILE="$DIR/build/index.html"
-INSTALL_DIR="/tmp/python-test/local"
+INSTALL_DIR="/tmp/python-test-2.5/local"
RSYNC_OPTS="-aC -e ssh"
# Always run the installed version of Python.
@@ -66,7 +67,7 @@
# Note: test_XXX (none currently) really leak, but are disabled
# so we don't send spam. Any test which really leaks should only
# be listed here if there are also test cases under Lib/test/leakers.
-LEAKY_TESTS="test_(XXX)" # Currently no tests should report spurious leaks.
+LEAKY_TESTS="test_(cmd_line|socket)"
# Skip these tests altogether when looking for leaks. These tests
# do not need to be stored above in LEAKY_TESTS too.
@@ -76,7 +77,7 @@
LEAKY_SKIPS="-x test_compiler test_logging"
# Change this flag to "yes" for old releases to only update/build the docs.
-BUILD_DISABLED="no"
+BUILD_DISABLED="yes"
## utility functions
current_time() {
@@ -91,7 +92,12 @@
mail_on_failure() {
if [ "$NUM_FAILURES" != "0" ]; then
- mutt -s "$FAILURE_SUBJECT $1 ($NUM_FAILURES)" $FAILURE_MAILTO < $2
+ dest=$FAILURE_MAILTO
+ # FAILURE_CC is optional.
+ if [ "$FAILURE_CC" != "" ]; then
+ dest="$dest -c $FAILURE_CC"
+ fi
+ mutt -s "$FAILURE_SUBJECT $1 ($NUM_FAILURES)" $dest < $2
fi
}
@@ -208,8 +214,19 @@
cd $DIR/Doc
F="make-doc.out"
start=`current_time`
-make >& ../build/$F
-err=$?
+# Doc/commontex/boilerplate.tex is expected to always have an outstanding
+# modification for the date. When a release is cut, a conflict occurs.
+# This allows us to detect this problem and not try to build the docs
+# which will definitely fail with a conflict.
+CONFLICTED_FILE=commontex/boilerplate.tex
+conflict_count=`grep -c "<<<" $CONFLICTED_FILE`
+if [ $conflict_count != 0 ]; then
+ echo "Conflict detected in $CONFLICTED_FILE. Doc build skipped." > ../build/$F
+ err=1
+else
+ make >& ../build/$F
+ err=$?
+fi
update_status "Making doc" "$F" $start
if [ $err != 0 ]; then
NUM_FAILURES=1
Modified: stackless/branches/release25-maint/Modules/_ctypes/callproc.c
==============================================================================
--- stackless/branches/release25-maint/Modules/_ctypes/callproc.c (original)
+++ stackless/branches/release25-maint/Modules/_ctypes/callproc.c Tue May 8 11:04:01 2007
@@ -64,6 +64,7 @@
#ifdef MS_WIN32
#include
+#include
#else
#include "ctypes_dlfcn.h"
#endif
@@ -97,9 +98,9 @@
0,
NULL);
if (n) {
- while (isspace(lpMsgBuf[n-1]))
+ while (_istspace(lpMsgBuf[n-1]))
--n;
- lpMsgBuf[n] = '\0'; /* rstrip() */
+ lpMsgBuf[n] = _T('\0'); /* rstrip() */
}
return lpMsgBuf;
}
@@ -538,8 +539,10 @@
size += 1; /* terminating NUL */
size *= sizeof(wchar_t);
pa->value.p = PyMem_Malloc(size);
- if (!pa->value.p)
+ if (!pa->value.p) {
+ PyErr_NoMemory();
return -1;
+ }
memset(pa->value.p, 0, size);
pa->keep = PyCObject_FromVoidPtr(pa->value.p, PyMem_Free);
if (!pa->keep) {
Modified: stackless/branches/release25-maint/Modules/_ctypes/cfield.c
==============================================================================
--- stackless/branches/release25-maint/Modules/_ctypes/cfield.c (original)
+++ stackless/branches/release25-maint/Modules/_ctypes/cfield.c Tue May 8 11:04:01 2007
@@ -1333,7 +1333,7 @@
if (IsBadStringPtrA(*(char **)ptr, -1)) {
PyErr_Format(PyExc_ValueError,
"invalid string pointer %p",
- ptr);
+ *(char **)ptr);
return NULL;
}
#endif
@@ -1389,7 +1389,7 @@
size *= sizeof(wchar_t);
buffer = (wchar_t *)PyMem_Malloc(size);
if (!buffer)
- return NULL;
+ return PyErr_NoMemory();
memset(buffer, 0, size);
keep = PyCObject_FromVoidPtr(buffer, PyMem_Free);
if (!keep) {
@@ -1414,9 +1414,17 @@
{
wchar_t *p;
p = *(wchar_t **)ptr;
- if (p)
+ if (p) {
+#if defined(MS_WIN32) && !defined(_WIN32_WCE)
+ if (IsBadStringPtrW(*(wchar_t **)ptr, -1)) {
+ PyErr_Format(PyExc_ValueError,
+ "invalid string pointer %p",
+ *(wchar_t **)ptr);
+ return NULL;
+ }
+#endif
return PyUnicode_FromWideChar(p, wcslen(p));
- else {
+ } else {
Py_INCREF(Py_None);
return Py_None;
}
Modified: stackless/branches/release25-maint/Modules/_ctypes/stgdict.c
==============================================================================
--- stackless/branches/release25-maint/Modules/_ctypes/stgdict.c (original)
+++ stackless/branches/release25-maint/Modules/_ctypes/stgdict.c Tue May 8 11:04:01 2007
@@ -72,8 +72,10 @@
return 0;
size = sizeof(ffi_type *) * (src->length + 1);
dst->ffi_type_pointer.elements = PyMem_Malloc(size);
- if (dst->ffi_type_pointer.elements == NULL)
+ if (dst->ffi_type_pointer.elements == NULL) {
+ PyErr_NoMemory();
return -1;
+ }
memcpy(dst->ffi_type_pointer.elements,
src->ffi_type_pointer.elements,
size);
@@ -359,6 +361,10 @@
total_align = align ? align : 1;
stgdict->ffi_type_pointer.type = FFI_TYPE_STRUCT;
stgdict->ffi_type_pointer.elements = PyMem_Malloc(sizeof(ffi_type *) * (basedict->length + len + 1));
+ if (stgdict->ffi_type_pointer.elements == NULL) {
+ PyErr_NoMemory();
+ return -1;
+ }
memset(stgdict->ffi_type_pointer.elements, 0,
sizeof(ffi_type *) * (basedict->length + len + 1));
memcpy(stgdict->ffi_type_pointer.elements,
@@ -373,6 +379,10 @@
total_align = 1;
stgdict->ffi_type_pointer.type = FFI_TYPE_STRUCT;
stgdict->ffi_type_pointer.elements = PyMem_Malloc(sizeof(ffi_type *) * (len + 1));
+ if (stgdict->ffi_type_pointer.elements == NULL) {
+ PyErr_NoMemory();
+ return -1;
+ }
memset(stgdict->ffi_type_pointer.elements, 0,
sizeof(ffi_type *) * (len + 1));
ffi_ofs = 0;
Modified: stackless/branches/release25-maint/Modules/binascii.c
==============================================================================
--- stackless/branches/release25-maint/Modules/binascii.c (original)
+++ stackless/branches/release25-maint/Modules/binascii.c Tue May 8 11:04:01 2007
@@ -1160,12 +1160,14 @@
if ((data[in] > 126) ||
(data[in] == '=') ||
(header && data[in] == '_') ||
- ((data[in] == '.') && (linelen == 1)) ||
+ ((data[in] == '.') && (linelen == 0) &&
+ (data[in+1] == '\n' || data[in+1] == '\r' || data[in+1] == 0)) ||
(!istext && ((data[in] == '\r') || (data[in] == '\n'))) ||
((data[in] == '\t' || data[in] == ' ') && (in + 1 == datalen)) ||
((data[in] < 33) &&
(data[in] != '\r') && (data[in] != '\n') &&
- (quotetabs && ((data[in] != '\t') || (data[in] != ' ')))))
+ (quotetabs ||
+ (!quotetabs && ((data[in] != '\t') && (data[in] != ' '))))))
{
if ((linelen + 3) >= MAXLINESIZE) {
linelen = 0;
@@ -1230,12 +1232,14 @@
if ((data[in] > 126) ||
(data[in] == '=') ||
(header && data[in] == '_') ||
- ((data[in] == '.') && (linelen == 1)) ||
+ ((data[in] == '.') && (linelen == 0) &&
+ (data[in+1] == '\n' || data[in+1] == '\r' || data[in+1] == 0)) ||
(!istext && ((data[in] == '\r') || (data[in] == '\n'))) ||
((data[in] == '\t' || data[in] == ' ') && (in + 1 == datalen)) ||
((data[in] < 33) &&
(data[in] != '\r') && (data[in] != '\n') &&
- (quotetabs && ((data[in] != '\t') || (data[in] != ' ')))))
+ (quotetabs ||
+ (!quotetabs && ((data[in] != '\t') && (data[in] != ' '))))))
{
if ((linelen + 3 )>= MAXLINESIZE) {
odata[out++] = '=';
Modified: stackless/branches/release25-maint/Modules/cPickle.c
==============================================================================
--- stackless/branches/release25-maint/Modules/cPickle.c (original)
+++ stackless/branches/release25-maint/Modules/cPickle.c Tue May 8 11:04:01 2007
@@ -538,11 +538,12 @@
self->buf_size = size;
}
else if (n > self->buf_size) {
- self->buf = (char *)realloc(self->buf, n);
- if (!self->buf) {
+ char *newbuf = (char *)realloc(self->buf, n);
+ if (!newbuf) {
PyErr_NoMemory();
return -1;
}
+ self->buf = newbuf;
self->buf_size = n;
}
@@ -581,6 +582,7 @@
i = 0;
while (1) {
int bigger;
+ char *newbuf;
for (; i < (self->buf_size - 1); i++) {
if (feof(self->fp) ||
(self->buf[i] = getc(self->fp)) == '\n') {
@@ -594,11 +596,12 @@
PyErr_NoMemory();
return -1;
}
- self->buf = (char *)realloc(self->buf, bigger);
- if (!self->buf) {
+ newbuf = (char *)realloc(self->buf, bigger);
+ if (!newbuf) {
PyErr_NoMemory();
return -1;
}
+ self->buf = newbuf;
self->buf_size = bigger;
}
}
@@ -4437,17 +4440,19 @@
*/
if ((self->num_marks + 1) >= self->marks_size) {
+ int *marks;
s=self->marks_size+20;
if (s <= self->num_marks) s=self->num_marks + 1;
if (self->marks == NULL)
- self->marks=(int *)malloc(s * sizeof(int));
+ marks=(int *)malloc(s * sizeof(int));
else
- self->marks=(int *)realloc(self->marks,
+ marks=(int *)realloc(self->marks,
s * sizeof(int));
- if (! self->marks) {
+ if (!marks) {
PyErr_NoMemory();
return -1;
}
+ self->marks = marks;
self->marks_size = s;
}
Modified: stackless/branches/release25-maint/Modules/cStringIO.c
==============================================================================
--- stackless/branches/release25-maint/Modules/cStringIO.c (original)
+++ stackless/branches/release25-maint/Modules/cStringIO.c Tue May 8 11:04:01 2007
@@ -339,13 +339,17 @@
}
if (position > self->buf_size) {
+ char *newbuf;
self->buf_size*=2;
if (self->buf_size <= position) self->buf_size=position+1;
- self->buf = (char*) realloc(self->buf,self->buf_size);
- if (!self->buf) {
+ newbuf = (char*) realloc(self->buf,self->buf_size);
+ if (!newbuf) {
+ free(self->buf);
+ self->buf = 0;
self->buf_size=self->pos=0;
return PyErr_NoMemory();
}
+ self->buf = newbuf;
}
else if (position < 0) position=0;
@@ -366,6 +370,7 @@
O_cwrite(PyObject *self, const char *c, Py_ssize_t l) {
Py_ssize_t newl;
Oobject *oself;
+ char *newbuf;
if (!IO__opencheck(IOOOBJECT(self))) return -1;
oself = (Oobject *)self;
@@ -377,12 +382,15 @@
assert(newl + 1 < INT_MAX);
oself->buf_size = (int)(newl+1);
}
- oself->buf = (char*)realloc(oself->buf, oself->buf_size);
- if (!oself->buf) {
+ newbuf = (char*)realloc(oself->buf, oself->buf_size);
+ if (!newbuf) {
PyErr_SetString(PyExc_MemoryError,"out of memory");
+ free(oself->buf);
+ oself->buf = 0;
oself->buf_size = oself->pos = 0;
return -1;
}
+ oself->buf = newbuf;
}
memcpy(oself->buf+oself->pos,c,l);
Modified: stackless/branches/release25-maint/Modules/itertoolsmodule.c
==============================================================================
--- stackless/branches/release25-maint/Modules/itertoolsmodule.c (original)
+++ stackless/branches/release25-maint/Modules/itertoolsmodule.c Tue May 8 11:04:01 2007
@@ -2073,9 +2073,9 @@
static PyObject *
count_next(countobject *lz)
{
- if (lz->cnt == LONG_MAX) {
+ if (lz->cnt == PY_SSIZE_T_MAX) {
PyErr_SetString(PyExc_OverflowError,
- "cannot count beyond LONG_MAX");
+ "cannot count beyond PY_SSIZE_T_MAX");
return NULL;
}
return PyInt_FromSsize_t(lz->cnt++);
Modified: stackless/branches/release25-maint/Modules/posixmodule.c
==============================================================================
--- stackless/branches/release25-maint/Modules/posixmodule.c (original)
+++ stackless/branches/release25-maint/Modules/posixmodule.c Tue May 8 11:04:01 2007
@@ -4788,18 +4788,19 @@
(sizeof(modulepath)/sizeof(modulepath[0]))
-strlen(modulepath));
if (stat(modulepath, &statinfo) != 0) {
+ size_t mplen = sizeof(modulepath)/sizeof(modulepath[0]);
/* Eeek - file-not-found - possibly an embedding
situation - see if we can locate it in sys.prefix
*/
strncpy(modulepath,
Py_GetExecPrefix(),
- sizeof(modulepath)/sizeof(modulepath[0]));
+ mplen);
+ modulepath[mplen-1] = '\0';
if (modulepath[strlen(modulepath)-1] != '\\')
strcat(modulepath, "\\");
strncat(modulepath,
szConsoleSpawn,
- (sizeof(modulepath)/sizeof(modulepath[0]))
- -strlen(modulepath));
+ mplen-strlen(modulepath));
/* No where else to look - raise an easily identifiable
error, rather than leaving Windows to report
"file not found" - as the user is probably blissfully
@@ -6169,16 +6170,23 @@
posix_fdopen(PyObject *self, PyObject *args)
{
int fd;
- char *mode = "r";
+ char *orgmode = "r";
int bufsize = -1;
FILE *fp;
PyObject *f;
- if (!PyArg_ParseTuple(args, "i|si", &fd, &mode, &bufsize))
+ char *mode;
+ if (!PyArg_ParseTuple(args, "i|si", &fd, &orgmode, &bufsize))
return NULL;
- if (mode[0] != 'r' && mode[0] != 'w' && mode[0] != 'a') {
- PyErr_Format(PyExc_ValueError,
- "invalid file mode '%s'", mode);
+ /* Sanitize mode. See fileobject.c */
+ mode = PyMem_MALLOC(strlen(orgmode)+3);
+ if (!mode) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+ strcpy(mode, orgmode);
+ if (_PyFile_SanitizeMode(mode)) {
+ PyMem_FREE(mode);
return NULL;
}
Py_BEGIN_ALLOW_THREADS
@@ -6199,10 +6207,11 @@
#else
fp = fdopen(fd, mode);
#endif
+ PyMem_FREE(mode);
Py_END_ALLOW_THREADS
if (fp == NULL)
return posix_error();
- f = PyFile_FromFile(fp, "", mode, fclose);
+ f = PyFile_FromFile(fp, "", orgmode, fclose);
if (f != NULL)
PyFile_SetBufSize(f, bufsize);
return f;
Modified: stackless/branches/release25-maint/Objects/classobject.c
==============================================================================
--- stackless/branches/release25-maint/Objects/classobject.c (original)
+++ stackless/branches/release25-maint/Objects/classobject.c Tue May 8 11:04:01 2007
@@ -1540,6 +1540,18 @@
return generic_unary_op(self, o); \
}
+/* unary function with a fallback */
+#define UNARY_FB(funcname, methodname, funcname_fb) \
+static PyObject *funcname(PyInstanceObject *self) { \
+ static PyObject *o; \
+ if (o == NULL) { o = PyString_InternFromString(methodname); \
+ if (o == NULL) return NULL; } \
+ if (PyObject_HasAttr((PyObject*)self, o)) \
+ return generic_unary_op(self, o); \
+ else \
+ return funcname_fb(self); \
+}
+
#define BINARY(f, m, n) \
static PyObject *f(PyObject *v, PyObject *w) { \
return do_binop(v, w, "__" m "__", "__r" m "__", n); \
@@ -1778,7 +1790,7 @@
UNARY(instance_invert, "__invert__")
UNARY(instance_int, "__int__")
-UNARY(instance_long, "__long__")
+UNARY_FB(instance_long, "__long__", instance_int)
UNARY(instance_float, "__float__")
UNARY(instance_oct, "__oct__")
UNARY(instance_hex, "__hex__")
Modified: stackless/branches/release25-maint/Objects/exceptions.c
==============================================================================
--- stackless/branches/release25-maint/Objects/exceptions.c (original)
+++ stackless/branches/release25-maint/Objects/exceptions.c Tue May 8 11:04:01 2007
@@ -33,6 +33,8 @@
PyBaseExceptionObject *self;
self = (PyBaseExceptionObject *)type->tp_alloc(type, 0);
+ if (!self)
+ return NULL;
/* the dict is created on the fly in PyObject_GenericSetAttr */
self->message = self->dict = NULL;
Modified: stackless/branches/release25-maint/Objects/fileobject.c
==============================================================================
--- stackless/branches/release25-maint/Objects/fileobject.c (original)
+++ stackless/branches/release25-maint/Objects/fileobject.c Tue May 8 11:04:01 2007
@@ -139,17 +139,16 @@
ignore stuff they don't understand... write or append mode with
universal newline support is expressly forbidden by PEP 278.
Additionally, remove the 'U' from the mode string as platforms
- won't know what it is. */
-/* zero return is kewl - one is un-kewl */
-static int
-sanitize_the_mode(char *mode)
+ won't know what it is. Non-zero return signals an exception */
+int
+_PyFile_SanitizeMode(char *mode)
{
char *upos;
size_t len = strlen(mode);
if (!len) {
PyErr_SetString(PyExc_ValueError, "empty mode string");
- return 1;
+ return -1;
}
upos = strchr(mode, 'U');
@@ -160,7 +159,7 @@
PyErr_Format(PyExc_ValueError, "universal newline "
"mode can only be used with modes "
"starting with 'r'");
- return 1;
+ return -1;
}
if (mode[0] != 'r') {
@@ -175,7 +174,7 @@
} else if (mode[0] != 'r' && mode[0] != 'w' && mode[0] != 'a') {
PyErr_Format(PyExc_ValueError, "mode string must begin with "
"one of 'r', 'w', 'a' or 'U', not '%.200s'", mode);
- return 1;
+ return -1;
}
return 0;
@@ -204,7 +203,7 @@
}
strcpy(newmode, mode);
- if (sanitize_the_mode(newmode)) {
+ if (_PyFile_SanitizeMode(newmode)) {
f = NULL;
goto cleanup;
}
Modified: stackless/branches/release25-maint/Objects/longobject.c
==============================================================================
--- stackless/branches/release25-maint/Objects/longobject.c (original)
+++ stackless/branches/release25-maint/Objects/longobject.c Tue May 8 11:04:01 2007
@@ -893,7 +893,7 @@
int one = 1;
return _PyLong_FromByteArray(
(unsigned char *)&bytes,
- SIZEOF_SIZE_T, IS_LITTLE_ENDIAN, 0);
+ SIZEOF_SIZE_T, IS_LITTLE_ENDIAN, 1);
}
/* Create a new long int object from a C size_t. */
@@ -1739,6 +1739,8 @@
a->ob_digit[size_a-1] < b->ob_digit[size_b-1])) {
/* |a| < |b|. */
*pdiv = _PyLong_New(0);
+ if (*pdiv == NULL)
+ return -1;
Py_INCREF(a);
*prem = (PyLongObject *) a;
return 0;
@@ -1749,6 +1751,10 @@
if (z == NULL)
return -1;
*prem = (PyLongObject *) PyLong_FromLong((long)rem);
+ if (*prem == NULL) {
+ Py_DECREF(z);
+ return -1;
+ }
}
else {
z = x_divrem(a, b, prem);
@@ -3204,6 +3210,8 @@
{
if (PyInt_Check(*pw)) {
*pw = PyLong_FromLong(PyInt_AS_LONG(*pw));
+ if (*pw == NULL)
+ return -1;
Py_INCREF(*pv);
return 0;
}
Modified: stackless/branches/release25-maint/PC/_winreg.c
==============================================================================
--- stackless/branches/release25-maint/PC/_winreg.c (original)
+++ stackless/branches/release25-maint/PC/_winreg.c Tue May 8 11:04:01 2007
@@ -699,7 +699,7 @@
case REG_DWORD:
if (value != Py_None && !PyInt_Check(value))
return FALSE;
- *retDataBuf = (BYTE *)PyMem_NEW(DWORD, sizeof(DWORD));
+ *retDataBuf = (BYTE *)PyMem_NEW(DWORD, 1);
if (*retDataBuf==NULL){
PyErr_NoMemory();
return FALSE;
Modified: stackless/branches/release25-maint/Python/dynload_win.c
==============================================================================
--- stackless/branches/release25-maint/Python/dynload_win.c (original)
+++ stackless/branches/release25-maint/Python/dynload_win.c Tue May 8 11:04:01 2007
@@ -13,16 +13,8 @@
const struct filedescr _PyImport_DynLoadFiletab[] = {
#ifdef _DEBUG
{"_d.pyd", "rb", C_EXTENSION},
- /* Temporarily disable .dll, to avoid conflicts between sqlite3.dll
- and the sqlite3 package. If this needs to be reverted for 2.5,
- some other solution for the naming conflict must be found.
- {"_d.dll", "rb", C_EXTENSION},
- */
#else
{".pyd", "rb", C_EXTENSION},
- /* Likewise
- {".dll", "rb", C_EXTENSION},
- */
#endif
{0, 0}
};
Modified: stackless/branches/release25-maint/Python/thread_nt.h
==============================================================================
--- stackless/branches/release25-maint/Python/thread_nt.h (original)
+++ stackless/branches/release25-maint/Python/thread_nt.h Tue May 8 11:04:01 2007
@@ -15,14 +15,14 @@
HANDLE hevent ;
} NRMUTEX, *PNRMUTEX ;
-typedef PVOID WINAPI interlocked_cmp_xchg_t(PVOID *dest, PVOID exc, PVOID comperand) ;
+typedef LONG WINAPI interlocked_cmp_xchg_t(LONG volatile *dest, LONG exc, LONG comperand) ;
/* Sorry mate, but we haven't got InterlockedCompareExchange in Win95! */
-static PVOID WINAPI
-interlocked_cmp_xchg(PVOID *dest, PVOID exc, PVOID comperand)
+static LONG WINAPI
+interlocked_cmp_xchg(LONG volatile *dest, LONG exc, LONG comperand)
{
static LONG spinlock = 0 ;
- PVOID result ;
+ LONG result ;
DWORD dwSleep = 0;
/* Acqire spinlock (yielding control to other threads if cant aquire for the moment) */
@@ -76,10 +76,12 @@
return mutex->hevent != NULL ; /* TRUE if the mutex is created */
}
+#ifndef MS_WIN64
#ifdef InterlockedCompareExchange
#undef InterlockedCompareExchange
#endif
#define InterlockedCompareExchange(dest,exchange,comperand) (ixchg((dest), (exchange), (comperand)))
+#endif
VOID
DeleteNonRecursiveMutex(PNRMUTEX mutex)
@@ -98,7 +100,7 @@
/* InterlockedIncrement(&mutex->owned) == 0 means that no thread currently owns the mutex */
if (!wait)
{
- if (InterlockedCompareExchange((PVOID *)&mutex->owned, (PVOID)0, (PVOID)-1) != (PVOID)-1)
+ if (InterlockedCompareExchange(&mutex->owned, 0, -1) != -1)
return WAIT_TIMEOUT ;
ret = WAIT_OBJECT_0 ;
}
@@ -202,12 +204,12 @@
* too many threads".
*/
dprintf(("%ld: PyThread_start_new_thread failed: %p errno %d\n",
- PyThread_get_thread_ident(), rv, errno));
+ PyThread_get_thread_ident(), (void*)rv, errno));
obj.id = -1;
}
else {
dprintf(("%ld: PyThread_start_new_thread succeeded: %p\n",
- PyThread_get_thread_ident(), rv));
+ PyThread_get_thread_ident(), (void*)rv));
/* wait for thread to initialize, so we can get its id */
WaitForSingleObject(obj.done, INFINITE);
assert(obj.id != -1);
@@ -333,7 +335,7 @@
dprintf(("%ld: PyThread_release_lock(%p) called\n", PyThread_get_thread_ident(),aLock));
if (!(aLock && LeaveNonRecursiveMutex((PNRMUTEX) aLock)))
- dprintf(("%ld: Could not PyThread_release_lock(%p) error: %l\n", PyThread_get_thread_ident(), aLock, GetLastError()));
+ dprintf(("%ld: Could not PyThread_release_lock(%p) error: %ld\n", PyThread_get_thread_ident(), aLock, GetLastError()));
}
/* minimum/maximum thread stack sizes supported */
_______________________________________________
Stackless-checkins mailing list
Stackless-checkins at stackless.com
http://www.stackless.com/mailman/listinfo/stackless-checkins