Kaydet (Commit) 5e55b3e2 authored tarafından Benjamin Peterson's avatar Benjamin Peterson

Merged revisions…

Merged revisions 77484,77487,77561,77570,77593,77603,77608,77667,77702-77703,77739,77858,77887,77889 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r77484 | skip.montanaro | 2010-01-13 19:12:34 -0600 (Wed, 13 Jan 2010) | 4 lines

  Update PyEval_EvalFrame to PyEval_EvalFrameEx.  This looks to have been done
  partially before.  Also add a comment describing how this might have to work
  with different versions of the interpreter.
........
  r77487 | ezio.melotti | 2010-01-14 05:34:10 -0600 (Thu, 14 Jan 2010) | 1 line

  Fixed typo
........
  r77561 | georg.brandl | 2010-01-17 02:42:30 -0600 (Sun, 17 Jan 2010) | 1 line

  #7699: improve datetime docs: straightforward linking to strftime/strptime section, mark classmethods as such.
........
  r77570 | georg.brandl | 2010-01-17 06:14:42 -0600 (Sun, 17 Jan 2010) | 1 line

  Add note about usage of STRINGLIB_EMPTY.
........
  r77593 | georg.brandl | 2010-01-17 17:33:53 -0600 (Sun, 17 Jan 2010) | 1 line

  Fix internal reference.
........
  r77603 | benjamin.peterson | 2010-01-18 17:07:56 -0600 (Mon, 18 Jan 2010) | 8 lines

  data descriptors do not override the class dictionary if __get__ is not defined

  Adjust documentation and add a test to verify this behavior.

  See http://mail.python.org/pipermail/python-dev/2010-January/095637.html for
  discussion.
........
  r77608 | gregory.p.smith | 2010-01-19 02:19:03 -0600 (Tue, 19 Jan 2010) | 6 lines

  Do not compile stubs for the sha2 series hashes in the openssl hashlib
  module when the openssl version is too old to support them.  That
  leads both compiled code bloat and to unittests attempting to test
  implementations that don't exist for comparison purposes on such
  platforms.
........
  r77667 | mark.dickinson | 2010-01-21 12:32:27 -0600 (Thu, 21 Jan 2010) | 1 line

  Add two more test_strtod test values.
........
  r77702 | georg.brandl | 2010-01-23 02:43:31 -0600 (Sat, 23 Jan 2010) | 1 line

  #7762: fix refcount annotation of PyUnicode_Tailmatch().
........
  r77703 | georg.brandl | 2010-01-23 02:47:54 -0600 (Sat, 23 Jan 2010) | 1 line

  #7725: fix referencing issue.
........
  r77739 | benjamin.peterson | 2010-01-24 21:52:52 -0600 (Sun, 24 Jan 2010) | 1 line

  mention from_float() in error message
........
  r77858 | georg.brandl | 2010-01-30 11:57:48 -0600 (Sat, 30 Jan 2010) | 1 line

  #7802: fix invalid example (heh).
........
  r77887 | georg.brandl | 2010-01-31 12:51:49 -0600 (Sun, 31 Jan 2010) | 5 lines

  Fix-up ftplib documentation:
  move exception descriptions to toplevel, not inside a class
  remove attribution in "versionadded"
  spell and grammar check docstring of FTP_TLS
........
  r77889 | michael.foord | 2010-01-31 13:59:26 -0600 (Sun, 31 Jan 2010) | 1 line

  Minor modification to unittest documentation.
........
üst 895aa5e0
......@@ -1637,7 +1637,7 @@ PyUnicode_Join:PyObject*::+1:
PyUnicode_Join:PyObject*:separator:0:
PyUnicode_Join:PyObject*:seq:0:
PyUnicode_Tailmatch:PyObject*::+1:
PyUnicode_Tailmatch:int:::
PyUnicode_Tailmatch:PyObject*:str:0:
PyUnicode_Tailmatch:PyObject*:substr:0:
PyUnicode_Tailmatch:int:start::
......
......@@ -285,8 +285,11 @@ by using the `docutils` parser::
warning: check: Title underline too short. (line 2)
warning: check: Could not finish the parsing.
.. _reading-metadata:
Reading the metadata
=====================
====================
The :func:`distutils.core.setup` function provides a command-line interface
that allows you to query the metadata fields of a project through the
......
This diff is collapsed.
......@@ -33,8 +33,8 @@ Here's a sample session using the :mod:`ftplib` module::
'226 Transfer complete.'
>>> ftp.quit()
The module defines the following items:
The module defines the following items:
.. class:: FTP(host='', user='', passwd='', acct=''[, timeout])
......@@ -51,21 +51,20 @@ The module defines the following items:
A :class:`FTP` subclass which adds TLS support to FTP as described in
:rfc:`4217`.
Connect as usual to port 21 implicitly securing the FTP control connection
before authenticating. Securing the data connection requires user to
explicitly ask for it by calling :exc:`prot_p()` method.
*keyfile* and *certfile* are optional - they can contain a PEM formatted
private key and certificate chain file for the SSL connection.
.. versionadded:: 3.2 Contributed by Giampaolo Rodola'
before authenticating. Securing the data connection requires the user to
explicitly ask for it by calling the :meth:`prot_p` method.
*keyfile* and *certfile* are optional -- they can contain a PEM formatted
private key and certificate chain file name for the SSL connection.
.. versionadded:: 3.2
Here's a sample session using :class:`FTP_TLS` class:
Here's a sample session using the :class:`FTP_TLS` class:
>>> from ftplib import FTP_TLS
>>> ftps = FTP_TLS('ftp.python.org')
>>> ftps.login() # login anonimously previously securing control channel
>>> ftps.prot_p() # switch to secure data connection
>>> ftps.retrlines('LIST') # list directory content securely
>>> ftps.login() # login anonymously before securing control channel
>>> ftps.prot_p() # switch to secure data connection
>>> ftps.retrlines('LIST') # list directory content securely
total 9
drwxr-xr-x 8 root wheel 1024 Jan 3 1994 .
drwxr-xr-x 8 root wheel 1024 Jan 3 1994 ..
......@@ -81,16 +80,6 @@ The module defines the following items:
>>>
.. attribute:: all_errors
The set of all exceptions (as a tuple) that methods of :class:`FTP`
instances may raise as a result of problems with the FTP connection (as
opposed to programming errors made by the caller). This set includes the
four exceptions listed below as well as :exc:`socket.error` and
:exc:`IOError`.
.. exception:: error_reply
Exception raised when an unexpected reply is received from the server.
......@@ -98,19 +87,24 @@ The module defines the following items:
.. exception:: error_temp
Exception raised when an error code in the range 400--499 is received.
Exception raised when an unexpected reply is received from the server.
.. exception:: error_perm
Exception raised when an error code in the range 500--599 is received.
.. exception:: error_proto
Exception raised when a reply is received from the server that does not begin
with a digit in the range 1--5.
Exception raised when a reply is received from the server that does not
begin with a digit in the range 1--5.
.. data:: all_errors
The set of all exceptions (as a tuple) that methods of :class:`FTP`
instances may raise as a result of problems with the FTP connection (as
opposed to programming errors made by the caller). This set includes the
four exceptions listed below as well as :exc:`socket.error` and
:exc:`IOError`.
.. seealso::
......
......@@ -107,7 +107,7 @@ script. For example::
cProfile.py [-o output_file] [-s sort_order]
:option:`-s` only applies to standard output (:option:`-o` is not supplied).
``-s`` only applies to standard output (``-o`` is not supplied).
Look in the :class:`Stats` documentation for valid sort values.
When you wish to review the profile, you should use the methods in the
......
......@@ -803,9 +803,9 @@ Test cases
.. method:: assertSameElements(expected, actual, msg=None)
Test that sequence *expected* contains the same elements as *actual*.
When they don't an error message listing the differences between the
sequences will be generated.
Test that sequence *expected* contains the same elements as *actual*,
regardless of their order. When they don't, an error message listing
the differences between the sequences will be generated.
If specified *msg* will be used as the error message on failure.
......
......@@ -383,8 +383,8 @@ by providing an invalid URI::
import xmlrpc.client
# create a ServerProxy with an invalid URI
proxy = xmlrpc.client.ServerProxy("http://invalidaddress/")
# create a ServerProxy with an URI that doesn't respond to XMLRPC requests
proxy = xmlrpc.client.ServerProxy("http://google.com/")
try:
proxy.some_method()
......
......@@ -1413,11 +1413,17 @@ Super Binding
``A.__dict__['m'].__get__(obj, A)``.
For instance bindings, the precedence of descriptor invocation depends on the
which descriptor methods are defined. Normally, data descriptors define both
:meth:`__get__` and :meth:`__set__`, while non-data descriptors have just the
:meth:`__get__` method. Data descriptors always override a redefinition in an
which descriptor methods are defined. A descriptor can define any combination
of :meth:`__get__`, :meth:`__set__` and :meth:`__delete__`. If it does not
define :meth:`__get__`, then accessing the attribute will return the descriptor
object itself unless there is a value in the object's instance dictionary. If
the descriptor defines :meth:`__set__` and/or :meth:`__delete__`, it is a data
descriptor; if it defines neither, it is a non-data descriptor. Normally, data
descriptors define both :meth:`__get__` and :meth:`__set__`, while non-data
descriptors have just the :meth:`__get__` method. Data descriptors with
:meth:`__set__` and :meth:`__get__` defined always override a redefinition in an
instance dictionary. In contrast, non-data descriptors can be overridden by
instances. [#]_
instances.
Python methods (including :func:`staticmethod` and :func:`classmethod`) are
implemented as non-data descriptors. Accordingly, instances can redefine and
......@@ -2006,13 +2012,6 @@ object itself in order to be consistently invoked by the interpreter).
controlled conditions. It generally isn't a good idea though, since it can
lead to some very strange behaviour if it is handled incorrectly.
.. [#] A descriptor can define any combination of :meth:`__get__`,
:meth:`__set__` and :meth:`__delete__`. If it does not define :meth:`__get__`,
then accessing the attribute even on an instance will return the descriptor
object itself. If the descriptor defines :meth:`__set__` and/or
:meth:`__delete__`, it is a data descriptor; if it defines neither, it is a
non-data descriptor.
.. [#] For operands of the same type, it is assumed that if the non-reflected method
(such as :meth:`__add__`) fails the operation is not supported, which is why the
reflected method is not called.
......@@ -612,8 +612,8 @@ changes, or look through the Subversion logs for all the details.
The :class:`distutils.dist.DistributionMetadata` class'
:meth:`read_pkg_file` method will read the contents of a package's
:file:`PKG-INFO` metadata file. For an example of its use,
XXX link to file:///MacDev/svn.python.org/python-trunk/Doc/build/html/distutils/examples.html#reading-the-metadata
:file:`PKG-INFO` metadata file. For an example of its use, see
:ref:`reading-metadata`.
(Contributed by Tarek Ziade; :issue:`7457`.)
:file:`setup.py` files will now accept a :option:`--no-user-cfg` switch
......
......@@ -648,8 +648,8 @@ class Decimal(object):
return self
if isinstance(value, float):
raise TypeError("Cannot convert float to Decimal. " +
"First convert the float to a string")
raise TypeError("Cannot convert float in Decimal constructor. "
"Use from_float class method.")
raise TypeError("Cannot convert %r to Decimal" % value)
......
......@@ -4147,6 +4147,26 @@ order (MRO) for bases """
c[1:2] = 3
self.assertEqual(c.value, 3)
def test_set_and_no_get(self):
# See
# http://mail.python.org/pipermail/python-dev/2010-January/095637.html
class Descr(object):
def __init__(self, name):
self.name = name
def __set__(self, obj, value):
obj.__dict__[self.name] = value
descr = Descr("a")
class X(object):
a = descr
x = X()
self.assertIs(x.a, descr)
x.a = 42
self.assertEqual(x.a, 42)
def test_getattr_hooks(self):
# issue 4230
......
......@@ -313,6 +313,42 @@ class StrtodTests(unittest.TestCase):
'4106250198039490000000000000000000000000000000000000000e-38',
# issue 7632 bug 8: the following produced 10.0
'10.900000000000000012345678912345678912345',
# two humongous values from issue 7743
'116512874940594195638617907092569881519034793229385' #...
'228569165191541890846564669771714896916084883987920' #...
'473321268100296857636200926065340769682863349205363' #...
'349247637660671783209907949273683040397979984107806' #...
'461822693332712828397617946036239581632976585100633' #...
'520260770761060725403904123144384571612073732754774' #...
'588211944406465572591022081973828448927338602556287' #...
'851831745419397433012491884869454462440536895047499' #...
'436551974649731917170099387762871020403582994193439' #...
'761933412166821484015883631622539314203799034497982' #...
'130038741741727907429575673302461380386596501187482' #...
'006257527709842179336488381672818798450229339123527' #...
'858844448336815912020452294624916993546388956561522' #...
'161875352572590420823607478788399460162228308693742' #...
'05287663441403533948204085390898399055004119873046875e-1075',
'525440653352955266109661060358202819561258984964913' #...
'892256527849758956045218257059713765874251436193619' #...
'443248205998870001633865657517447355992225852945912' #...
'016668660000210283807209850662224417504752264995360' #...
'631512007753855801075373057632157738752800840302596' #...
'237050247910530538250008682272783660778181628040733' #...
'653121492436408812668023478001208529190359254322340' #...
'397575185248844788515410722958784640926528544043090' #...
'115352513640884988017342469275006999104519620946430' #...
'818767147966495485406577703972687838176778993472989' #...
'561959000047036638938396333146685137903018376496408' #...
'319705333868476925297317136513970189073693314710318' #...
'991252811050501448326875232850600451776091303043715' #...
'157191292827614046876950225714743118291034780466325' #...
'085141343734564915193426994587206432697337118211527' #...
'278968731294639353354774788602467795167875117481660' #...
'4738791256853675690543663283782215866825e-1180',
# exercise exit conditions in bigcomp comparison loop
'2602129298404963083833853479113577253105939995688e2',
'260212929840496308383385347911357725310593999568896e0',
......
......@@ -49,6 +49,10 @@
#define HASH_OBJ_CONSTRUCTOR 0
#endif
/* Minimum OpenSSL version needed to support sha224 and higher. */
#if defined(OPENSSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER >= 0x00908000)
#define _OPENSSL_SUPPORTS_SHA2
#endif
typedef struct {
PyObject_HEAD
......@@ -70,10 +74,12 @@ static PyTypeObject EVPtype;
DEFINE_CONSTS_FOR_NEW(md5)
DEFINE_CONSTS_FOR_NEW(sha1)
#ifdef _OPENSSL_SUPPORTS_SHA2
DEFINE_CONSTS_FOR_NEW(sha224)
DEFINE_CONSTS_FOR_NEW(sha256)
DEFINE_CONSTS_FOR_NEW(sha384)
DEFINE_CONSTS_FOR_NEW(sha512)
#endif
static EVPobject *
......@@ -537,10 +543,12 @@ EVP_new(PyObject *self, PyObject *args, PyObject *kwdict)
GEN_CONSTRUCTOR(md5)
GEN_CONSTRUCTOR(sha1)
#ifdef _OPENSSL_SUPPORTS_SHA2
GEN_CONSTRUCTOR(sha224)
GEN_CONSTRUCTOR(sha256)
GEN_CONSTRUCTOR(sha384)
GEN_CONSTRUCTOR(sha512)
#endif
/* List of functions exported by this module */
......@@ -548,11 +556,13 @@ static struct PyMethodDef EVP_functions[] = {
{"new", (PyCFunction)EVP_new, METH_VARARGS|METH_KEYWORDS, EVP_new__doc__},
CONSTRUCTOR_METH_DEF(md5),
CONSTRUCTOR_METH_DEF(sha1),
#ifdef _OPENSSL_SUPPORTS_SHA2
CONSTRUCTOR_METH_DEF(sha224),
CONSTRUCTOR_METH_DEF(sha256),
CONSTRUCTOR_METH_DEF(sha384),
CONSTRUCTOR_METH_DEF(sha512),
{NULL, NULL} /* Sentinel */
#endif
{NULL, NULL} /* Sentinel */
};
......@@ -599,9 +609,11 @@ PyInit__hashlib(void)
/* these constants are used by the convenience constructors */
INIT_CONSTRUCTOR_CONSTANTS(md5);
INIT_CONSTRUCTOR_CONSTANTS(sha1);
#ifdef _OPENSSL_SUPPORTS_SHA2
INIT_CONSTRUCTOR_CONSTANTS(sha224);
INIT_CONSTRUCTOR_CONSTANTS(sha256);
INIT_CONSTRUCTOR_CONSTANTS(sha384);
INIT_CONSTRUCTOR_CONSTANTS(sha512);
#endif
return m;
}
......@@ -13,7 +13,8 @@ STRINGLIB_CHAR
STRINGLIB_EMPTY
a PyObject representing the empty string
a PyObject representing the empty string, only to be used if
STRINGLIB_MUTABLE is 0
Py_ssize_t STRINGLIB_LEN(PyObject*)
......@@ -31,9 +32,9 @@ STRINGLIB_CHAR* STRINGLIB_STR(PyObject*)
int STRINGLIB_CHECK_EXACT(PyObject *)
returns true if the object is an instance of our type, not a subclass.
returns true if the object is an instance of our type, not a subclass
STRINGLIB_MUTABLE
Must be 0 or 1 to tell the cpp macros in stringlib code if the object
being operated on is mutable or not.
must be 0 or 1 to tell the cpp macros in stringlib code if the object
being operated on is mutable or not
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment