Commit 1b7f891f authored by Thomas Wouters's avatar Thomas Wouters

Merged revisions 58095-58132,58136-58148,58151-58197 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r58096 | brett.cannon | 2007-09-10 23:38:27 +0200 (Mon, 10 Sep 2007) | 4 lines

  Fix a possible segfault from recursing too deep to get the repr of a list.

  Closes issue #1096.
........
  r58097 | bill.janssen | 2007-09-10 23:51:02 +0200 (Mon, 10 Sep 2007) | 33 lines

  More work on SSL support.

  * Much expanded test suite:

    All protocols tested against all other protocols.
    All protocols tested with all certificate options.
    Tests for bad key and bad cert.
    Test of STARTTLS functionality.
    Test of RAND_* functions.

  * Fixes for threading/malloc bug.

  * Issue 1065 fixed:

    sslsocket class renamed to SSLSocket.
    sslerror class renamed to SSLError.
    Function "wrap_socket" now used to wrap an existing socket.

  * Issue 1583946 finally fixed:

    Support for subjectAltName added.
    Subject name now returned as proper DN list of RDNs.

  * SSLError exported from socket as "sslerror".

  * RAND_* functions properly exported from ssl.py.

  * Documentation improved:

    Example of how to create a self-signed certificate.
    Better indexing.
........
  r58098 | guido.van.rossum | 2007-09-11 00:02:25 +0200 (Tue, 11 Sep 2007) | 9 lines

  Patch # 1140 (my code, approved by Effbot).

  Make sure the type of the return value of re.sub(x, y, z) is the type
  of y+x (i.e. unicode if either is unicode, str if they are both str)
  even if there are no substitutions or if x==z (which triggered various
  special cases in join_list()).

  Could be backported to 2.5; no need to port to 3.0.
........
  r58099 | guido.van.rossum | 2007-09-11 00:36:02 +0200 (Tue, 11 Sep 2007) | 8 lines

  Patch # 1026 by Benjamin Aranguren (with Alex Martelli):
  Backport abc.py and isinstance/issubclass overloading to 2.6.

  I had to backport test_typechecks.py myself, and make one small change
  to abc.py to avoid duplicate work when x.__class__ and type(x) are the
  same.
........
  r58100 | bill.janssen | 2007-09-11 01:41:24 +0200 (Tue, 11 Sep 2007) | 3 lines

  A better way of finding an open port to test with.
........
  r58101 | bill.janssen | 2007-09-11 03:09:19 +0200 (Tue, 11 Sep 2007) | 4 lines

  Make sure test_ssl doesn't reference the ssl module in a
  context where it can't be imported.
........
  r58102 | bill.janssen | 2007-09-11 04:42:07 +0200 (Tue, 11 Sep 2007) | 3 lines

  Fix some documentation bugs.
........
  r58103 | nick.coghlan | 2007-09-11 16:01:18 +0200 (Tue, 11 Sep 2007) | 1 line

  Always use the -E flag when spawning subprocesses in test_cmd_line (Issue 1056)
........
  r58106 | thomas.heller | 2007-09-11 21:17:48 +0200 (Tue, 11 Sep 2007) | 3 lines

  Disable some tests that fail on the 'ppc Debian unstable' buildbot to
  find out if they cause the segfault on the 'alpha Debian' machine.
........
  r58108 | brett.cannon | 2007-09-11 23:02:28 +0200 (Tue, 11 Sep 2007) | 6 lines

  Generators had their throw() method allowing string exceptions.  That's a
  no-no.

  Fixes issue #1147.  Need to fix 2.5 to raise a proper warning if a string
  exception is passed in.
........
  r58112 | georg.brandl | 2007-09-12 20:03:51 +0200 (Wed, 12 Sep 2007) | 3 lines

  New documentation page for the bdb module.
  (This doesn't need to be merged to Py3k.)
........
  r58114 | georg.brandl | 2007-09-12 20:05:57 +0200 (Wed, 12 Sep 2007) | 2 lines

  Bug #1152: use non-deprecated name in example.
........
  r58115 | georg.brandl | 2007-09-12 20:08:33 +0200 (Wed, 12 Sep 2007) | 2 lines

  Fix #1122: wrong return type documented for various _Size() functions.
........
  r58117 | georg.brandl | 2007-09-12 20:10:56 +0200 (Wed, 12 Sep 2007) | 2 lines

  Fix #1139: PyFile_Encoding really is PyFile_SetEncoding.
........
  r58119 | georg.brandl | 2007-09-12 20:29:18 +0200 (Wed, 12 Sep 2007) | 2 lines

  bug #1154: release memory allocated by "es" PyArg_ParseTuple format specifier.
........
  r58121 | bill.janssen | 2007-09-12 20:52:05 +0200 (Wed, 12 Sep 2007) | 1 line

  root certificate for https://svn.python.org/, used in test_ssl
........
  r58122 | georg.brandl | 2007-09-12 21:00:07 +0200 (Wed, 12 Sep 2007) | 3 lines

  Bug #1153: repr.repr() now doesn't require set and dictionary items
  to be orderable to properly represent them.
........
  r58125 | georg.brandl | 2007-09-12 21:29:28 +0200 (Wed, 12 Sep 2007) | 4 lines

  #1120: put explicit version in the shebang lines of pydoc, idle
  and smtpd.py scripts that are installed by setup.py. That way, they
  work when only "make altinstall" is used.
........
  r58139 | mark.summerfield | 2007-09-13 16:54:30 +0200 (Thu, 13 Sep 2007) | 9 lines

  Replaced variable o with obj in operator.rst because o is easy to
  confuse.

  Added a note about Python 3's collections.Mapping etc., above section
  that describes isMappingType() etc.

  Added xrefs between os, os.path, fileinput, and open().
........
  r58143 | facundo.batista | 2007-09-13 20:13:15 +0200 (Thu, 13 Sep 2007) | 7 lines


  Merged the decimal-branch (revisions 54886 to 58140). Decimal is now
  fully updated to the latests Decimal Specification (v1.66) and the
  latests test cases (v2.56).

  Thanks to Mark Dickinson for all his help during this process.
........
  r58145 | facundo.batista | 2007-09-13 20:42:09 +0200 (Thu, 13 Sep 2007) | 7 lines


  Put the parameter watchexp back in (changed watchexp from an int
  to a bool).  Also second argument to watchexp is now converted
  to Decimal, just as with all the other two-argument operations.

  Thanks Mark Dickinson.
........
  r58147 | andrew.kuchling | 2007-09-14 00:49:34 +0200 (Fri, 14 Sep 2007) | 1 line

  Add various items
........
  r58148 | andrew.kuchling | 2007-09-14 00:50:10 +0200 (Fri, 14 Sep 2007) | 1 line

  Make target unique
........
  r58154 | facundo.batista | 2007-09-14 20:58:34 +0200 (Fri, 14 Sep 2007) | 3 lines


  Included the new functions, and new descriptions.
........
  r58155 | thomas.heller | 2007-09-14 21:40:35 +0200 (Fri, 14 Sep 2007) | 2 lines

  ctypes.util.find_library uses dump(1) instead of objdump(1) on Solaris.
  Fixes issue #1777530; will backport to release25-maint.
........
  r58159 | facundo.batista | 2007-09-14 23:29:52 +0200 (Fri, 14 Sep 2007) | 3 lines


  Some additions (examples and a bit on the tutorial).
........
  r58160 | georg.brandl | 2007-09-15 18:53:36 +0200 (Sat, 15 Sep 2007) | 2 lines

  Remove bdb from the "undocumented modules" list.
........
  r58164 | bill.janssen | 2007-09-17 00:06:00 +0200 (Mon, 17 Sep 2007) | 15 lines

  Add support for asyncore server-side SSL support.  This requires
  adding the 'makefile' method to ssl.SSLSocket, and importing the
  requisite fakefile class from socket.py, and making the appropriate
  changes to it to make it use the SSL connection.

  Added sample HTTPS server to test_ssl.py, and test that uses it.

  Change SSL tests to use https://svn.python.org/, instead of
  www.sf.net and pop.gmail.com.

  Added utility function to ssl module, get_server_certificate,
  to wrap up the several things to be done to pull a certificate
  from a remote server.
........
  r58173 | bill.janssen | 2007-09-17 01:16:46 +0200 (Mon, 17 Sep 2007) | 1 line

  use binary mode when reading files for testAsyncore to make Windows happy
........
  r58175 | raymond.hettinger | 2007-09-17 02:55:00 +0200 (Mon, 17 Sep 2007) | 7 lines

  Sync-up named tuples with the latest version of the ASPN recipe.
  Allows optional commas in the field-name spec (help when named tuples are used in conjuction with sql queries).
  Adds the __fields__ attribute for introspection and to support conversion to dictionary form.
  Adds a  __replace__() method similar to str.replace() but using a named field as a target.
  Clean-up spelling and presentation in doc-strings.
........
  r58176 | brett.cannon | 2007-09-17 05:28:34 +0200 (Mon, 17 Sep 2007) | 5 lines

  Add a bunch of GIL release/acquire points in tp_print implementations and for
  PyObject_Print().

  Closes issue #1164.
........
  r58177 | sean.reifschneider | 2007-09-17 07:45:04 +0200 (Mon, 17 Sep 2007) | 2 lines

  issue1597011: Fix for bz2 module corner-case error due to error checking bug.
........
  r58180 | facundo.batista | 2007-09-17 18:26:50 +0200 (Mon, 17 Sep 2007) | 3 lines


  Decimal is updated, :)
........
  r58181 | facundo.batista | 2007-09-17 19:30:13 +0200 (Mon, 17 Sep 2007) | 5 lines


  The methods always return Decimal classes, even if they're
  executed through a subclass (thanks Mark Dickinson).
  Added a bit of testing for this.
........
  r58183 | sean.reifschneider | 2007-09-17 22:53:21 +0200 (Mon, 17 Sep 2007) | 2 lines

  issue1082: Fixing platform and system for Vista.
........
  r58185 | andrew.kuchling | 2007-09-18 03:36:16 +0200 (Tue, 18 Sep 2007) | 1 line

  Add item; sort properly
........
  r58186 | raymond.hettinger | 2007-09-18 05:33:19 +0200 (Tue, 18 Sep 2007) | 1 line

  Handle corner cased on 0-tuples and 1-tuples.  Add verbose option so people can see how it works.
........
  r58192 | georg.brandl | 2007-09-18 09:24:40 +0200 (Tue, 18 Sep 2007) | 2 lines

  A bit of reordering, also show more subheadings in the lang ref index.
........
  r58193 | facundo.batista | 2007-09-18 18:53:18 +0200 (Tue, 18 Sep 2007) | 4 lines


  Speed up of the various division operations (remainder, divide,
  divideint and divmod). Thanks Mark Dickinson.
........
  r58197 | raymond.hettinger | 2007-09-19 00:18:02 +0200 (Wed, 19 Sep 2007) | 1 line

  Cleanup docs for NamedTuple.
........
parent 782d6b44
......@@ -1953,12 +1953,12 @@ Tuple Objects
``PyTuple_Pack(2, a, b)`` is equivalent to ``Py_BuildValue("(OO)", a, b)``.
.. cfunction:: int PyTuple_Size(PyObject *p)
.. cfunction:: Py_ssize_t PyTuple_Size(PyObject *p)
Take a pointer to a tuple object, and return the size of that tuple.
.. cfunction:: int PyTuple_GET_SIZE(PyObject *p)
.. cfunction:: Py_ssize_t PyTuple_GET_SIZE(PyObject *p)
Return the size of the tuple *p*, which must be non-*NULL* and point to a tuple;
no error checking is performed.
......@@ -2458,7 +2458,7 @@ change in future releases of Python.
immediately after file object creation.
.. cfunction:: int PyFile_Encoding(PyFileObject *p, char *enc)
.. cfunction:: int PyFile_SetEncoding(PyFileObject *p, const char *enc)
Set the file's encoding for Unicode output to *enc*. Return 1 on success and 0
on failure.
......@@ -3371,7 +3371,7 @@ The following functions and macros are available for instances of :class:`set`
or :class:`frozenset` or instances of their subtypes.
.. cfunction:: int PySet_Size(PyObject *anyset)
.. cfunction:: Py_ssize_t PySet_Size(PyObject *anyset)
.. index:: builtin: len
......@@ -3380,7 +3380,7 @@ or :class:`frozenset` or instances of their subtypes.
:class:`set`, :class:`frozenset`, or an instance of a subtype.
.. cfunction:: int PySet_GET_SIZE(PyObject *anyset)
.. cfunction:: Py_ssize_t PySet_GET_SIZE(PyObject *anyset)
Macro form of :cfunc:`PySet_Size` without error checking.
......
......@@ -395,11 +395,14 @@ Setting the :attr:`default_factory` to :class:`set` makes the
.. _named-tuple-factory:
:func:`NamedTuple` datatype factory function
--------------------------------------------
:func:`NamedTuple` factory function
-----------------------------------
Named tuples assign meaning to each position in a tuple and allow for more readable,
self-documenting code. They can be used wherever regular tuples are used, and
they add the ability to access fields by name instead of position index.
.. function:: NamedTuple(typename, fieldnames)
.. function:: NamedTuple(typename, fieldnames, [verbose])
Returns a new tuple subclass named *typename*. The new subclass is used to
create tuple-like objects that have fields accessable by attribute lookup as
......@@ -407,43 +410,88 @@ Setting the :attr:`default_factory` to :class:`set` makes the
helpful docstring (with typename and fieldnames) and a helpful :meth:`__repr__`
method which lists the tuple contents in a ``name=value`` format.
The *fieldnames* are specified in a single string and are separated by spaces.
Any valid Python identifier may be used for a field name.
Example::
>>> Point = NamedTuple('Point', 'x y')
>>> Point.__doc__ # docstring for the new datatype
'Point(x, y)'
>>> p = Point(11, y=22) # instantiate with positional or keyword arguments
>>> p[0] + p[1] # works just like the tuple (11, 22)
33
>>> x, y = p # unpacks just like a tuple
>>> x, y
(11, 22)
>>> p.x + p.y # fields also accessable by name
33
>>> p # readable __repr__ with name=value style
Point(x=11, y=22)
The use cases are the same as those for tuples. The named factories assign
meaning to each tuple position and allow for more readable, self-documenting
code. Named tuples can also be used to assign field names to tuples returned
by the :mod:`csv` or :mod:`sqlite3` modules. For example::
from itertools import starmap
import csv
EmployeeRecord = NamedTuple('EmployeeRecord', 'name age title department paygrade')
for record in starmap(EmployeeRecord, csv.reader(open("employees.csv", "rb"))):
print(record)
To cast an individual record stored as :class:`list`, :class:`tuple`, or some
other iterable type, use the star-operator [#]_ to unpack the values::
>>> Color = NamedTuple('Color', 'name code')
>>> m = dict(red=1, green=2, blue=3)
>>> print(Color(*m.popitem()))
Color(name='blue', code=3)
The *fieldnames* are specified in a single string with each fieldname separated by
a space and/or comma. Any valid Python identifier may be used for a field name.
If *verbose* is true, the *NamedTuple* call will print the class definition.
*NamedTuple* instances do not have per-instance dictionaries, so they are
lightweight, requiring no more memory than regular tuples.
Example::
>>> Point = NamedTuple('Point', 'x y', True)
class Point(tuple):
'Point(x, y)'
__slots__ = ()
__fields__ = ('x', 'y')
def __new__(cls, x, y):
return tuple.__new__(cls, (x, y))
def __repr__(self):
return 'Point(x=%r, y=%r)' % self
def __replace__(self, field, value):
'Return a new Point object replacing one field with a new value'
return Point(**dict(zip(('x', 'y'), self) + [(field, value)]))
x = property(itemgetter(0))
y = property(itemgetter(1))
>>> p = Point(11, y=22) # instantiate with positional or keyword arguments
>>> p[0] + p[1] # indexable like the regular tuple (11, 22)
33
>>> x, y = p # unpack like a regular tuple
>>> x, y
(11, 22)
>>> p.x + p.y # fields also accessable by name
33
>>> p # readable __repr__ with a name=value style
Point(x=11, y=22)
Named tuples are especially useful for assigning field names to result tuples returned
by the :mod:`csv` or :mod:`sqlite3` modules::
from itertools import starmap
import csv
EmployeeRecord = NamedTuple('EmployeeRecord', 'name age title department paygrade')
for record in starmap(EmployeeRecord, csv.reader(open("employees.csv", "rb"))):
print(emp.name, emp.title)
When casting a single record to a *NamedTuple*, use the star-operator [#]_ to unpack
the values::
>>> t = [11, 22]
>>> Point(*t) # the star-operator unpacks any iterable object
Point(x=11, y=22)
In addition to the methods inherited from tuples, named tuples support
an additonal method and an informational read-only attribute.
.. method:: somenamedtuple.replace(field, value)
Return a new instance of the named tuple replacing the named *field* with a new *value*::
>>> p = Point(x=11, y=22)
>>> p.__replace__('x', 33)
Point(x=33, y=22)
>>> for recordnum, record in inventory:
... inventory[recordnum] = record.replace('total', record.price * record.quantity)
.. attribute:: somenamedtuple.__fields__
Return a tuple of strings listing the field names. This is useful for introspection,
for converting a named tuple instance to a dictionary, and for combining named tuple
types to create new named tuple types::
>>> p.__fields__ # view the field names
('x', 'y')
>>> dict(zip(p.__fields__, p)) # convert to a dictionary
{'y': 22, 'x': 11}
>>> Color = NamedTuple('Color', 'red green blue')
>>> pixel_fields = ' '.join(Point.__fields__ + Color.__fields__) # combine fields
>>> Pixel = NamedTuple('Pixel', pixel_fields)
>>> Pixel(11, 22, 128, 255, 0)
Pixel(x=11, y=22, red=128, green=255, blue=0)'
.. rubric:: Footnotes
......
This diff is collapsed.
......@@ -7,8 +7,9 @@
.. sectionauthor:: Fred L. Drake, Jr. <fdrake@acm.org>
This module implements a helper class and functions to quickly write a loop over
standard input or a list of files.
This module implements a helper class and functions to quickly write a
loop over standard input or a list of files. If you just want to read or
write one file see :func:`open`.
The typical use is::
......
......@@ -746,7 +746,8 @@ available. They are listed here in alphabetical order.
Python enforces that the mode, after stripping ``'U'``, begins with ``'r'``,
``'w'`` or ``'a'``.
See also the :mod:`fileinput` module.
See also the :mod:`fileinput` module, the :mod:`os` module, and the
:mod:`os.path` module.
.. function:: ord(c)
......
......@@ -36,7 +36,7 @@ concatenation of the data fed to it so far using the :meth:`digest` or
Feeding string objects is to :meth:`update` is not supported, as hashes work
on bytes, not on characters.
.. index:: single: OpenSSL
.. index:: single: OpenSSL; (use in module hashlib)
Constructors for hash algorithms that are always present in this module are
:func:`md5`, :func:`sha1`, :func:`sha224`, :func:`sha256`, :func:`sha384`, and
......
......@@ -47,18 +47,18 @@ The logical operations are also generally applicable to all objects, and support
truth tests, identity tests, and boolean operations:
.. function:: not_(o)
__not__(o)
.. function:: not_(obj)
__not__(obj)
Return the outcome of :keyword:`not` *o*. (Note that there is no
Return the outcome of :keyword:`not` *obj*. (Note that there is no
:meth:`__not__` method for object instances; only the interpreter core defines
this operation. The result is affected by the :meth:`__bool__` and
:meth:`__len__` methods.)
.. function:: truth(o)
.. function:: truth(obj)
Return :const:`True` if *o* is true, and :const:`False` otherwise. This is
Return :const:`True` if *obj* is true, and :const:`False` otherwise. This is
equivalent to using the :class:`bool` constructor.
......@@ -75,10 +75,10 @@ truth tests, identity tests, and boolean operations:
The mathematical and bitwise operations are the most numerous:
.. function:: abs(o)
__abs__(o)
.. function:: abs(obj)
__abs__(obj)
Return the absolute value of *o*.
Return the absolute value of *obj*.
.. function:: add(a, b)
......@@ -106,12 +106,12 @@ The mathematical and bitwise operations are the most numerous:
Return ``a // b``.
.. function:: inv(o)
invert(o)
__inv__(o)
__invert__(o)
.. function:: inv(obj)
invert(obj)
__inv__(obj)
__invert__(obj)
Return the bitwise inverse of the number *o*. This is equivalent to ``~o``.
Return the bitwise inverse of the number *obj*. This is equivalent to ``~obj``.
.. function:: lshift(a, b)
......@@ -132,10 +132,10 @@ The mathematical and bitwise operations are the most numerous:
Return ``a * b``, for *a* and *b* numbers.
.. function:: neg(o)
__neg__(o)
.. function:: neg(obj)
__neg__(obj)
Return *o* negated.
Return *obj* negated.
.. function:: or_(a, b)
......@@ -144,10 +144,10 @@ The mathematical and bitwise operations are the most numerous:
Return the bitwise or of *a* and *b*.
.. function:: pos(o)
__pos__(o)
.. function:: pos(obj)
__pos__(obj)
Return *o* positive.
Return *obj* positive.
.. function:: pow(a, b)
......@@ -373,24 +373,30 @@ objects.
... pass
...
>>> import operator
>>> o = C()
>>> operator.isMappingType(o)
>>> obj = C()
>>> operator.isMappingType(obj)
True
.. note::
Python 3 is expected to introduce abstract base classes for
collection types, so it should be possible to write, for example,
``isinstance(obj, collections.Mapping)`` and ``isinstance(obj,
collections.Sequence)``.
.. function:: isCallable(o)
.. function:: isCallable(obj)
.. deprecated:: 2.0
Use the :func:`callable` built-in function instead.
Returns true if the object *o* can be called like a function, otherwise it
Returns true if the object *obj* can be called like a function, otherwise it
returns false. True is returned for functions, bound and unbound methods, class
objects, and instance objects which support the :meth:`__call__` method.
.. function:: isMappingType(o)
.. function:: isMappingType(obj)
Returns true if the object *o* supports the mapping interface. This is true for
Returns true if the object *obj* supports the mapping interface. This is true for
dictionaries and all instance objects defining :meth:`__getitem__`.
.. warning::
......@@ -400,9 +406,9 @@ objects.
useful than it otherwise might be.
.. function:: isNumberType(o)
.. function:: isNumberType(obj)
Returns true if the object *o* represents a number. This is true for all
Returns true if the object *obj* represents a number. This is true for all
numeric types implemented in C.
.. warning::
......@@ -412,9 +418,9 @@ objects.
useful than it otherwise might be.
.. function:: isSequenceType(o)
.. function:: isSequenceType(obj)
Returns true if the object *o* supports the sequence protocol. This returns true
Returns true if the object *obj* supports the sequence protocol. This returns true
for all objects which define sequence methods in C, and for all instance objects
defining :meth:`__getitem__`.
......@@ -484,7 +490,7 @@ Python syntax and the functions in the :mod:`operator` module.
+-----------------------+-------------------------+---------------------------------+
| Concatenation | ``seq1 + seq2`` | ``concat(seq1, seq2)`` |
+-----------------------+-------------------------+---------------------------------+
| Containment Test | ``o in seq`` | ``contains(seq, o)`` |
| Containment Test | ``obj in seq`` | ``contains(seq, obj)`` |
+-----------------------+-------------------------+---------------------------------+
| Division | ``a / b`` | ``div(a, b)`` (without |
| | | ``__future__.division``) |
......@@ -508,11 +514,11 @@ Python syntax and the functions in the :mod:`operator` module.
+-----------------------+-------------------------+---------------------------------+
| Identity | ``a is not b`` | ``is_not(a, b)`` |
+-----------------------+-------------------------+---------------------------------+
| Indexed Assignment | ``o[k] = v`` | ``setitem(o, k, v)`` |
| Indexed Assignment | ``obj[k] = v`` | ``setitem(obj, k, v)`` |
+-----------------------+-------------------------+---------------------------------+
| Indexed Deletion | ``del o[k]`` | ``delitem(o, k)`` |
| Indexed Deletion | ``del obj[k]`` | ``delitem(obj, k)`` |
+-----------------------+-------------------------+---------------------------------+
| Indexing | ``o[k]`` | ``getitem(o, k)`` |
| Indexing | ``obj[k]`` | ``getitem(obj, k)`` |
+-----------------------+-------------------------+---------------------------------+
| Left Shift | ``a << b`` | ``lshift(a, b)`` |
+-----------------------+-------------------------+---------------------------------+
......@@ -534,11 +540,11 @@ Python syntax and the functions in the :mod:`operator` module.
+-----------------------+-------------------------+---------------------------------+
| Slicing | ``seq[i:j]`` | ``getslice(seq, i, j)`` |
+-----------------------+-------------------------+---------------------------------+
| String Formatting | ``s % o`` | ``mod(s, o)`` |
| String Formatting | ``s % obj`` | ``mod(s, obj)`` |
+-----------------------+-------------------------+---------------------------------+
| Subtraction | ``a - b`` | ``sub(a, b)`` |
+-----------------------+-------------------------+---------------------------------+
| Truth Test | ``o`` | ``truth(o)`` |
| Truth Test | ``obj`` | ``truth(obj)`` |
+-----------------------+-------------------------+---------------------------------+
| Ordering | ``a < b`` | ``lt(a, b)`` |
+-----------------------+-------------------------+---------------------------------+
......
......@@ -8,9 +8,10 @@
This module provides a more portable way of using operating system dependent
functionality than importing a operating system dependent built-in module like
:mod:`posix` or :mod:`nt`. (If you just want to read or write a file see
:func:`open`, and if you want to manipulate paths, see the :mod:`os.path`
module.)
:mod:`posix` or :mod:`nt`. If you just want to read or write a file see
:func:`open`, if you want to manipulate paths, see the :mod:`os.path`
module, and if you want to read all the lines in all the files on the
command line see the :mod:`fileinput` module.
This module searches for an operating system dependent built-in module like
:mod:`mac` or :mod:`posix` and exports the same functions and data as found
......
......@@ -142,7 +142,7 @@ server::
import xmlrpclib
s = xmlrpclib.Server('http://localhost:8000')
s = xmlrpclib.ServerProxy('http://localhost:8000')
print(s.pow(2,3)) # Returns 2**3 = 8
print(s.add(2,3)) # Returns 5
print(s.div(5,2)) # Returns 5//2 = 2
......
This diff is collapsed.
......@@ -19,9 +19,6 @@ Miscellaneous useful utilities
Some of these are very old and/or not very robust; marked with "hmm."
:mod:`bdb`
--- A generic Python debugger base class (used by pdb).
:mod:`ihooks`
--- Import hook support (for :mod:`rexec`; may become obsolete).
......
......@@ -17,7 +17,7 @@ write a Python extension module, and the :ref:`c-api-index` describes the
interfaces available to C/C++ programmers in detail.
.. toctree::
:maxdepth: 2
:maxdepth: 3
introduction.rst
lexical_analysis.rst
......
......@@ -62,47 +62,6 @@ using the built-in :func:`repr` function and the resulting string is written to
standard output on a line by itself (except if the result is ``None``, so that
procedure calls do not cause any output.)
.. _assert:
Assert statements
=================
.. index::
statement: assert
pair: debugging; assertions
single: __debug__
exception: AssertionError
Assert statements are a convenient way to insert debugging assertions into a
program:
.. productionlist::
assert_stmt: "assert" `expression` ["," `expression`]
The simple form, ``assert expression``, is equivalent to ::
if __debug__:
if not expression: raise AssertionError
The extended form, ``assert expression1, expression2``, is equivalent to ::
if __debug__:
if not expression1: raise AssertionError(expression2)
These equivalences assume that :data:`__debug__` and :exc:`AssertionError` refer
to the built-in variables with those names. In the current implementation, the
built-in variable :data:`__debug__` is ``True`` under normal circumstances,
``False`` when optimization is requested (command line option ``-O``). The
current code generator emits no code for an assert statement when optimization
is requested at compile time. Note that it is unnecessary to include the source
code for the expression that failed in the error message; it will be displayed
as part of the stack trace.
Assignments to :data:`__debug__` are illegal. The value for the built-in
variable is determined when the interpreter starts.
.. _assignment:
Assignment statements
......@@ -308,6 +267,48 @@ instance variable. For example::
a.x += 1 # writes a.x as 4 leaving A.x as 3
.. _assert:
The :keyword:`assert` statement
===============================
.. index::
statement: assert
pair: debugging; assertions
Assert statements are a convenient way to insert debugging assertions into a
program:
.. productionlist::
assert_stmt: "assert" `expression` ["," `expression`]
The simple form, ``assert expression``, is equivalent to ::
if __debug__:
if not expression: raise AssertionError
The extended form, ``assert expression1, expression2``, is equivalent to ::
if __debug__:
if not expression1: raise AssertionError, expression2
.. index::
single: __debug__
exception: AssertionError
These equivalences assume that ``__debug__`` and :exc:`AssertionError` refer to
the built-in variables with those names. In the current implementation, the
built-in variable ``__debug__`` is ``True`` under normal circumstances,
``False`` when optimization is requested (command line option -O). The current
code generator emits no code for an assert statement when optimization is
requested at compile time. Note that it is unnecessary to include the source
code for the expression that failed in the error message; it will be displayed
as part of the stack trace.
Assignments to ``__debug__`` are illegal. The value for the built-in variable
is determined when the interpreter starts.
.. _pass:
The :keyword:`pass` statement
......
......@@ -637,7 +637,7 @@ precision and rounding characteristics for computations::
print v.sqrt()
.. _context-managers:
.. _new-25-context-managers:
Writing Context Managers
------------------------
......
This diff is collapsed.
......@@ -11,40 +11,50 @@ import _abcoll
__all__ += _abcoll.__all__
def NamedTuple(typename, s):
def NamedTuple(typename, s, verbose=False):
"""Returns a new subclass of tuple with named fields.
>>> Point = NamedTuple('Point', 'x y')
>>> Point.__doc__ # docstring for the new class
>>> Point.__doc__ # docstring for the new class
'Point(x, y)'
>>> p = Point(11, y=22) # instantiate with positional args or keywords
>>> p[0] + p[1] # works just like the tuple (11, 22)
>>> p = Point(11, y=22) # instantiate with positional args or keywords
>>> p[0] + p[1] # works just like the tuple (11, 22)
33
>>> x, y = p # unpacks just like a tuple
>>> x, y = p # unpacks just like a tuple
>>> x, y
(11, 22)
>>> p.x + p.y # fields also accessable by name
>>> p.x + p.y # fields also accessable by name
33
>>> p # readable __repr__ with name=value style
>>> p # readable __repr__ with name=value style
Point(x=11, y=22)
>>> p.__replace__('x', 100) # __replace__() is like str.replace() but targets a named field
Point(x=100, y=22)
>>> d = dict(zip(p.__fields__, p)) # use __fields__ to make a dictionary
>>> d['x']
11
"""
field_names = s.split()
if not ''.join([typename] + field_names).replace('_', '').isalnum():
field_names = tuple(s.replace(',', ' ').split()) # names separated by spaces and/or commas
if not ''.join((typename,) + field_names).replace('_', '').isalnum():
raise ValueError('Type names and field names can only contain alphanumeric characters and underscores')
argtxt = ', '.join(field_names)
argtxt = repr(field_names).replace("'", "")[1:-1] # tuple repr without parens or quotes
reprtxt = ', '.join('%s=%%r' % name for name in field_names)
template = '''class %(typename)s(tuple):
'%(typename)s(%(argtxt)s)'
__slots__ = ()
__fields__ = %(field_names)r
def __new__(cls, %(argtxt)s):
return tuple.__new__(cls, (%(argtxt)s,))
return tuple.__new__(cls, (%(argtxt)s))
def __repr__(self):
return '%(typename)s(%(reprtxt)s)' %% self
''' % locals()
def __replace__(self, field, value):
'Return a new %(typename)s object replacing one field with a new value'
return %(typename)s(**dict(list(zip(%(field_names)r, self)) + [(field, value)])) \n''' % locals()
for i, name in enumerate(field_names):
template += '\n %s = property(itemgetter(%d))\n' % (name, i)
template += ' %s = property(itemgetter(%d))\n' % (name, i)
if verbose:
print(template)
m = dict(itemgetter=_itemgetter)
exec(template, m)
result = m[typename]
......@@ -57,9 +67,9 @@ def NamedTuple(typename, s):
if __name__ == '__main__':
# verify that instances are pickable
# verify that instances can be pickled
from pickle import loads, dumps
Point = NamedTuple('Point', 'x y')
Point = NamedTuple('Point', 'x, y', True)
p = Point(x=10, y=20)
assert p == loads(dumps(p))
......
......@@ -158,17 +158,17 @@ class CFunctions(unittest.TestCase):
self.failUnlessEqual(self._dll.tf_bd(0, 42.), 14.)
self.failUnlessEqual(self.S(), 42)
def test_longdouble(self):
self._dll.tf_D.restype = c_longdouble
self._dll.tf_D.argtypes = (c_longdouble,)
self.failUnlessEqual(self._dll.tf_D(42.), 14.)
self.failUnlessEqual(self.S(), 42)
def test_longdouble_plus(self):
self._dll.tf_bD.restype = c_longdouble
self._dll.tf_bD.argtypes = (c_byte, c_longdouble)
self.failUnlessEqual(self._dll.tf_bD(0, 42.), 14.)
self.failUnlessEqual(self.S(), 42)
## def test_longdouble(self):
## self._dll.tf_D.restype = c_longdouble
## self._dll.tf_D.argtypes = (c_longdouble,)
## self.failUnlessEqual(self._dll.tf_D(42.), 14.)
## self.failUnlessEqual(self.S(), 42)
## def test_longdouble_plus(self):
## self._dll.tf_bD.restype = c_longdouble
## self._dll.tf_bD.argtypes = (c_byte, c_longdouble)
## self.failUnlessEqual(self._dll.tf_bD(0, 42.), 14.)
## self.failUnlessEqual(self.S(), 42)
def test_callwithresult(self):
def process_result(result):
......
......@@ -143,17 +143,17 @@ class FunctionTestCase(unittest.TestCase):
self.failUnlessEqual(result, -21)
self.failUnlessEqual(type(result), float)
def test_longdoubleresult(self):
f = dll._testfunc_D_bhilfD
f.argtypes = [c_byte, c_short, c_int, c_long, c_float, c_longdouble]
f.restype = c_longdouble
result = f(1, 2, 3, 4, 5.0, 6.0)
self.failUnlessEqual(result, 21)
self.failUnlessEqual(type(result), float)
result = f(-1, -2, -3, -4, -5.0, -6.0)
self.failUnlessEqual(result, -21)
self.failUnlessEqual(type(result), float)
## def test_longdoubleresult(self):
## f = dll._testfunc_D_bhilfD
## f.argtypes = [c_byte, c_short, c_int, c_long, c_float, c_longdouble]
## f.restype = c_longdouble
## result = f(1, 2, 3, 4, 5.0, 6.0)
## self.failUnlessEqual(result, 21)
## self.failUnlessEqual(type(result), float)
## result = f(-1, -2, -3, -4, -5.0, -6.0)
## self.failUnlessEqual(result, -21)
## self.failUnlessEqual(type(result), float)
def test_longlongresult(self):
try:
......
......@@ -63,15 +63,27 @@ elif os.name == "posix":
return None
return res.group(0)
def _get_soname(f):
# assuming GNU binutils / ELF
if not f:
return None
cmd = "objdump -p -j .dynamic 2>/dev/null " + f
res = re.search(r'\sSONAME\s+([^\s]+)', os.popen(cmd).read())
if not res:
return None
return res.group(1)
if sys.platform == "sunos5":
# use /usr/ccs/bin/dump on solaris
def _get_soname(f):
if not f:
return None
cmd = "/usr/ccs/bin/dump -Lpv 2>/dev/null " + f
res = re.search(r'\[.*\]\sSONAME\s+([^\s]+)', os.popen(cmd).read())
if not res:
return None
return res.group(1)
else:
def _get_soname(f):
# assuming GNU binutils / ELF
if not f:
return None
cmd = "objdump -p -j .dynamic 2>/dev/null " + f
res = re.search(r'\sSONAME\s+([^\s]+)', os.popen(cmd).read())
if not res:
return None
return res.group(1)
if (sys.platform.startswith("freebsd")
or sys.platform.startswith("openbsd")
......
This diff is collapsed.
......@@ -102,7 +102,8 @@ class build_scripts(Command):
outf.write("#!%s%s\n" %
(os.path.join(
sysconfig.get_config_var("BINDIR"),
"python" + sysconfig.get_config_var("EXE")),
"python" + sysconfig.get_config_var("VERSION")
+ sysconfig.get_config_var("EXE")),
post_interp))
outf.writelines(f.readlines())
outf.close()
......
......@@ -985,12 +985,12 @@ else:
"Connect to a host on a given (SSL) port."
sock = socket.create_connection((self.host, self.port), self.timeout)
self.sock = ssl.sslsocket(sock, self.key_file, self.cert_file)
self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file)
def FakeSocket (sock, sslobj):
warnings.warn("FakeSocket is deprecated, and won't be in 3.x. " +
"Use the result of ssl.sslsocket directly instead.",
"Use the result of ssl.wrap_socket() directly instead.",
DeprecationWarning, stacklevel=2)
return sslobj
......
......@@ -1147,7 +1147,7 @@ else:
self.port = port
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.connect((host, port))
self.sslobj = ssl.sslsocket(self.sock, self.keyfile, self.certfile)
self.sslobj = ssl.wrap_socket(self.sock, self.keyfile, self.certfile)
def read(self, size):
......@@ -1199,7 +1199,7 @@ else:
def ssl(self):
"""Return SSLObject instance used to communicate with the IMAP4 server.
ssl = ssl.sslsocket(<instance>.socket)
ssl = ssl.wrap_socket(<instance>.socket)
"""
return self.sslobj
......
......@@ -1142,6 +1142,12 @@ def uname():
machine = ''
if processor == 'unknown':
processor = ''
# normalize name
if system == 'Microsoft' and release == 'Windows':
system = 'Windows'
release = 'Vista'
_uname_cache = system,node,release,version,machine,processor
return _uname_cache
......
......@@ -348,7 +348,7 @@ else:
if not self.sock:
raise socket.error(msg)
self.file = self.sock.makefile('rb')
self.sslobj = ssl.sslsocket(self.sock, self.keyfile, self.certfile)
self.sslobj = ssl.wrap_socket(self.sock, self.keyfile, self.certfile)
self._debugging = 0
self.welcome = self._getresp()
......
"""Redo the `...` (representation) but with limits on most sizes."""
"""Redo the builtin repr() (representation) but with limits on most sizes."""
__all__ = ["Repr","repr"]
......@@ -57,11 +57,11 @@ class Repr:
return self._repr_iterable(x, level, header, '])', self.maxarray)
def repr_set(self, x, level):
x = sorted(x)
x = _possibly_sorted(x)
return self._repr_iterable(x, level, 'set([', '])', self.maxset)
def repr_frozenset(self, x, level):
x = sorted(x)
x = _possibly_sorted(x)
return self._repr_iterable(x, level, 'frozenset([', '])',
self.maxfrozenset)
......@@ -75,7 +75,7 @@ class Repr:
newlevel = level - 1
repr1 = self.repr1
pieces = []
for key in islice(sorted(x), self.maxdict):
for key in islice(_possibly_sorted(x), self.maxdict):
keyrepr = repr1(key, newlevel)
valrepr = repr1(x[key], newlevel)
pieces.append('%s: %s' % (keyrepr, valrepr))
......@@ -105,7 +105,7 @@ class Repr:
s = __builtin__.repr(x)
# Bugs in x.__repr__() can cause arbitrary
# exceptions -- then make up something
except:
except Exception:
return '<%s instance at %x>' % (x.__class__.__name__, id(x))
if len(s) > self.maxother:
i = max(0, (self.maxother-3)//2)
......@@ -113,5 +113,15 @@ class Repr:
s = s[:i] + '...' + s[len(s)-j:]
return s
def _possibly_sorted(x):
# Since not all sequences of items can be sorted and comparison
# functions may raise arbitrary exceptions, return an unsorted
# sequence in that case.
try:
return sorted(x)
except Exception:
return list(x)
aRepr = Repr()
repr = aRepr.repr
......@@ -588,7 +588,7 @@ class SMTP:
if resp == 220:
if not _have_ssl:
raise RuntimeError("No SSL support included in this Python")
self.sock = ssl.sslsocket(self.sock, keyfile, certfile)
self.sock = ssl.wrap_socket(self.sock, keyfile, certfile)
self.file = SSLFakeFile(self.sock)
return (resp, reply)
......@@ -721,7 +721,7 @@ if _have_ssl:
def _get_socket(self, host, port, timeout):
if self.debuglevel > 0: print('connect:', (host, port), file=stderr)
self.sock = socket.create_connection((host, port), timeout)
self.sock = ssl.sslsocket(self.sock, self.keyfile, self.certfile)
self.sock = ssl.wrap_socket(self.sock, self.keyfile, self.certfile)
self.file = SSLFakeFile(self.sock)
__all__.append("SMTP_SSL")
......
......@@ -56,13 +56,13 @@ else:
def ssl(sock, keyfile=None, certfile=None):
# we do an internal import here because the ssl
# module imports the socket module
warnings.warn("socket.ssl() is deprecated. Use ssl.sslsocket() instead.",
warnings.warn("socket.ssl() is deprecated. Use ssl.wrap_socket() instead.",
DeprecationWarning, stacklevel=2)
return _realssl.sslwrap_simple(sock, keyfile, certfile)
# we need to import the same constants we used to...
from _ssl import SSLError as sslerror
from _ssl import \
sslerror, \
RAND_add, \
RAND_egd, \
RAND_status, \
......
This diff is collapsed.
-----BEGIN RSA PRIVATE KEY-----
MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L
opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH
fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB
AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU
D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA
IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM
oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0
ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/
loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j
oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA
z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq
ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV
q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU=
-----END RSA PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
Just bad cert data
-----END CERTIFICATE-----
-----BEGIN RSA PRIVATE KEY-----
MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L
opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH
fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB
AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU
D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA
IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM
oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0
ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/
loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j
oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA
z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq
ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV
q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU=
-----END RSA PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
Just bad cert data
-----END CERTIFICATE-----
-----BEGIN RSA PRIVATE KEY-----
Bad Key, though the cert should be OK
-----END RSA PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
MIICpzCCAhCgAwIBAgIJAP+qStv1cIGNMA0GCSqGSIb3DQEBBQUAMIGJMQswCQYD
VQQGEwJVUzERMA8GA1UECBMIRGVsYXdhcmUxEzARBgNVBAcTCldpbG1pbmd0b24x
IzAhBgNVBAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMQwwCgYDVQQLEwNT
U0wxHzAdBgNVBAMTFnNvbWVtYWNoaW5lLnB5dGhvbi5vcmcwHhcNMDcwODI3MTY1
NDUwWhcNMTMwMjE2MTY1NDUwWjCBiTELMAkGA1UEBhMCVVMxETAPBgNVBAgTCERl
bGF3YXJlMRMwEQYDVQQHEwpXaWxtaW5ndG9uMSMwIQYDVQQKExpQeXRob24gU29m
dHdhcmUgRm91bmRhdGlvbjEMMAoGA1UECxMDU1NMMR8wHQYDVQQDExZzb21lbWFj
aGluZS5weXRob24ub3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8ddrh
m+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9LopdJhTvbGfEj0DQs1IE8
M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVHfhi/VwovESJlaBOp+WMn
fhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQABoxUwEzARBglghkgBhvhC
AQEEBAMCBkAwDQYJKoZIhvcNAQEFBQADgYEAF4Q5BVqmCOLv1n8je/Jw9K669VXb
08hyGzQhkemEBYQd6fzQ9A/1ZzHkJKb1P6yreOLSEh4KcxYPyrLRC1ll8nr5OlCx
CMhKkTnR6qBsdNV0XtdU2+N25hqW+Ma4ZeqsN/iiJVCGNOZGnvQuvCAGWF8+J/f/
iHkC6gGdBJhogs4=
-----END CERTIFICATE-----
-----BEGIN RSA PRIVATE KEY-----
Bad Key, though the cert should be OK
-----END RSA PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
MIICpzCCAhCgAwIBAgIJAP+qStv1cIGNMA0GCSqGSIb3DQEBBQUAMIGJMQswCQYD
VQQGEwJVUzERMA8GA1UECBMIRGVsYXdhcmUxEzARBgNVBAcTCldpbG1pbmd0b24x
IzAhBgNVBAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMQwwCgYDVQQLEwNT
U0wxHzAdBgNVBAMTFnNvbWVtYWNoaW5lLnB5dGhvbi5vcmcwHhcNMDcwODI3MTY1
NDUwWhcNMTMwMjE2MTY1NDUwWjCBiTELMAkGA1UEBhMCVVMxETAPBgNVBAgTCERl
bGF3YXJlMRMwEQYDVQQHEwpXaWxtaW5ndG9uMSMwIQYDVQQKExpQeXRob24gU29m
dHdhcmUgRm91bmRhdGlvbjEMMAoGA1UECxMDU1NMMR8wHQYDVQQDExZzb21lbWFj
aGluZS5weXRob24ub3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8ddrh
m+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9LopdJhTvbGfEj0DQs1IE8
M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVHfhi/VwovESJlaBOp+WMn
fhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQABoxUwEzARBglghkgBhvhC
AQEEBAMCBkAwDQYJKoZIhvcNAQEFBQADgYEAF4Q5BVqmCOLv1n8je/Jw9K669VXb
08hyGzQhkemEBYQd6fzQ9A/1ZzHkJKb1P6yreOLSEh4KcxYPyrLRC1ll8nr5OlCx
CMhKkTnR6qBsdNV0XtdU2+N25hqW+Ma4ZeqsN/iiJVCGNOZGnvQuvCAGWF8+J/f/
iHkC6gGdBJhogs4=
-----END CERTIFICATE-----
------------------------------------------------------------------------
-- abs.decTest -- decimal absolute value --
-- Copyright (c) IBM Corporation, 1981, 2004. All rights reserved. --
-- Copyright (c) IBM Corporation, 1981, 2007. All rights reserved. --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases" --
-- at http://www2.hursley.ibm.com/decimal for the description of --
......@@ -17,7 +17,7 @@
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
-- mfc@uk.ibm.com --
------------------------------------------------------------------------
version: 2.39
version: 2.56
-- This set of tests primarily tests the existence of the operator.
-- Additon, subtraction, rounding, and more overflows are tested
......@@ -106,9 +106,9 @@ absx214 abs 0.01E-999 -> 1E-1001 Subnormal
absx215 abs 0.999E-999 -> 1.00E-999 Inexact Rounded Subnormal Underflow
absx216 abs 0.099E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow
absx217 abs 0.009E-999 -> 1E-1001 Inexact Rounded Subnormal Underflow
absx218 abs 0.001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow
absx219 abs 0.0009E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow
absx220 abs 0.0001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow
absx218 abs 0.001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
absx219 abs 0.0009E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
absx220 abs 0.0001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
absx230 abs -1.00E-999 -> 1.00E-999
absx231 abs -0.1E-999 -> 1E-1000 Subnormal
......@@ -119,9 +119,9 @@ absx234 abs -0.01E-999 -> 1E-1001 Subnormal
absx235 abs -0.999E-999 -> 1.00E-999 Inexact Rounded Subnormal Underflow
absx236 abs -0.099E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow
absx237 abs -0.009E-999 -> 1E-1001 Inexact Rounded Subnormal Underflow
absx238 abs -0.001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow
absx239 abs -0.0009E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow
absx240 abs -0.0001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow
absx238 abs -0.001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
absx239 abs -0.0009E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
absx240 abs -0.0001E-999 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
-- long operand tests
maxexponent: 999
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
------------------------------------------------------------------------
-- decSingle.decTest -- run all decSingle decimal arithmetic tests --
-- Copyright (c) IBM Corporation, 1981, 2007. All rights reserved. --
------------------------------------------------------------------------
-- Please see the document "General Decimal Arithmetic Testcases" --
-- at http://www2.hursley.ibm.com/decimal for the description of --
-- these testcases. --
-- --
-- These testcases are experimental ('beta' versions), and they --
-- may contain errors. They are offered on an as-is basis. In --
-- particular, achieving the same results as the tests here is not --
-- a guarantee that an implementation complies with any Standard --
-- or specification. The tests are not exhaustive. --
-- --
-- Please send comments, suggestions, and corrections to the author: --
-- Mike Cowlishaw, IBM Fellow --
-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
-- mfc@uk.ibm.com --
------------------------------------------------------------------------
version: 2.56
-- decSingle tests
dectest: dsBase
dectest: dsEncode
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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