Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Checkins

cpython (merge 3.2 -> default): merge 3.2

 

 

First page Previous page 1 2 3 4 5 6 7 8 Next page Last page  View All Python checkins RSS feed   Index | Next | Previous | View Threaded


python-checkins at python

Mar 12, 2011, 9:58 AM

Post #1 of 192 (656 views)
Permalink
cpython (merge 3.2 -> default): merge 3.2

http://hg.python.org/cpython/rev/9e70e818d434
changeset: 68402:9e70e818d434
parent: 68399:ee259a4f3eee
parent: 68401:45d76bb9fbcd
user: Benjamin Peterson <benjamin [at] python>
date: Sat Mar 12 11:59:10 2011 -0600
summary:
merge 3.2

files:


diff --git a/Doc/library/numbers.rst b/Doc/library/numbers.rst
--- a/Doc/library/numbers.rst
+++ b/Doc/library/numbers.rst
@@ -45,7 +45,7 @@
To :class:`Complex`, :class:`Real` adds the operations that work on real
numbers.

- In short, those are: a conversion to :class:`float`, :func:`trunc`,
+ In short, those are: a conversion to :class:`float`, :func:`math.trunc`,
:func:`round`, :func:`math.floor`, :func:`math.ceil`, :func:`divmod`, ``//``,
``%``, ``<``, ``<=``, ``>``, and ``>=``.


--
Repository URL: http://hg.python.org/cpython


python-checkins at python

Mar 15, 2011, 1:08 PM

Post #2 of 192 (628 views)
Permalink
cpython (merge 3.2 -> default): merge 3.2 [In reply to]

http://hg.python.org/cpython/rev/c23b53882996
changeset: 68539:c23b53882996
parent: 68528:fbdcc7437b34
parent: 68538:68acbf72290c
user: Benjamin Peterson <benjamin [at] python>
date: Tue Mar 15 15:05:22 2011 -0500
summary:
merge 3.2

files:
Include/patchlevel.h
Lib/test/test_subprocess.py

diff --git a/Include/patchlevel.h b/Include/patchlevel.h
--- a/Include/patchlevel.h
+++ b/Include/patchlevel.h
@@ -26,8 +26,9 @@
#define PY_VERSION "3.3a0"
/*--end constants--*/

-/* Subversion Revision number of this file (not of the repository) */
-#define PY_PATCHLEVEL_REVISION "$Revision$"
+/* Subversion Revision number of this file (not of the repository). Empty
+ since Mercurial migration. */
+#define PY_PATCHLEVEL_REVISION ""

/* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2.
Use this for numeric comparisons, e.g. #if PY_VERSION_HEX >= ... */

--
Repository URL: http://hg.python.org/cpython


python-checkins at python

Mar 15, 2011, 1:08 PM

Post #3 of 192 (627 views)
Permalink
cpython (merge 3.2 -> default): merge 3.2 [In reply to]

http://hg.python.org/cpython/rev/5798168e35ff
changeset: 68543:5798168e35ff
parent: 68541:e09609770999
parent: 68542:ccea53bd4f88
user: Benjamin Peterson <benjamin [at] python>
date: Tue Mar 15 15:10:29 2011 -0500
summary:
merge 3.2

files:



--
Repository URL: http://hg.python.org/cpython


python-checkins at python

Mar 15, 2011, 4:21 PM

Post #4 of 192 (627 views)
Permalink
cpython (merge 3.2 -> default): merge 3.2 [In reply to]

http://hg.python.org/cpython/rev/60866549e653
changeset: 68576:60866549e653
parent: 68574:0a3b00d2c31c
parent: 68575:8c7eac34f7bf
user: Michael Foord <michael [at] python>
date: Tue Mar 15 19:22:19 2011 -0400
summary:
merge 3.2

files:
Misc/NEWS

diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst
--- a/Doc/library/inspect.rst
+++ b/Doc/library/inspect.rst
@@ -589,14 +589,11 @@
that raise AttributeError). It can also return descriptors objects
instead of instance members.

+ If the instance `__dict__` is shadowed by another member (for example a
+ property) then this function will be unable to find instance members.
+
.. versionadded:: 3.2

-The only known case that can cause `getattr_static` to trigger code execution,
-and cause it to return incorrect results (or even break), is where a class uses
-:data:`~object.__slots__` and provides a `__dict__` member using a property or
-descriptor. If you find other cases please report them so they can be fixed
-or documented.
-
`getattr_static` does not resolve descriptors, for example slot descriptors or
getset descriptors on objects implemented in C. The descriptor object
is returned instead of the underlying attribute.
diff --git a/Lib/inspect.py b/Lib/inspect.py
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -1069,15 +1069,16 @@
instance_dict = object.__getattribute__(obj, "__dict__")
except AttributeError:
pass
- return instance_dict.get(attr, _sentinel)
+ return dict.get(instance_dict, attr, _sentinel)


def _check_class(klass, attr):
for entry in _static_getmro(klass):
- try:
- return entry.__dict__[attr]
- except KeyError:
- pass
+ if not _shadowed_dict(type(entry)):
+ try:
+ return entry.__dict__[attr]
+ except KeyError:
+ pass
return _sentinel

def _is_type(obj):
@@ -1087,6 +1088,19 @@
return False
return True

+def _shadowed_dict(klass):
+ dict_attr = type.__dict__["__dict__"]
+ for entry in _static_getmro(klass):
+ try:
+ class_dict = dict_attr.__get__(entry)["__dict__"]
+ except KeyError:
+ pass
+ else:
+ if not (type(class_dict) is types.GetSetDescriptorType and
+ class_dict.__name__ == "__dict__" and
+ class_dict.__objclass__ is entry):
+ return True
+ return False

def getattr_static(obj, attr, default=_sentinel):
"""Retrieve attributes without triggering dynamic lookup via the
@@ -1101,8 +1115,9 @@
"""
instance_result = _sentinel
if not _is_type(obj):
- instance_result = _check_instance(obj, attr)
klass = type(obj)
+ if not _shadowed_dict(klass):
+ instance_result = _check_instance(obj, attr)
else:
klass = obj

diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -906,6 +906,53 @@
self.assertEqual(inspect.getattr_static(Something(), 'foo'), 3)
self.assertEqual(inspect.getattr_static(Something, 'foo'), 3)

+ def test_dict_as_property(self):
+ test = self
+ test.called = False
+
+ class Foo(dict):
+ a = 3
+ @property
+ def __dict__(self):
+ test.called = True
+ return {}
+
+ foo = Foo()
+ foo.a = 4
+ self.assertEqual(inspect.getattr_static(foo, 'a'), 3)
+ self.assertFalse(test.called)
+
+ def test_custom_object_dict(self):
+ test = self
+ test.called = False
+
+ class Custom(dict):
+ def get(self, key, default=None):
+ test.called = True
+ super().get(key, default)
+
+ class Foo(object):
+ a = 3
+ foo = Foo()
+ foo.__dict__ = Custom()
+ self.assertEqual(inspect.getattr_static(foo, 'a'), 3)
+ self.assertFalse(test.called)
+
+ def test_metaclass_dict_as_property(self):
+ class Meta(type):
+ @property
+ def __dict__(self):
+ self.executed = True
+
+ class Thing(metaclass=Meta):
+ executed = False
+
+ def __init__(self):
+ self.spam = 42
+
+ instance = Thing()
+ self.assertEqual(inspect.getattr_static(instance, "spam"), 42)
+ self.assertFalse(Thing.executed)

class TestGetGeneratorState(unittest.TestCase):

diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -72,6 +72,9 @@
Library
-------

+- Issue #11133: fix two cases where inspect.getattr_static can trigger code
+ execution. Patch by Daniel Urban.
+
- Issue #11501: disutils.archive_utils.make_zipfile no longer fails if zlib is
not installed. Instead, the zipfile.ZIP_STORED compression is used to create
the ZipFile. Patch by Natalia B. Bidart.

--
Repository URL: http://hg.python.org/cpython


python-checkins at python

Mar 16, 2011, 8:29 AM

Post #5 of 192 (629 views)
Permalink
cpython (merge 3.2 -> default): merge 3.2 [In reply to]

http://hg.python.org/cpython/rev/f0d3a3699593
changeset: 68599:f0d3a3699593
parent: 68597:e33e45cc4ea8
parent: 68598:382cb3386d57
user: Benjamin Peterson <benjamin [at] python>
date: Wed Mar 16 10:29:37 2011 -0500
summary:
merge 3.2

files:
Misc/NEWS

diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -73,7 +73,7 @@
-------

- Issue #11133: fix two cases where inspect.getattr_static can trigger code
- execution. Patch by Daniel Urban.
+ execution. Patch by Andreas Stührk.

- Issue #11569: use absolute path to the sysctl command in multiprocessing to
ensure that it will be found regardless of the shell PATH. This ensures

--
Repository URL: http://hg.python.org/cpython


python-checkins at python

Mar 16, 2011, 2:28 PM

Post #6 of 192 (622 views)
Permalink
cpython (merge 3.2 -> default): merge 3.2 [In reply to]

http://hg.python.org/cpython/rev/fab66eb4773d
changeset: 68622:fab66eb4773d
parent: 68620:84b7a68445aa
parent: 68621:f11da6cecffd
user: Michael Foord <michael [at] python>
date: Wed Mar 16 17:28:51 2011 -0400
summary:
merge 3.2

files:
Misc/NEWS

diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py
--- a/Lib/test/test_posixpath.py
+++ b/Lib/test/test_posixpath.py
@@ -6,6 +6,11 @@
import sys
from posixpath import realpath, abspath, dirname, basename

+try:
+ import posix
+except ImportError:
+ posix = None
+
# An absolute path to a temporary filename for testing. We can't rely on TESTFN
# being an absolute path, so we need this.

@@ -150,6 +155,7 @@

def test_islink(self):
self.assertIs(posixpath.islink(support.TESTFN + "1"), False)
+ self.assertIs(posixpath.lexists(support.TESTFN + "2"), False)
f = open(support.TESTFN + "1", "wb")
try:
f.write(b"foo")
@@ -225,6 +231,44 @@

def test_ismount(self):
self.assertIs(posixpath.ismount("/"), True)
+ self.assertIs(posixpath.ismount(b"/"), True)
+
+ def test_ismount_non_existent(self):
+ # Non-existent mountpoint.
+ self.assertIs(posixpath.ismount(ABSTFN), False)
+ try:
+ os.mkdir(ABSTFN)
+ self.assertIs(posixpath.ismount(ABSTFN), False)
+ finally:
+ safe_rmdir(ABSTFN)
+
+ @unittest.skipUnless(support.can_symlink(),
+ "Test requires symlink support")
+ def test_ismount_symlinks(self):
+ # Symlinks are never mountpoints.
+ try:
+ os.symlink("/", ABSTFN)
+ self.assertIs(posixpath.ismount(ABSTFN), False)
+ finally:
+ os.unlink(ABSTFN)
+
+ @unittest.skipIf(posix is None, "Test requires posix module")
+ def test_ismount_different_device(self):
+ # Simulate the path being on a different device from its parent by
+ # mocking out st_dev.
+ save_lstat = os.lstat
+ def fake_lstat(path):
+ st_ino = 0
+ st_dev = 0
+ if path == ABSTFN:
+ st_dev = 1
+ st_ino = 1
+ return posix.stat_result((0, st_ino, st_dev, 0, 0, 0, 0, 0, 0, 0))
+ try:
+ os.lstat = fake_lstat
+ self.assertIs(posixpath.ismount(ABSTFN), True)
+ finally:
+ os.lstat = save_lstat

def test_expanduser(self):
self.assertEqual(posixpath.expanduser("foo"), "foo")
@@ -254,6 +298,10 @@
with support.EnvironmentVarGuard() as env:
env['HOME'] = '/'
self.assertEqual(posixpath.expanduser("~"), "/")
+ # expanduser should fall back to using the password database
+ del env['HOME']
+ home = pwd.getpwuid(os.getuid()).pw_dir
+ self.assertEqual(posixpath.expanduser("~"), home)

def test_normpath(self):
self.assertEqual(posixpath.normpath(""), ".")
@@ -289,6 +337,16 @@
@unittest.skipUnless(hasattr(os, "symlink"),
"Missing symlink implementation")
@skip_if_ABSTFN_contains_backslash
+ def test_realpath_relative(self):
+ try:
+ os.symlink(posixpath.relpath(ABSTFN+"1"), ABSTFN)
+ self.assertEqual(realpath(ABSTFN), ABSTFN+"1")
+ finally:
+ support.unlink(ABSTFN)
+
+ @unittest.skipUnless(hasattr(os, "symlink"),
+ "Missing symlink implementation")
+ @skip_if_ABSTFN_contains_backslash
def test_realpath_symlink_loops(self):
# Bug #930024, return the path unchanged if we get into an infinite
# symlink loop.
@@ -443,6 +501,11 @@
finally:
os.getcwdb = real_getcwdb

+ def test_sameopenfile(self):
+ fname = support.TESTFN + "1"
+ with open(fname, "wb") as a, open(fname, "wb") as b:
+ self.assertTrue(posixpath.sameopenfile(a.fileno(), b.fileno()))
+

class PosixCommonTest(test_genericpath.CommonTest):
pathmodule = posixpath
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -236,6 +236,11 @@
Tests
-----

+- Issue #11503: improve test coverage of posixpath.py. Patch by Evan Dandrea.
+
+- Issue #11505: improves test coverage of string.py. Patch by Alicia
+ Arlen.
+
- Issue #11548: Improve test coverage of the shutil module. Patch by
Evan Dandrea.


--
Repository URL: http://hg.python.org/cpython


python-checkins at python

Mar 20, 2011, 6:15 PM

Post #7 of 192 (617 views)
Permalink
cpython (merge 3.2 -> default): merge 3.2 [In reply to]

http://hg.python.org/cpython/rev/a6f3fa489f8d
changeset: 68784:a6f3fa489f8d
parent: 68782:cbd86ac6cc81
parent: 68783:be74f446b4b8
user: Victor Stinner <victor.stinner [at] haypocalc>
date: Mon Mar 21 02:15:18 2011 +0100
summary:
merge 3.2

files:


diff --git a/Modules/timemodule.c b/Modules/timemodule.c
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -476,9 +476,8 @@

#if defined(_MSC_VER) || defined(sun)
if (buf.tm_year + 1900 < 1 || 9999 < buf.tm_year + 1900) {
- PyErr_Format(PyExc_ValueError,
- "strftime() requires year in [1; 9999]",
- buf.tm_year + 1900);
+ PyErr_SetString(PyExc_ValueError,
+ "strftime() requires year in [1; 9999]");
return NULL;
}
#endif

--
Repository URL: http://hg.python.org/cpython


python-checkins at python

Mar 20, 2011, 6:53 PM

Post #8 of 192 (616 views)
Permalink
cpython (merge 3.2 -> default): merge 3.2 [In reply to]

http://hg.python.org/cpython/rev/2c346063471b
changeset: 68787:2c346063471b
parent: 68784:a6f3fa489f8d
parent: 68786:7113319e4dcc
user: Victor Stinner <victor.stinner [at] haypocalc>
date: Mon Mar 21 02:53:04 2011 +0100
summary:
merge 3.2

files:
Misc/NEWS

diff --git a/Lib/http/cookiejar.py b/Lib/http/cookiejar.py
--- a/Lib/http/cookiejar.py
+++ b/Lib/http/cookiejar.py
@@ -29,6 +29,7 @@
'FileCookieJar', 'LWPCookieJar', 'LoadError', 'MozillaCookieJar']

import copy
+import datetime
import re
import time
import urllib.parse, urllib.request
@@ -97,10 +98,12 @@
1994-11-24 08:49:37Z

"""
- if t is None: t = time.time()
- year, mon, mday, hour, min, sec = time.gmtime(t)[:6]
+ if t is None:
+ dt = datetime.datetime.utcnow()
+ else:
+ dt = datetime.datetime.utcfromtimestamp(t)
return "%04d-%02d-%02d %02d:%02d:%02dZ" % (
- year, mon, mday, hour, min, sec)
+ dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second)

def time2netscape(t=None):
"""Return a string representing time in seconds since epoch, t.
@@ -113,10 +116,13 @@
Wed, DD-Mon-YYYY HH:MM:SS GMT

"""
- if t is None: t = time.time()
- year, mon, mday, hour, min, sec, wday = time.gmtime(t)[:7]
+ if t is None:
+ dt = datetime.datetime.utcnow()
+ else:
+ dt = datetime.datetime.utcfromtimestamp(t)
return "%s %02d-%s-%04d %02d:%02d:%02d GMT" % (
- DAYS[wday], mday, MONTHS[mon-1], year, hour, min, sec)
+ DAYS[dt.weekday()], dt.day, MONTHS[dt.month-1],
+ dt.year, dt.hour, dt.minute, dt.second)


UTC_ZONES = {"GMT": None, "UTC": None, "UT": None, "Z": None}
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -81,6 +81,9 @@
Library
-------

+- Issue #5537: Fix time2isoz() and time2netscape() functions of
+ httplib.cookiejar for expiration year greater than 2038 on 32-bit systems.
+
- Issue #4391: Use proper gettext plural forms in optparse.

- Issue #11127: Raise a TypeError when trying to pickle a socket object.

--
Repository URL: http://hg.python.org/cpython


python-checkins at python

Mar 24, 2011, 8:39 AM

Post #9 of 192 (616 views)
Permalink
cpython (merge 3.2 -> default): Merge 3.2 [In reply to]

http://hg.python.org/cpython/rev/d944431a2b04
changeset: 68897:d944431a2b04
parent: 68894:d6bbde982c1c
parent: 68896:7a767910db5d
user: Victor Stinner <victor.stinner [at] haypocalc>
date: Thu Mar 24 16:39:34 2011 +0100
summary:
Merge 3.2

files:
Lib/test/test_multiprocessing.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)


diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py
--- a/Lib/test/test_multiprocessing.py
+++ b/Lib/test/test_multiprocessing.py
@@ -1100,7 +1100,7 @@
self.pool.terminate()
join = TimingWrapper(self.pool.join)
join()
- self.assertTrue(join.elapsed < 0.5)
+ self.assertLess(join.elapsed, 0.5)

def raising():
raise KeyError("key")

--
Repository URL: http://hg.python.org/cpython


python-checkins at python

Mar 25, 2011, 6:04 PM

Post #10 of 192 (619 views)
Permalink
cpython (merge 3.2 -> default): Merge 3.2 [In reply to]

http://hg.python.org/cpython/rev/3fda0eba5765
changeset: 68954:3fda0eba5765
parent: 68944:9ea72ff3527a
parent: 68953:089e8dc9a6d8
user: Éric Araujo <merwok [at] netwok>
date: Sat Mar 26 02:00:51 2011 +0100
summary:
Merge 3.2

files:
Doc/library/http.cookiejar.rst | 2 +-
Doc/library/readline.rst | 2 +-
Doc/library/sys.rst | 43 ++++++++-------------
Doc/tutorial/interactive.rst | 5 +--
4 files changed, 19 insertions(+), 33 deletions(-)


diff --git a/Doc/library/http.cookiejar.rst b/Doc/library/http.cookiejar.rst
--- a/Doc/library/http.cookiejar.rst
+++ b/Doc/library/http.cookiejar.rst
@@ -722,7 +722,7 @@

import os, http.cookiejar, urllib.request
cj = http.cookiejar.MozillaCookieJar()
- cj.load(os.path.join(os.environ["HOME"], ".netscape/cookies.txt"))
+ cj.load(os.path.join(os.path.expanduser("~"), ".netscape", "cookies.txt"))
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
r = opener.open("http://example.com/")

diff --git a/Doc/library/readline.rst b/Doc/library/readline.rst
--- a/Doc/library/readline.rst
+++ b/Doc/library/readline.rst
@@ -196,7 +196,7 @@

import os
import readline
- histfile = os.path.join(os.environ["HOME"], ".pyhist")
+ histfile = os.path.join(os.path.expanduser("~"), ".pyhist")
try:
readline.read_history_file(histfile)
except IOError:
diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst
--- a/Doc/library/sys.rst
+++ b/Doc/library/sys.rst
@@ -227,33 +227,22 @@
The struct sequence *flags* exposes the status of command line flags. The
attributes are read only.

- +------------------------------+------------------------------------------+
- | attribute | flag |
- +==============================+==========================================+
- | :const:`debug` | -d |
- +------------------------------+------------------------------------------+
- | :const:`division_warning` | -Q |
- +------------------------------+------------------------------------------+
- | :const:`inspect` | -i |
- +------------------------------+------------------------------------------+
- | :const:`interactive` | -i |
- +------------------------------+------------------------------------------+
- | :const:`optimize` | -O or -OO |
- +------------------------------+------------------------------------------+
- | :const:`dont_write_bytecode` | -B |
- +------------------------------+------------------------------------------+
- | :const:`no_user_site` | -s |
- +------------------------------+------------------------------------------+
- | :const:`no_site` | -S |
- +------------------------------+------------------------------------------+
- | :const:`ignore_environment` | -E |
- +------------------------------+------------------------------------------+
- | :const:`verbose` | -v |
- +------------------------------+------------------------------------------+
- | :const:`bytes_warning` | -b |
- +------------------------------+------------------------------------------+
- | :const:`quiet` | -q |
- +------------------------------+------------------------------------------+
+ ============================= =============================
+ attribute flag
+ ============================= =============================
+ :const:`debug` :option:`-d`
+ :const:`division_warning` :option:`-Q`
+ :const:`inspect` :option:`-i`
+ :const:`interactive` :option:`-i`
+ :const:`optimize` :option:`-O` or :option:`-OO`
+ :const:`dont_write_bytecode` :option:`-B`
+ :const:`no_user_site` :option:`-s`
+ :const:`no_site` :option:`-S`
+ :const:`ignore_environment` :option:`-E`
+ :const:`verbose` :option:`-v`
+ :const:`bytes_warning` :option:`-b`
+ :const:`quiet` :option:`-q`
+ ============================= =============================

.. versionchanged:: 3.2
Added ``quiet`` attribute for the new :option:`-q` flag.
diff --git a/Doc/tutorial/interactive.rst b/Doc/tutorial/interactive.rst
--- a/Doc/tutorial/interactive.rst
+++ b/Doc/tutorial/interactive.rst
@@ -123,10 +123,7 @@
# bound to the Esc key by default (you can change it - see readline docs).
#
# Store the file in ~/.pystartup, and set an environment variable to point
- # to it: "export PYTHONSTARTUP=/home/user/.pystartup" in bash.
- #
- # Note that PYTHONSTARTUP does *not* expand "~", so you have to put in the
- # full path to your home directory.
+ # to it: "export PYTHONSTARTUP=~/.pystartup" in bash.

import atexit
import os

--
Repository URL: http://hg.python.org/cpython


python-checkins at python

Mar 26, 2011, 4:17 PM

Post #11 of 192 (617 views)
Permalink
cpython (merge 3.2 -> default): merge 3.2 [In reply to]

http://hg.python.org/cpython/rev/b44156fdc7f2
changeset: 68998:b44156fdc7f2
parent: 68988:8bdc20468cbc
parent: 68997:d5c819d597fe
user: Benjamin Peterson <benjamin [at] python>
date: Sat Mar 26 18:18:09 2011 -0500
summary:
merge 3.2

files:
Lib/ctypes/test/test_as_parameter.py | 12 ++
Misc/NEWS | 6 +
Modules/_ctypes/_ctypes.c | 74 +++++++++++----
3 files changed, 72 insertions(+), 20 deletions(-)


diff --git a/Lib/ctypes/test/test_as_parameter.py b/Lib/ctypes/test/test_as_parameter.py
--- a/Lib/ctypes/test/test_as_parameter.py
+++ b/Lib/ctypes/test/test_as_parameter.py
@@ -187,6 +187,18 @@
self.assertEqual((s8i.a, s8i.b, s8i.c, s8i.d, s8i.e, s8i.f, s8i.g, s8i.h),
(9*2, 8*3, 7*4, 6*5, 5*6, 4*7, 3*8, 2*9))

+ def test_recursive_as_param(self):
+ from ctypes import c_int
+
+ class A(object):
+ pass
+
+ a = A()
+ a._as_parameter_ = a
+ with self.assertRaises(RuntimeError):
+ c_int.from_param(a)
+
+
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

class AsParamWrapper(object):
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -322,6 +322,12 @@

- Issue #11179: Make ccbench work under Python 3.1 and 2.7 again.

+Extensions
+----------
+
+- Issue #1838: Prevent segfault in ctypes, when _as_parameter_ on a class is set
+ to an instance of the class.
+
Tests
-----

diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -585,7 +585,10 @@
CDataType_from_param(PyObject *type, PyObject *value)
{
PyObject *as_parameter;
- if (1 == PyObject_IsInstance(value, type)) {
+ int res = PyObject_IsInstance(value, type);
+ if (res == -1)
+ return NULL;
+ if (res) {
Py_INCREF(value);
return value;
}
@@ -598,10 +601,14 @@

/* If we got a PyCArgObject, we must check if the object packed in it
is an instance of the type's dict->proto */
- if(dict && ob
- && PyObject_IsInstance(ob, dict->proto)) {
- Py_INCREF(value);
- return value;
+ if(dict && ob) {
+ res = PyObject_IsInstance(ob, dict->proto);
+ if (res == -1)
+ return NULL;
+ if (res) {
+ Py_INCREF(value);
+ return value;
+ }
}
ob_name = (ob) ? Py_TYPE(ob)->tp_name : "???";
PyErr_Format(PyExc_TypeError,
@@ -951,8 +958,7 @@
Py_INCREF(value); /* _byref steals a refcount */
return _byref(value);
case -1:
- PyErr_Clear();
- break;
+ return NULL;
default:
break;
}
@@ -1431,6 +1437,7 @@
c_wchar_p_from_param(PyObject *type, PyObject *value)
{
PyObject *as_parameter;
+ int res;
if (value == Py_None) {
Py_INCREF(Py_None);
return Py_None;
@@ -1451,7 +1458,10 @@
}
return (PyObject *)parg;
}
- if (PyObject_IsInstance(value, type)) {
+ res = PyObject_IsInstance(value, type);
+ if (res == -1)
+ return NULL;
+ if (res) {
Py_INCREF(value);
return value;
}
@@ -1492,6 +1502,7 @@
c_char_p_from_param(PyObject *type, PyObject *value)
{
PyObject *as_parameter;
+ int res;
if (value == Py_None) {
Py_INCREF(Py_None);
return Py_None;
@@ -1512,7 +1523,10 @@
}
return (PyObject *)parg;
}
- if (PyObject_IsInstance(value, type)) {
+ res = PyObject_IsInstance(value, type);
+ if (res == -1)
+ return NULL;
+ if (res) {
Py_INCREF(value);
return value;
}
@@ -1554,6 +1568,7 @@
{
StgDictObject *stgd;
PyObject *as_parameter;
+ int res;

/* None */
if (value == Py_None) {
@@ -1631,7 +1646,10 @@
return (PyObject *)parg;
}
/* c_void_p instance (or subclass) */
- if (PyObject_IsInstance(value, type)) {
+ res = PyObject_IsInstance(value, type);
+ if (res == -1)
+ return NULL;
+ if (res) {
/* c_void_p instances */
Py_INCREF(value);
return value;
@@ -1990,10 +2008,14 @@
PyCArgObject *parg;
struct fielddesc *fd;
PyObject *as_parameter;
+ int res;

/* If the value is already an instance of the requested type,
we can use it as is */
- if (1 == PyObject_IsInstance(value, type)) {
+ res = PyObject_IsInstance(value, type);
+ if (res == -1)
+ return NULL;
+ if (res) {
Py_INCREF(value);
return value;
}
@@ -2022,7 +2044,12 @@

as_parameter = PyObject_GetAttrString(value, "_as_parameter_");
if (as_parameter) {
+ if (Py_EnterRecursiveCall("while processing _as_parameter_")) {
+ Py_DECREF(as_parameter);
+ return NULL;
+ }
value = PyCSimpleType_from_param(type, as_parameter);
+ Py_LeaveRecursiveCall();
Py_DECREF(as_parameter);
return value;
}
@@ -2714,6 +2741,7 @@
Py_ssize_t size, char *ptr)
{
CDataObject *src;
+ int err;

if (setfunc)
return setfunc(ptr, value, size);
@@ -2754,7 +2782,10 @@
}
src = (CDataObject *)value;

- if (PyObject_IsInstance(value, type)) {
+ err = PyObject_IsInstance(value, type);
+ if (err == -1)
+ return NULL;
+ if (err) {
memcpy(ptr,
src->b_ptr,
size);
@@ -4749,14 +4780,17 @@
stgdict = PyObject_stgdict((PyObject *)self);
assert(stgdict); /* Cannot be NULL fr pointer instances */
assert(stgdict->proto);
- if (!CDataObject_Check(value)
- || 0 == PyObject_IsInstance(value, stgdict->proto)) {
- /* XXX PyObject_IsInstance could return -1! */
- PyErr_Format(PyExc_TypeError,
- "expected %s instead of %s",
- ((PyTypeObject *)(stgdict->proto))->tp_name,
- Py_TYPE(value)->tp_name);
- return -1;
+ if (!CDataObject_Check(value)) {
+ int res = PyObject_IsInstance(value, stgdict->proto);
+ if (res == -1)
+ return -1;
+ if (!res) {
+ PyErr_Format(PyExc_TypeError,
+ "expected %s instead of %s",
+ ((PyTypeObject *)(stgdict->proto))->tp_name,
+ Py_TYPE(value)->tp_name);
+ return -1;
+ }
}

dst = (CDataObject *)value;

--
Repository URL: http://hg.python.org/cpython


python-checkins at python

Mar 28, 2011, 3:24 PM

Post #12 of 192 (616 views)
Permalink
cpython (merge 3.2 -> default): merge 3.2 [In reply to]

http://hg.python.org/cpython/rev/00217100b9e7
changeset: 69030:00217100b9e7
parent: 69026:30a026a25167
parent: 69029:2a9ba6efbc56
user: Benjamin Peterson <benjamin [at] python>
date: Mon Mar 28 17:26:04 2011 -0500
summary:
merge 3.2

files:
Modules/getbuildinfo.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)


diff --git a/Modules/getbuildinfo.c b/Modules/getbuildinfo.c
--- a/Modules/getbuildinfo.c
+++ b/Modules/getbuildinfo.c
@@ -34,9 +34,9 @@
const char *
Py_GetBuildInfo(void)
{
- static char buildinfo[.50 + sizeof HGVERSION +
- ((sizeof HGTAG > sizeof HGBRANCH) ?
- sizeof HGTAG : sizeof HGBRANCH)];
+ static char buildinfo[.50 + sizeof(HGVERSION) +
+ ((sizeof(HGTAG) > sizeof(HGBRANCH)) ?
+ sizeof(HGTAG) : sizeof(HGBRANCH))];
const char *revision = _Py_hgversion();
const char *sep = *revision ? ":" : "";
const char *hgid = _Py_hgidentifier();

--
Repository URL: http://hg.python.org/cpython


python-checkins at python

Mar 28, 2011, 3:41 PM

Post #13 of 192 (614 views)
Permalink
cpython (merge 3.2 -> default): merge 3.2 [In reply to]

http://hg.python.org/cpython/rev/6a1ebd530b9e
changeset: 69033:6a1ebd530b9e
parent: 69030:00217100b9e7
parent: 69031:57e99f5f5e8f
user: Benjamin Peterson <benjamin [at] python>
date: Mon Mar 28 17:42:35 2011 -0500
summary:
merge 3.2

files:
Lib/inspect.py | 10 ++++++-
Lib/test/test_inspect.py | 33 ++++++++++++++++++++++++++++
Misc/NEWS | 3 ++
3 files changed, 44 insertions(+), 2 deletions(-)


diff --git a/Lib/inspect.py b/Lib/inspect.py
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -944,8 +944,14 @@
f_name, 'at most' if defaults else 'exactly', num_args,
'arguments' if num_args > 1 else 'argument', num_total))
elif num_args == 0 and num_total:
- raise TypeError('%s() takes no arguments (%d given)' %
- (f_name, num_total))
+ if varkw or kwonlyargs:
+ if num_pos:
+ # XXX: We should use num_pos, but Python also uses num_total:
+ raise TypeError('%s() takes exactly 0 positional arguments '
+ '(%d given)' % (f_name, num_total))
+ else:
+ raise TypeError('%s() takes no arguments (%d given)' %
+ (f_name, num_total))

for arg in itertools.chain(args, kwonlyargs):
if arg in named:
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -632,6 +632,16 @@
self.assertEqualCallArgs(f, '2, c=4, **collections.UserDict(b=3)')
self.assertEqualCallArgs(f, 'b=2, **collections.UserDict(a=3, c=4)')

+ def test_varkw_only(self):
+ # issue11256:
+ f = self.makeCallable('**c')
+ self.assertEqualCallArgs(f, '')
+ self.assertEqualCallArgs(f, 'a=1')
+ self.assertEqualCallArgs(f, 'a=1, b=2')
+ self.assertEqualCallArgs(f, 'c=3, **{"a": 1, "b": 2}')
+ self.assertEqualCallArgs(f, '**collections.UserDict(a=1, b=2)')
+ self.assertEqualCallArgs(f, 'c=3, **collections.UserDict(a=1, b=2)')
+
def test_keyword_only(self):
f = self.makeCallable('a=3, *, c, d=2')
self.assertEqualCallArgs(f, 'c=3')
@@ -643,6 +653,11 @@
self.assertEqualException(f, 'a=3')
self.assertEqualException(f, 'd=4')

+ f = self.makeCallable('*, c, d=2')
+ self.assertEqualCallArgs(f, 'c=3')
+ self.assertEqualCallArgs(f, 'c=3, d=4')
+ self.assertEqualCallArgs(f, 'd=4, c=3')
+
def test_multiple_features(self):
f = self.makeCallable('a, b=2, *f, **g')
self.assertEqualCallArgs(f, '2, 3, 7')
@@ -656,6 +671,17 @@
'(4,[5,6])]), **collections.UserDict('
'y=9, z=10)')

+ f = self.makeCallable('a, b=2, *f, x, y=99, **g')
+ self.assertEqualCallArgs(f, '2, 3, x=8')
+ self.assertEqualCallArgs(f, '2, 3, x=8, *[(4,[5,6]), 7]')
+ self.assertEqualCallArgs(f, '2, x=8, *[3, (4,[5,6]), 7], y=9, z=10')
+ self.assertEqualCallArgs(f, 'x=8, *[2, 3, (4,[5,6])], y=9, z=10')
+ self.assertEqualCallArgs(f, 'x=8, *collections.UserList('
+ '[2, 3, (4,[5,6])]), q=0, **{"y":9, "z":10}')
+ self.assertEqualCallArgs(f, '2, x=8, *collections.UserList([3, '
+ '(4,[5,6])]), q=0, **collections.UserDict('
+ 'y=9, z=10)')
+
def test_errors(self):
f0 = self.makeCallable('')
f1 = self.makeCallable('a, b')
@@ -692,6 +718,13 @@
# - for functions and bound methods: unexpected keyword 'c'
# - for unbound methods: multiple values for keyword 'a'
#self.assertEqualException(f, '1, c=3, a=2')
+ # issue11256:
+ f3 = self.makeCallable('**c')
+ self.assertEqualException(f3, '1, 2')
+ self.assertEqualException(f3, '1, 2, a=1, b=2')
+ f4 = self.makeCallable('*, a, b=0')
+ self.assertEqualException(f3, '1, 2')
+ self.assertEqualException(f3, '1, 2, a=1, b=2')

class TestGetcallargsMethods(TestGetcallargsFunctions):

diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -87,6 +87,9 @@
Library
-------

+- Issue #11256: Fix inspect.getcallargs on functions that take only keyword
+ arguments.
+
- Issue #11696: Fix ID generation in msilib.

- itertools.accumulate now supports an optional *func* argument for

--
Repository URL: http://hg.python.org/cpython


python-checkins at python

Mar 30, 2011, 4:56 AM

Post #14 of 192 (615 views)
Permalink
cpython (merge 3.2 -> default): Merge 3.2 [In reply to]

http://hg.python.org/cpython/rev/b63eeb5a5c07
changeset: 69064:b63eeb5a5c07
parent: 69037:7a8ada66c07d
parent: 69063:50e9d4515ea2
user: Kristjan Valur Jonsson <sweskman [at] gmail>
date: Wed Mar 30 11:32:06 2011 +0000
summary:
Merge 3.2

files:
Lib/test/test_itertools.py | 5 +++++
Modules/itertoolsmodule.c | 9 ++++++---
2 files changed, 11 insertions(+), 3 deletions(-)


diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py
--- a/Lib/test/test_itertools.py
+++ b/Lib/test/test_itertools.py
@@ -367,6 +367,8 @@
list(range(maxsize-5, maxsize+5)))
self.assertEqual(list(islice(count(-maxsize-5), 10)),
list(range(-maxsize-5, -maxsize+5)))
+ self.assertEqual(list(islice(count(10, maxsize+5), 3)),
+ list(range(10, 10+3*(maxsize+5), maxsize+5)))
c = count(3)
self.assertEqual(repr(c), 'count(3)')
next(c)
@@ -389,6 +391,9 @@
self.assertEqual(next(copy.deepcopy(c)), value)
self.assertEqual(next(pickle.loads(pickle.dumps(c))), value)

+ #check proper internal error handling for large "step' sizes
+ count(1, maxsize+5); sys.exc_info()
+
def test_count_with_stride(self):
self.assertEqual(lzip('abc',count(2,3)), [('a', 2), ('b', 5), ('c', 8)])
self.assertEqual(lzip('abc',count(start=2,step=3)),
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -3060,6 +3060,7 @@
Py_ssize_t cnt = 0;
PyObject *long_cnt = NULL;
PyObject *long_step = NULL;
+ long step;
static char *kwlist[] = {"start", "step", 0};

if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO:count",
@@ -3097,9 +3098,11 @@
assert(long_cnt != NULL && long_step != NULL);

/* Fast mode only works when the step is 1 */
- if (!PyLong_Check(long_step) ||
- PyLong_AS_LONG(long_step) != 1) {
- slow_mode = 1;
+ step = PyLong_AsLong(long_step);
+ if (step != 1) {
+ slow_mode = 1;
+ if (step == -1 && PyErr_Occurred())
+ PyErr_Clear();
}

if (slow_mode)

--
Repository URL: http://hg.python.org/cpython


python-checkins at python

Apr 12, 2011, 4:34 PM

Post #15 of 192 (606 views)
Permalink
cpython (merge 3.2 -> default): merge 3.2 [In reply to]

http://hg.python.org/cpython/rev/0e6359968b80
changeset: 69291:0e6359968b80
parent: 69287:bdca6780be95
parent: 69290:d25c2812b0d8
user: Benjamin Peterson <benjamin [at] python>
date: Tue Apr 12 18:35:21 2011 -0500
summary:
merge 3.2

files:
Lib/test/test_syntax.py | 4 ++++
Misc/NEWS | 3 +++
Python/ast.c | 1 +
3 files changed, 8 insertions(+), 0 deletions(-)


diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -67,6 +67,10 @@
Traceback (most recent call last):
SyntaxError: can't assign to literal

+>>> b"" = 1
+Traceback (most recent call last):
+SyntaxError: can't assign to literal
+
>>> `1` = 1
Traceback (most recent call last):
SyntaxError: invalid syntax
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -716,6 +716,9 @@

- Add sys.flags attribute for the new -q command-line option.

+- Issue #11506: Trying to assign to a bytes literal should result in a
+ SyntaxError.
+
Library
-------

diff --git a/Python/ast.c b/Python/ast.c
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -483,6 +483,7 @@
case Set_kind:
case Num_kind:
case Str_kind:
+ case Bytes_kind:
expr_name = "literal";
break;
case Ellipsis_kind:

--
Repository URL: http://hg.python.org/cpython


python-checkins at python

Apr 13, 2011, 2:13 PM

Post #16 of 192 (608 views)
Permalink
cpython (merge 3.2 -> default): Merge 3.2 [In reply to]

http://hg.python.org/cpython/rev/602d317d2257
changeset: 69337:602d317d2257
parent: 69334:a95d936ce8eb
parent: 69336:eecde4602c5c
user: Brian Curtin <brian [at] python>
date: Wed Apr 13 16:12:46 2011 -0500
summary:
Merge 3.2

files:
Tools/README | 5 -----
1 files changed, 0 insertions(+), 5 deletions(-)


diff --git a/Tools/README b/Tools/README
--- a/Tools/README
+++ b/Tools/README
@@ -40,8 +40,3 @@

unittestgui A Tkinter based GUI test runner for unittest, with test
discovery.
-
-world Script to take a list of Internet addresses and print
- out where in the world those addresses originate from,
- based on the top-level domain country code found in
- the address.

--
Repository URL: http://hg.python.org/cpython


python-checkins at python

Apr 27, 2011, 7:38 AM

Post #17 of 192 (598 views)
Permalink
cpython (merge 3.2 -> default): Merge 3.2 [In reply to]

http://hg.python.org/cpython/rev/933494a3b705
changeset: 69609:933494a3b705
parent: 69440:253f8623ea0b
parent: 69608:26c22aaf43a4
user: Éric Araujo <merwok [at] netwok>
date: Wed Apr 20 20:22:57 2011 +0200
summary:
Merge 3.2

files:
Doc/c-api/intro.rst | 3 +-
Doc/documenting/markup.rst | 25 +++++++++++++--
Doc/library/dbm.rst | 4 +-
Lib/ast.py | 4 +-
Lib/dbm/__init__.py | 22 +++++++------
Lib/distutils/command/sdist.py | 23 ++++++++------
Lib/distutils/tests/test_register.py | 6 +-
Lib/heapq.py | 6 +-
Lib/sysconfig.py | 1 -
Lib/trace.py | 2 +-
10 files changed, 58 insertions(+), 38 deletions(-)


diff --git a/Doc/c-api/intro.rst b/Doc/c-api/intro.rst
--- a/Doc/c-api/intro.rst
+++ b/Doc/c-api/intro.rst
@@ -511,13 +511,12 @@
module: builtins
module: __main__
module: sys
- module: exceptions
triple: module; search; path
single: path (in module sys)

The basic initialization function is :c:func:`Py_Initialize`. This initializes
the table of loaded modules, and creates the fundamental modules
-:mod:`builtins`, :mod:`__main__`, :mod:`sys`, and :mod:`exceptions`. It also
+:mod:`builtins`, :mod:`__main__`, and :mod:`sys`. It also
initializes the module search path (``sys.path``).

.. index:: single: PySys_SetArgvEx()
diff --git a/Doc/documenting/markup.rst b/Doc/documenting/markup.rst
--- a/Doc/documenting/markup.rst
+++ b/Doc/documenting/markup.rst
@@ -152,7 +152,7 @@

Describes global data in a module, including both variables and values used
as "defined constants." Class and object attributes are not documented
- using this environment.
+ using this directive.

.. describe:: exception

@@ -165,7 +165,7 @@
parameters, enclosing optional parameters in brackets. Default values can be
given if it enhances clarity. For example::

- .. function:: Timer.repeat([repeat=3[, number=1000000]])
+ .. function:: repeat([repeat=3[, number=1000000]])

Object methods are not documented using this directive. Bound object methods
placed in the module namespace as part of the public interface of the module
@@ -217,13 +217,30 @@

Describes an object data attribute. The description should include
information about the type of the data to be expected and whether it may be
- changed directly.
+ changed directly. This directive should be nested in a class directive,
+ like in this example::
+
+ .. class:: Spam
+
+ Description of the class.
+
+ .. data:: ham
+
+ Description of the attribute.
+
+ If is also possible to document an attribute outside of a class directive,
+ for example if the documentation for different attributes and methods is
+ split in multiple sections. The class name should then be included
+ explicitly::
+
+ .. data:: Spam.eggs

.. describe:: method

Describes an object method. The parameters should not include the ``self``
parameter. The description should include similar information to that
- described for ``function``.
+ described for ``function``. This method should be nested in a class
+ method, like in the example above.

.. describe:: decoratormethod

diff --git a/Doc/library/dbm.rst b/Doc/library/dbm.rst
--- a/Doc/library/dbm.rst
+++ b/Doc/library/dbm.rst
@@ -30,9 +30,9 @@
name, such as ``'dbm.ndbm'`` or ``'dbm.gnu'``.


-.. function:: open(filename, flag='r', mode=0o666)
+.. function:: open(file, flag='r', mode=0o666)

- Open the database file *filename* and return a corresponding object.
+ Open the database file *file* and return a corresponding object.

If the database file already exists, the :func:`whichdb` function is used to
determine its type and the appropriate module is used; if it does not exist,
diff --git a/Lib/ast.py b/Lib/ast.py
--- a/Lib/ast.py
+++ b/Lib/ast.py
@@ -40,8 +40,8 @@
"""
Safely evaluate an expression node or a string containing a Python
expression. The string or node provided may only consist of the following
- Python literal structures: strings, numbers, tuples, lists, dicts, booleans,
- and None.
+ Python literal structures: strings, bytes, numbers, tuples, lists, dicts,
+ sets, booleans, and None.
"""
_safe_names = {'None': None, 'True': True, 'False': False}
if isinstance(node_or_string, str):
diff --git a/Lib/dbm/__init__.py b/Lib/dbm/__init__.py
--- a/Lib/dbm/__init__.py
+++ b/Lib/dbm/__init__.py
@@ -23,16 +23,8 @@
list = d.keys() # return a list of all existing keys (slow!)

Future versions may change the order in which implementations are
-tested for existence, add interfaces to other dbm-like
+tested for existence, and add interfaces to other dbm-like
implementations.
-
-The open function has an optional second argument. This can be 'r',
-for read-only access, 'w', for read-write access of an existing
-database, 'c' for read-write access to a new or existing database, and
-'n' for read-write access to a new database. The default is 'r'.
-
-Note: 'r' and 'w' fail if the database doesn't exist; 'c' creates it
-only if it doesn't exist; and 'n' always creates a new database.
"""

__all__ = ['open', 'whichdb', 'error']
@@ -53,7 +45,17 @@
error = (error, IOError)


-def open(file, flag = 'r', mode = 0o666):
+def open(file, flag='r', mode=0o666):
+ """Open or create database at path given by *file*.
+
+ Optional argument *flag* can be 'r' (default) for read-only access, 'w'
+ for read-write access of an existing database, 'c' for read-write access
+ to a new or existing database, and 'n' for read-write access to a new
+ database.
+
+ Note: 'r' and 'w' fail if the database doesn't exist; 'c' creates it
+ only if it doesn't exist; and 'n' always creates a new database.
+ """
global _defaultmod
if _defaultmod is None:
for name in _names:
diff --git a/Lib/distutils/command/sdist.py b/Lib/distutils/command/sdist.py
--- a/Lib/distutils/command/sdist.py
+++ b/Lib/distutils/command/sdist.py
@@ -294,17 +294,20 @@
join_lines=1, lstrip_ws=1, rstrip_ws=1,
collapse_join=1)

- while True:
- line = template.readline()
- if line is None: # end of file
- break
+ try:
+ while True:
+ line = template.readline()
+ if line is None: # end of file
+ break

- try:
- self.filelist.process_template_line(line)
- except DistutilsTemplateError as msg:
- self.warn("%s, line %d: %s" % (template.filename,
- template.current_line,
- msg))
+ try:
+ self.filelist.process_template_line(line)
+ except DistutilsTemplateError as msg:
+ self.warn("%s, line %d: %s" % (template.filename,
+ template.current_line,
+ msg))
+ finally:
+ template.close()

def prune_file_list(self):
"""Prune off branches that might slip into the file list as created
diff --git a/Lib/distutils/tests/test_register.py b/Lib/distutils/tests/test_register.py
--- a/Lib/distutils/tests/test_register.py
+++ b/Lib/distutils/tests/test_register.py
@@ -137,7 +137,7 @@

# let's see what the server received : we should
# have 2 similar requests
- self.assertTrue(self.conn.reqs, 2)
+ self.assertEqual(len(self.conn.reqs), 2)
req1 = dict(self.conn.reqs[0].headers)
req2 = dict(self.conn.reqs[1].headers)

@@ -169,7 +169,7 @@
del register_module.input

# we should have send a request
- self.assertTrue(self.conn.reqs, 1)
+ self.assertEqual(len(self.conn.reqs), 1)
req = self.conn.reqs[0]
headers = dict(req.headers)
self.assertEqual(headers['Content-length'], '608')
@@ -187,7 +187,7 @@
del register_module.input

# we should have send a request
- self.assertTrue(self.conn.reqs, 1)
+ self.assertEqual(len(self.conn.reqs), 1)
req = self.conn.reqs[0]
headers = dict(req.headers)
self.assertEqual(headers['Content-length'], '290')
diff --git a/Lib/heapq.py b/Lib/heapq.py
--- a/Lib/heapq.py
+++ b/Lib/heapq.py
@@ -170,7 +170,7 @@
return item

def heapify(x):
- """Transform list into a heap, in-place, in O(len(heap)) time."""
+ """Transform list into a heap, in-place, in O(len(x)) time."""
n = len(x)
# Transform bottom-up. The largest index there's any point to looking at
# is the largest with a child index in-range, so must have 2*i + 1 < n,
@@ -360,7 +360,7 @@
return [min(chain(head, it))]
return [min(chain(head, it), key=key)]

- # When n>=size, it's faster to use sort()
+ # When n>=size, it's faster to use sorted()
try:
size = len(iterable)
except (TypeError, AttributeError):
@@ -398,7 +398,7 @@
return [max(chain(head, it))]
return [max(chain(head, it), key=key)]

- # When n>=size, it's faster to use sort()
+ # When n>=size, it's faster to use sorted()
try:
size = len(iterable)
except (TypeError, AttributeError):
diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
--- a/Lib/sysconfig.py
+++ b/Lib/sysconfig.py
@@ -694,7 +694,6 @@
m = re.search(
r'<key>ProductUserVisibleVersion</key>\s*' +
r'<string>(.*?)</string>', f.read())
- f.close()
if m is not None:
macrelease = '.'.join(m.group(1).split('.')[:2])
# else: fall back to the default behaviour
diff --git a/Lib/trace.py b/Lib/trace.py
--- a/Lib/trace.py
+++ b/Lib/trace.py
@@ -688,7 +688,7 @@

for opt, val in opts:
if opt == "--help":
- usage(sys.stdout)
+ _usage(sys.stdout)
sys.exit(0)

if opt == "--version":

--
Repository URL: http://hg.python.org/cpython


python-checkins at python

Apr 27, 2011, 7:38 AM

Post #18 of 192 (600 views)
Permalink
cpython (merge 3.2 -> default): Merge 3.2 [In reply to]

http://hg.python.org/cpython/rev/73ac0477288e
changeset: 69617:73ac0477288e
parent: 69616:52d0aeb96864
parent: 69615:8d4f27590a3e
user: Éric Araujo <merwok [at] netwok>
date: Sun Apr 24 02:49:10 2011 +0200
summary:
Merge 3.2

files:
Doc/distutils/examples.rst | 2 +-
Doc/library/json.rst | 2 +-
Doc/library/runpy.rst | 2 +-
Lib/json/__init__.py | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)


diff --git a/Doc/distutils/examples.rst b/Doc/distutils/examples.rst
--- a/Doc/distutils/examples.rst
+++ b/Doc/distutils/examples.rst
@@ -279,7 +279,7 @@
Where the long description is broken, ``check`` will be able to detect it
by using the :mod:`docutils` parser::

- $ pythontrunk setup.py check --restructuredtext
+ $ python setup.py check --restructuredtext
running check
warning: check: Title underline too short. (line 2)
warning: check: Could not finish the parsing.
diff --git a/Doc/library/json.rst b/Doc/library/json.rst
--- a/Doc/library/json.rst
+++ b/Doc/library/json.rst
@@ -34,7 +34,7 @@
Compact encoding::

>>> import json
- >>> json.dumps([1,2,3,{'4': 5, '6': 7}], separators=(',',':'))
+ >>> json.dumps([1,2,3,{'4': 5, '6': 7}], separators=(',', ':'))
'[1,2,3,{"4":5,"6":7}]'

Pretty printing::
diff --git a/Doc/library/runpy.rst b/Doc/library/runpy.rst
--- a/Doc/library/runpy.rst
+++ b/Doc/library/runpy.rst
@@ -49,7 +49,7 @@
loader does not make filename information available, this variable is set
to :const:`None`.

- ``__cached__`` will be set to ``None``.
+ ``__cached__`` will be set to ``None``.

``__loader__`` is set to the :pep:`302` module loader used to retrieve the
code for the module (This loader may be a wrapper around the standard
diff --git a/Lib/json/__init__.py b/Lib/json/__init__.py
--- a/Lib/json/__init__.py
+++ b/Lib/json/__init__.py
@@ -31,7 +31,7 @@
Compact encoding::

>>> import json
- >>> json.dumps([1,2,3,{'4': 5, '6': 7}], separators=(',',':'))
+ >>> json.dumps([1,2,3,{'4': 5, '6': 7}], separators=(',', ':'))
'[1,2,3,{"4":5,"6":7}]'

Pretty printing::

--
Repository URL: http://hg.python.org/cpython


python-checkins at python

Apr 27, 2011, 7:39 AM

Post #19 of 192 (599 views)
Permalink
cpython (merge 3.2 -> default): Merge 3.2 [In reply to]

http://hg.python.org/cpython/rev/cd6dfe6dd3a3
changeset: 69630:cd6dfe6dd3a3
parent: 69623:95f9c2d6a1e7
parent: 69629:0ff8f6105827
user: Éric Araujo <merwok [at] netwok>
date: Wed Apr 27 16:32:36 2011 +0200
summary:
Merge 3.2

files:
Doc/c-api/object.rst | 1 -
Doc/library/__future__.rst | 2 +-
Doc/library/sys.rst | 4 ++--
Doc/library/wsgiref.rst | 2 +-
Lib/test/tracedmodules/__init__.py | 5 -----
5 files changed, 4 insertions(+), 10 deletions(-)


diff --git a/Doc/c-api/object.rst b/Doc/c-api/object.rst
--- a/Doc/c-api/object.rst
+++ b/Doc/c-api/object.rst
@@ -258,7 +258,6 @@
This is the equivalent of the Python expression ``hash(o)``.

.. versionchanged:: 3.2
-
The return type is now Py_hash_t. This is a signed integer the same size
as Py_ssize_t.

diff --git a/Doc/library/__future__.rst b/Doc/library/__future__.rst
--- a/Doc/library/__future__.rst
+++ b/Doc/library/__future__.rst
@@ -29,7 +29,7 @@


where, normally, *OptionalRelease* is less than *MandatoryRelease*, and both are
-5-tuples of the same form as ``sys.version_info``::
+5-tuples of the same form as :data:`sys.version_info`::

(PY_MAJOR_VERSION, # the 2 in 2.1.0a3; an int
PY_MINOR_VERSION, # the 1; an int
diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst
--- a/Doc/library/sys.rst
+++ b/Doc/library/sys.rst
@@ -540,8 +540,8 @@

This is called ``hexversion`` since it only really looks meaningful when viewed
as the result of passing it to the built-in :func:`hex` function. The
- ``version_info`` value may be used for a more human-friendly encoding of the
- same information.
+ :term:`struct sequence` :data:`sys.version_info` may be used for a more
+ human-friendly encoding of the same information.

The ``hexversion`` is a 32-bit number with the following layout

diff --git a/Doc/library/wsgiref.rst b/Doc/library/wsgiref.rst
--- a/Doc/library/wsgiref.rst
+++ b/Doc/library/wsgiref.rst
@@ -690,7 +690,7 @@
.. attribute:: BaseHandler.wsgi_file_wrapper

A ``wsgi.file_wrapper`` factory, or ``None``. The default value of this
- attribute is the :class:`FileWrapper` class from :mod:`wsgiref.util`.
+ attribute is the :class:`wsgiref.util.FileWrapper` class.


.. method:: BaseHandler.sendfile()
diff --git a/Lib/test/tracedmodules/__init__.py b/Lib/test/tracedmodules/__init__.py
--- a/Lib/test/tracedmodules/__init__.py
+++ b/Lib/test/tracedmodules/__init__.py
@@ -2,8 +2,3 @@
that the exact location of functions in these modules is important, as trace.py
takes the real line numbers into account.
"""
-"""This directory contains modules that help testing the trace.py module. Note
-that the exact location of functions in these modules is important, as trace.py
-takes the real line numbers into account.
-
-"""

--
Repository URL: http://hg.python.org/cpython


python-checkins at python

Apr 30, 2011, 11:14 AM

Post #20 of 192 (583 views)
Permalink
cpython (merge 3.2 -> default): merge 3.2 [In reply to]

http://hg.python.org/cpython/rev/7247d9f2fce9
changeset: 69716:7247d9f2fce9
parent: 69712:fd45c2452be3
parent: 69714:6e9aedf6ef24
user: Benjamin Peterson <benjamin [at] python>
date: Sat Apr 30 13:16:14 2011 -0500
summary:
merge 3.2

files:
Doc/c-api/module.rst | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)


diff --git a/Doc/c-api/module.rst b/Doc/c-api/module.rst
--- a/Doc/c-api/module.rst
+++ b/Doc/c-api/module.rst
@@ -221,7 +221,7 @@
.. c:function:: int PyModule_AddIntMacro(PyObject *module, macro)

Add an int constant to *module*. The name and the value are taken from
- *macro*. For example ``PyModule_AddConstant(module, AF_INET)`` adds the int
+ *macro*. For example ``PyModule_AddIntMacro(module, AF_INET)`` adds the int
constant *AF_INET* with the value of *AF_INET* to *module*.
Return ``-1`` on error, ``0`` on success.


--
Repository URL: http://hg.python.org/cpython


python-checkins at python

May 1, 2011, 3:37 PM

Post #21 of 192 (580 views)
Permalink
cpython (merge 3.2 -> default): merge 3.2 [In reply to]

http://hg.python.org/cpython/rev/53a55599bc6b
changeset: 69752:53a55599bc6b
parent: 69747:ba8a8c47de7b
parent: 69751:e35e51d4e28c
user: Benjamin Peterson <benjamin [at] python>
date: Sun May 01 17:39:52 2011 -0500
summary:
merge 3.2

files:
Doc/library/stdtypes.rst | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)


diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -354,8 +354,8 @@
for a complete list of code points with the ``Nd`` property.


-All :class:`numbers.Real` types (:class:`int` and
-:class:`float`) also include the following operations:
+All :class:`numbers.Real` types (:class:`int` and :class:`float`) also include
+the following operations:

+--------------------+------------------------------------+--------+
| Operation | Result | Notes |
@@ -439,6 +439,9 @@
Additional Methods on Integer Types
-----------------------------------

+The int type implements the :class:`numbers.Integral` :term:`abstact base
+class`. In addition, it provides one more method
+
.. method:: int.bit_length()

Return the number of bits necessary to represent an integer in binary,
@@ -532,7 +535,8 @@
Additional Methods on Float
---------------------------

-The float type has some additional methods.
+The float type implements the :class:`numbers.Real` :term:`abstract base
+class`. float also has the following additional methods.

.. method:: float.as_integer_ratio()


--
Repository URL: http://hg.python.org/cpython


python-checkins at python

May 1, 2011, 6:22 PM

Post #22 of 192 (579 views)
Permalink
cpython (merge 3.2 -> default): merge 3.2 [In reply to]

http://hg.python.org/cpython/rev/513f6dfd3173
changeset: 69759:513f6dfd3173
parent: 69755:d578fdc9b157
parent: 69758:db31b4297ddc
user: Benjamin Peterson <benjamin [at] python>
date: Sun May 01 20:24:59 2011 -0500
summary:
merge 3.2

files:
Doc/library/stdtypes.rst | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)


diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -439,7 +439,7 @@
Additional Methods on Integer Types
-----------------------------------

-The int type implements the :class:`numbers.Integral` :term:`abstact base
+The int type implements the :class:`numbers.Integral` :term:`abstract base
class`. In addition, it provides one more method

.. method:: int.bit_length()

--
Repository URL: http://hg.python.org/cpython


python-checkins at python

May 2, 2011, 4:34 AM

Post #23 of 192 (577 views)
Permalink
cpython (merge 3.2 -> default): Merge 3.2 [In reply to]

http://hg.python.org/cpython/rev/92f563a14076
changeset: 69764:92f563a14076
parent: 69759:513f6dfd3173
parent: 69763:b1f28a2d6d33
user: Éric Araujo <merwok [at] netwok>
date: Mon May 02 13:33:14 2011 +0200
summary:
Merge 3.2

files:
Doc/documenting/markup.rst | 4 ++--
Doc/library/stdtypes.rst | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)


diff --git a/Doc/documenting/markup.rst b/Doc/documenting/markup.rst
--- a/Doc/documenting/markup.rst
+++ b/Doc/documenting/markup.rst
@@ -239,8 +239,8 @@

Describes an object method. The parameters should not include the ``self``
parameter. The description should include similar information to that
- described for ``function``. This method should be nested in a class
- method, like in the example above.
+ described for ``function``. This directive should be nested in a class
+ directive, like in the example above.

.. describe:: decoratormethod

diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -440,7 +440,7 @@
-----------------------------------

The int type implements the :class:`numbers.Integral` :term:`abstract base
-class`. In addition, it provides one more method
+class`. In addition, it provides one more method:

.. method:: int.bit_length()


--
Repository URL: http://hg.python.org/cpython


python-checkins at python

May 8, 2011, 1:33 PM

Post #24 of 192 (568 views)
Permalink
cpython (merge 3.2 -> default): merge 3.2 [In reply to]

http://hg.python.org/cpython/rev/b6a335b9e717
changeset: 69944:b6a335b9e717
parent: 69940:9af64d83c217
parent: 69943:ae6cd69ce9f8
user: Benjamin Peterson <benjamin [at] python>
date: Sun May 08 15:35:09 2011 -0500
summary:
merge 3.2

files:
Lib/test/support.py | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)


diff --git a/Lib/test/support.py b/Lib/test/support.py
--- a/Lib/test/support.py
+++ b/Lib/test/support.py
@@ -42,8 +42,9 @@
"BasicTestRunner", "run_unittest", "run_doctest", "threading_setup",
"threading_cleanup", "reap_children", "cpython_only", "check_impl_detail",
"get_attribute", "swap_item", "swap_attr", "requires_IEEE_754",
- "TestHandler", "Matcher", "can_symlink", "skip_unless_symlink"]
-
+ "TestHandler", "Matcher", "can_symlink", "skip_unless_symlink",
+ "import_fresh_module"
+ ]

class Error(Exception):
"""Base class for regression test exceptions."""

--
Repository URL: http://hg.python.org/cpython


python-checkins at python

May 20, 2011, 9:43 AM

Post #25 of 192 (548 views)
Permalink
cpython (merge 3.2 -> default): merge 3.2 [In reply to]

http://hg.python.org/cpython/rev/7c8e5ac27457
changeset: 70231:7c8e5ac27457
parent: 70226:cc60d0283fad
parent: 70230:a341694216fc
user: Benjamin Peterson <benjamin [at] python>
date: Fri May 20 11:42:47 2011 -0500
summary:
merge 3.2

files:
Doc/library/os.rst | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletions(-)


diff --git a/Doc/library/os.rst b/Doc/library/os.rst
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -1346,7 +1346,26 @@
Using :func:`access` to check if a user is authorized to e.g. open a file
before actually doing so using :func:`open` creates a security hole,
because the user might exploit the short time interval between checking
- and opening the file to manipulate it.
+ and opening the file to manipulate it. It's preferable to use :term:`EAFP`
+ techniques. For example::
+
+ if os.access("myfile", os.R_OK):
+ with open("myfile") as fp:
+ return fp.read()
+ return "some default data"
+
+ is better written as::
+
+ try:
+ fp = open("myfile")
+ except OSError as e:
+ if e.errno == errno.EACCESS:
+ return "some default data"
+ # Not a permission error.
+ raise
+ else:
+ with fp:
+ return fp.read()

.. note::


--
Repository URL: http://hg.python.org/cpython

First page Previous page 1 2 3 4 5 6 7 8 Next page Last page  View All Python checkins RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.