mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	merge from trunk
This commit is contained in:
		
							parent
							
								
									2d8dcdcb06
								
							
						
					
					
						commit
						f10a79aad4
					
				
					 40 changed files with 621 additions and 305 deletions
				
			
		|  | @ -111,7 +111,7 @@ dist: | ||||||
| 
 | 
 | ||||||
| 	# archive the HTML | 	# archive the HTML | ||||||
| 	make html | 	make html | ||||||
| 	cp -a build/html dist/python$(DISTVERSION)-docs-html | 	cp -pPR build/html dist/python$(DISTVERSION)-docs-html | ||||||
| 	tar -C dist -cf dist/python$(DISTVERSION)-docs-html.tar python$(DISTVERSION)-docs-html | 	tar -C dist -cf dist/python$(DISTVERSION)-docs-html.tar python$(DISTVERSION)-docs-html | ||||||
| 	bzip2 -9 -k dist/python$(DISTVERSION)-docs-html.tar | 	bzip2 -9 -k dist/python$(DISTVERSION)-docs-html.tar | ||||||
| 	(cd dist; zip -q -r -9 python$(DISTVERSION)-docs-html.zip python$(DISTVERSION)-docs-html) | 	(cd dist; zip -q -r -9 python$(DISTVERSION)-docs-html.zip python$(DISTVERSION)-docs-html) | ||||||
|  | @ -120,7 +120,7 @@ dist: | ||||||
| 
 | 
 | ||||||
| 	# archive the text build | 	# archive the text build | ||||||
| 	make text | 	make text | ||||||
| 	cp -a build/text dist/python$(DISTVERSION)-docs-text | 	cp -pPR build/text dist/python$(DISTVERSION)-docs-text | ||||||
| 	tar -C dist -cf dist/python$(DISTVERSION)-docs-text.tar python$(DISTVERSION)-docs-text | 	tar -C dist -cf dist/python$(DISTVERSION)-docs-text.tar python$(DISTVERSION)-docs-text | ||||||
| 	bzip2 -9 -k dist/python$(DISTVERSION)-docs-text.tar | 	bzip2 -9 -k dist/python$(DISTVERSION)-docs-text.tar | ||||||
| 	(cd dist; zip -q -r -9 python$(DISTVERSION)-docs-text.zip python$(DISTVERSION)-docs-text) | 	(cd dist; zip -q -r -9 python$(DISTVERSION)-docs-text.zip python$(DISTVERSION)-docs-text) | ||||||
|  |  | ||||||
|  | @ -744,11 +744,11 @@ created. | ||||||
|    :cmacro:`Py_END_ALLOW_THREADS` macros is acceptable. |    :cmacro:`Py_END_ALLOW_THREADS` macros is acceptable. | ||||||
| 
 | 
 | ||||||
|    The return value is an opaque "handle" to the thread state when |    The return value is an opaque "handle" to the thread state when | ||||||
|    :cfunc:`PyGILState_Acquire` was called, and must be passed to |    :cfunc:`PyGILState_Ensure` was called, and must be passed to | ||||||
|    :cfunc:`PyGILState_Release` to ensure Python is left in the same state. Even |    :cfunc:`PyGILState_Release` to ensure Python is left in the same state. Even | ||||||
|    though recursive calls are allowed, these handles *cannot* be shared - each |    though recursive calls are allowed, these handles *cannot* be shared - each | ||||||
|    unique call to :cfunc:`PyGILState_Ensure` must save the handle for its call to |    unique call to :cfunc:`PyGILState_Ensure` must save the handle for its call | ||||||
|    :cfunc:`PyGILState_Release`. |    to :cfunc:`PyGILState_Release`. | ||||||
| 
 | 
 | ||||||
|    When the function returns, the current thread will hold the GIL. Failure is a |    When the function returns, the current thread will hold the GIL. Failure is a | ||||||
|    fatal error. |    fatal error. | ||||||
|  |  | ||||||
|  | @ -41,13 +41,6 @@ | ||||||
| 
 | 
 | ||||||
| # List of files that shouldn't be included in the build. | # List of files that shouldn't be included in the build. | ||||||
| unused_docs = [ | unused_docs = [ | ||||||
|     'whatsnew/2.0', |  | ||||||
|     'whatsnew/2.1', |  | ||||||
|     'whatsnew/2.2', |  | ||||||
|     'whatsnew/2.3', |  | ||||||
|     'whatsnew/2.4', |  | ||||||
|     'whatsnew/2.5', |  | ||||||
|     'whatsnew/2.6', |  | ||||||
|     'maclib/scrap', |     'maclib/scrap', | ||||||
|     'library/xmllib', |     'library/xmllib', | ||||||
|     'library/xml.etree', |     'library/xml.etree', | ||||||
|  |  | ||||||
|  | @ -4,7 +4,7 @@ | ||||||
| 
 | 
 | ||||||
| .. toctree:: | .. toctree:: | ||||||
| 
 | 
 | ||||||
|    whatsnew/3.0.rst |    whatsnew/index.rst | ||||||
|    tutorial/index.rst |    tutorial/index.rst | ||||||
|    using/index.rst |    using/index.rst | ||||||
|    reference/index.rst |    reference/index.rst | ||||||
|  |  | ||||||
|  | @ -299,7 +299,7 @@ followed by ``lines`` for the text version or ``binary`` for the binary version. | ||||||
| .. method:: FTP.quit() | .. method:: FTP.quit() | ||||||
| 
 | 
 | ||||||
|    Send a ``QUIT`` command to the server and close the connection. This is the |    Send a ``QUIT`` command to the server and close the connection. This is the | ||||||
|    "polite" way to close a connection, but it may raise an exception of the server |    "polite" way to close a connection, but it may raise an exception if the server | ||||||
|    responds with an error to the ``QUIT`` command.  This implies a call to the |    responds with an error to the ``QUIT`` command.  This implies a call to the | ||||||
|    :meth:`close` method which renders the :class:`FTP` instance useless for |    :meth:`close` method which renders the :class:`FTP` instance useless for | ||||||
|    subsequent calls (see below). |    subsequent calls (see below). | ||||||
|  |  | ||||||
|  | @ -22,9 +22,8 @@ are always available.  They are listed here in alphabetical order. | ||||||
|    The function is invoked by the :keyword:`import` statement.  It mainly exists |    The function is invoked by the :keyword:`import` statement.  It mainly exists | ||||||
|    so that you can replace it with another function that has a compatible |    so that you can replace it with another function that has a compatible | ||||||
|    interface, in order to change the semantics of the :keyword:`import` |    interface, in order to change the semantics of the :keyword:`import` | ||||||
|    statement. See also the built-in module :mod:`imp`, which |    statement.  See the built-in module :mod:`imp`, which defines some useful | ||||||
|    defines some useful operations out of which you can build your own |    operations out of which you can build your own :func:`__import__` function. | ||||||
|    :func:`__import__` function. |  | ||||||
| 
 | 
 | ||||||
|    For example, the statement ``import spam`` results in the following call: |    For example, the statement ``import spam`` results in the following call: | ||||||
|    ``__import__('spam', globals(), locals(), [], -1)``; the statement |    ``__import__('spam', globals(), locals(), [], -1)``; the statement | ||||||
|  | @ -1201,6 +1200,18 @@ are always available.  They are listed here in alphabetical order. | ||||||
|    care about trailing, unmatched values from the longer iterables.  If those |    care about trailing, unmatched values from the longer iterables.  If those | ||||||
|    values are important, use :func:`itertools.zip_longest` instead. |    values are important, use :func:`itertools.zip_longest` instead. | ||||||
| 
 | 
 | ||||||
|  |    :func:`zip` in conjunction with the ``*`` operator can be used to unzip a | ||||||
|  |    list:: | ||||||
|  | 
 | ||||||
|  |       >>> x = [1, 2, 3] | ||||||
|  |       >>> y = [4, 5, 6] | ||||||
|  |       >>> zipped = zip(x, y) | ||||||
|  |       >>> zipped | ||||||
|  |       [(1, 4), (2, 5), (3, 6)] | ||||||
|  |       >>> x2, y2 = zip(*zipped) | ||||||
|  |       >>> x == x2, y == y2 | ||||||
|  |       True | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| .. rubric:: Footnotes | .. rubric:: Footnotes | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -25,7 +25,7 @@ represents the database.  Here the data will be stored in the | ||||||
| You can also supply the special name ``:memory:`` to create a database in RAM. | You can also supply the special name ``:memory:`` to create a database in RAM. | ||||||
| 
 | 
 | ||||||
| Once you have a :class:`Connection`, you can create a :class:`Cursor`  object | Once you have a :class:`Connection`, you can create a :class:`Cursor`  object | ||||||
| and call its :meth:`execute` method to perform SQL commands:: | and call its :meth:`~Cursor.execute` method to perform SQL commands:: | ||||||
| 
 | 
 | ||||||
|    c = conn.cursor() |    c = conn.cursor() | ||||||
| 
 | 
 | ||||||
|  | @ -50,7 +50,7 @@ is insecure; it makes your program vulnerable to an SQL injection attack. | ||||||
| 
 | 
 | ||||||
| Instead, use the DB-API's parameter substitution.  Put ``?`` as a placeholder | Instead, use the DB-API's parameter substitution.  Put ``?`` as a placeholder | ||||||
| wherever you want to use a value, and then provide a tuple of values as the | wherever you want to use a value, and then provide a tuple of values as the | ||||||
| second argument to the cursor's :meth:`execute` method.  (Other database modules | second argument to the cursor's :meth:`~Cursor.execute` method.  (Other database modules | ||||||
| may use a different placeholder, such as ``%s`` or ``:1``.) For example:: | may use a different placeholder, such as ``%s`` or ``:1``.) For example:: | ||||||
| 
 | 
 | ||||||
|    # Never do this -- insecure! |    # Never do this -- insecure! | ||||||
|  | @ -69,8 +69,8 @@ may use a different placeholder, such as ``%s`` or ``:1``.) For example:: | ||||||
|        c.execute('insert into stocks values (?,?,?,?,?)', t) |        c.execute('insert into stocks values (?,?,?,?,?)', t) | ||||||
| 
 | 
 | ||||||
| To retrieve data after executing a SELECT statement, you can either treat the | To retrieve data after executing a SELECT statement, you can either treat the | ||||||
| cursor as an :term:`iterator`, call the cursor's :meth:`fetchone` method to | cursor as an :term:`iterator`, call the cursor's :meth:`~Cursor.fetchone` method to | ||||||
| retrieve a single matching row, or call :meth:`fetchall` to get a list of the | retrieve a single matching row, or call :meth:`~Cursor.fetchall` to get a list of the | ||||||
| matching rows. | matching rows. | ||||||
| 
 | 
 | ||||||
| This example uses the iterator form:: | This example uses the iterator form:: | ||||||
|  | @ -128,7 +128,7 @@ Module functions and constants | ||||||
|    returns.  It will look for a string formed [mytype] in there, and then decide |    returns.  It will look for a string formed [mytype] in there, and then decide | ||||||
|    that 'mytype' is the type of the column. It will try to find an entry of |    that 'mytype' is the type of the column. It will try to find an entry of | ||||||
|    'mytype' in the converters dictionary and then use the converter function found |    'mytype' in the converters dictionary and then use the converter function found | ||||||
|    there to return the value. The column name found in :attr:`cursor.description` |    there to return the value. The column name found in :attr:`Cursor.description` | ||||||
|    is only the first word of the column name, i.  e. if you use something like |    is only the first word of the column name, i.  e. if you use something like | ||||||
|    ``'as "x [datetime]"'`` in your SQL, then we will parse out everything until the |    ``'as "x [datetime]"'`` in your SQL, then we will parse out everything until the | ||||||
|    first blank for the column name: the column name would simply be "x". |    first blank for the column name: the column name would simply be "x". | ||||||
|  | @ -215,11 +215,13 @@ Module functions and constants | ||||||
| Connection Objects | Connection Objects | ||||||
| ------------------ | ------------------ | ||||||
| 
 | 
 | ||||||
| A :class:`Connection` instance has the following attributes and methods: | .. class:: Connection | ||||||
|  | 
 | ||||||
|  |    A SQLite database connection has the following attributes and methods: | ||||||
| 
 | 
 | ||||||
| .. attribute:: Connection.isolation_level | .. attribute:: Connection.isolation_level | ||||||
| 
 | 
 | ||||||
|    Get or set the current isolation level. None for autocommit mode or one of |    Get or set the current isolation level. :const:`None` for autocommit mode or one of | ||||||
|    "DEFERRED", "IMMEDIATE" or "EXLUSIVE". See section |    "DEFERRED", "IMMEDIATE" or "EXLUSIVE". See section | ||||||
|    :ref:`sqlite3-controlling-transactions` for a more detailed explanation. |    :ref:`sqlite3-controlling-transactions` for a more detailed explanation. | ||||||
| 
 | 
 | ||||||
|  | @ -234,7 +236,7 @@ A :class:`Connection` instance has the following attributes and methods: | ||||||
| .. method:: Connection.commit() | .. method:: Connection.commit() | ||||||
| 
 | 
 | ||||||
|    This method commits the current transaction. If you don't call this method, |    This method commits the current transaction. If you don't call this method, | ||||||
|    anything you did since the last call to commit() is not visible from from |    anything you did since the last call to ``commit()`` is not visible from from | ||||||
|    other database connections. If you wonder why you don't see the data you've |    other database connections. If you wonder why you don't see the data you've | ||||||
|    written to the database, please check you didn't forget to call this method. |    written to the database, please check you didn't forget to call this method. | ||||||
| 
 | 
 | ||||||
|  | @ -383,9 +385,9 @@ A :class:`Connection` instance has the following attributes and methods: | ||||||
| 
 | 
 | ||||||
| .. attribute:: Connection.text_factory | .. attribute:: Connection.text_factory | ||||||
| 
 | 
 | ||||||
|    Using this attribute you can control what objects are returned for the TEXT data |    Using this attribute you can control what objects are returned for the ``TEXT`` | ||||||
|    type. By default, this attribute is set to :class:`str` and the |    data type. By default, this attribute is set to :class:`str` and the | ||||||
|    :mod:`sqlite3` module will return strings for TEXT. If you want to |    :mod:`sqlite3` module will return Unicode objects for ``TEXT``. If you want to | ||||||
|    return bytestrings instead, you can set it to :class:`bytes`. |    return bytestrings instead, you can set it to :class:`bytes`. | ||||||
| 
 | 
 | ||||||
|    For efficiency reasons, there's also a way to return :class:`str` objects |    For efficiency reasons, there's also a way to return :class:`str` objects | ||||||
|  | @ -430,8 +432,9 @@ A :class:`Connection` instance has the following attributes and methods: | ||||||
| Cursor Objects | Cursor Objects | ||||||
| -------------- | -------------- | ||||||
| 
 | 
 | ||||||
| A :class:`Cursor` instance has the following attributes and methods: | .. class:: Cursor | ||||||
| 
 | 
 | ||||||
|  |    A SQLite database cursor has the following attributes and methods: | ||||||
| 
 | 
 | ||||||
| .. method:: Cursor.execute(sql, [parameters]) | .. method:: Cursor.execute(sql, [parameters]) | ||||||
| 
 | 
 | ||||||
|  | @ -470,7 +473,7 @@ A :class:`Cursor` instance has the following attributes and methods: | ||||||
| .. method:: Cursor.executescript(sql_script) | .. method:: Cursor.executescript(sql_script) | ||||||
| 
 | 
 | ||||||
|    This is a nonstandard convenience method for executing multiple SQL statements |    This is a nonstandard convenience method for executing multiple SQL statements | ||||||
|    at once. It issues a COMMIT statement first, then executes the SQL script it |    at once. It issues a ``COMMIT`` statement first, then executes the SQL script it | ||||||
|    gets as a parameter. |    gets as a parameter. | ||||||
| 
 | 
 | ||||||
|    *sql_script* can be an instance of :class:`str` or :class:`bytes`. |    *sql_script* can be an instance of :class:`str` or :class:`bytes`. | ||||||
|  | @ -483,7 +486,7 @@ A :class:`Cursor` instance has the following attributes and methods: | ||||||
| .. method:: Cursor.fetchone() | .. method:: Cursor.fetchone() | ||||||
| 
 | 
 | ||||||
|    Fetches the next row of a query result set, returning a single sequence, |    Fetches the next row of a query result set, returning a single sequence, | ||||||
|    or ``None`` when no more data is available. |    or :const:`None` when no more data is available. | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| .. method:: Cursor.fetchmany([size=cursor.arraysize]) | .. method:: Cursor.fetchmany([size=cursor.arraysize]) | ||||||
|  | @ -522,8 +525,8 @@ A :class:`Cursor` instance has the following attributes and methods: | ||||||
|    into :attr:`rowcount`. |    into :attr:`rowcount`. | ||||||
| 
 | 
 | ||||||
|    As required by the Python DB API Spec, the :attr:`rowcount` attribute "is -1 in |    As required by the Python DB API Spec, the :attr:`rowcount` attribute "is -1 in | ||||||
|    case no executeXX() has been performed on the cursor or the rowcount of the last |    case no ``executeXX()`` has been performed on the cursor or the rowcount of the | ||||||
|    operation is not determinable by the interface". |    last operation is not determinable by the interface". | ||||||
| 
 | 
 | ||||||
|    This includes ``SELECT`` statements because we cannot determine the number of |    This includes ``SELECT`` statements because we cannot determine the number of | ||||||
|    rows a query produced until all rows were fetched. |    rows a query produced until all rows were fetched. | ||||||
|  | @ -535,6 +538,81 @@ A :class:`Cursor` instance has the following attributes and methods: | ||||||
|    method. For operations other than ``INSERT`` or when :meth:`executemany` is |    method. For operations other than ``INSERT`` or when :meth:`executemany` is | ||||||
|    called, :attr:`lastrowid` is set to :const:`None`. |    called, :attr:`lastrowid` is set to :const:`None`. | ||||||
| 
 | 
 | ||||||
|  | .. attribute:: Cursor.description | ||||||
|  | 
 | ||||||
|  |    This read-only attribute provides the column names of the last query. To | ||||||
|  |    remain compatible with the Python DB API, it returns a 7-tuple for each | ||||||
|  |    column where the last six items of each tuple are :const:`None`.  | ||||||
|  |     | ||||||
|  |    It is set for ``SELECT`` statements without any matching rows as well. | ||||||
|  | 
 | ||||||
|  | .. _sqlite3-row-objects: | ||||||
|  | 
 | ||||||
|  | Row Objects | ||||||
|  | ----------- | ||||||
|  | 
 | ||||||
|  | .. class:: Row | ||||||
|  | 
 | ||||||
|  |    A :class:`Row` instance serves as a highly optimized | ||||||
|  |    :attr:`~Connection.row_factory` for :class:`Connection` objects.  | ||||||
|  |    It tries to mimic a tuple in most of its features. | ||||||
|  | 
 | ||||||
|  |    It supports mapping access by column name and index, iteration, | ||||||
|  |    representation, equality testing and :func:`len`. | ||||||
|  | 
 | ||||||
|  |    If two :class:`Row` objects have exactly the same columns and their | ||||||
|  |    members are equal, they compare equal. | ||||||
|  |     | ||||||
|  |    .. versionchanged:: 2.6 | ||||||
|  |       Added iteration and equality (hashability). | ||||||
|  | 
 | ||||||
|  |    .. method:: keys | ||||||
|  | 
 | ||||||
|  |       This method returns a tuple of column names. Immediately after a query, | ||||||
|  |       it is the first member of each tuple in :attr:`Cursor.description`. | ||||||
|  | 
 | ||||||
|  |       .. versionadded:: 2.6 | ||||||
|  | 
 | ||||||
|  | Let's assume we initialize a table as in the example given above:: | ||||||
|  | 
 | ||||||
|  |     conn = sqlite3.connect(":memory:") | ||||||
|  |     c = conn.cursor() | ||||||
|  |     c.execute('''create table stocks | ||||||
|  |     (date text, trans text, symbol text, | ||||||
|  |      qty real, price real)''') | ||||||
|  |     c.execute("""insert into stocks | ||||||
|  |               values ('2006-01-05','BUY','RHAT',100,35.14)""") | ||||||
|  |     conn.commit() | ||||||
|  |     c.close() | ||||||
|  | 
 | ||||||
|  | Now we plug :class:`Row` in:: | ||||||
|  | 
 | ||||||
|  |     >>> conn.row_factory = sqlite3.Row | ||||||
|  |     >>> c = conn.cursor() | ||||||
|  |     >>> c.execute('select * from stocks') | ||||||
|  |     <sqlite3.Cursor object at 0x7f4e7dd8fa80> | ||||||
|  |     >>> r = c.fetchone() | ||||||
|  |     >>> type(r) | ||||||
|  |     <type 'sqlite3.Row'> | ||||||
|  |     >>> r | ||||||
|  |     (u'2006-01-05', u'BUY', u'RHAT', 100.0, 35.140000000000001) | ||||||
|  |     >>> len(r) | ||||||
|  |     5 | ||||||
|  |     >>> r[2] | ||||||
|  |     u'RHAT' | ||||||
|  |     >>> r.keys() | ||||||
|  |     ['date', 'trans', 'symbol', 'qty', 'price'] | ||||||
|  |     >>> r['qty'] | ||||||
|  |     100.0 | ||||||
|  |     >>> for member in r: print member | ||||||
|  |     ... | ||||||
|  |     2006-01-05 | ||||||
|  |     BUY | ||||||
|  |     RHAT | ||||||
|  |     100.0 | ||||||
|  |     35.14 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| .. _sqlite3-types: | .. _sqlite3-types: | ||||||
| 
 | 
 | ||||||
| SQLite and Python types | SQLite and Python types | ||||||
|  | @ -544,36 +622,38 @@ SQLite and Python types | ||||||
| Introduction | Introduction | ||||||
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^ | ||||||
| 
 | 
 | ||||||
| SQLite natively supports the following types: NULL, INTEGER, REAL, TEXT, BLOB. | SQLite natively supports the following types: ``NULL``, ``INTEGER``, | ||||||
|  | ``REAL``, ``TEXT``, ``BLOB``. | ||||||
| 
 | 
 | ||||||
| The following Python types can thus be sent to SQLite without any problem: | The following Python types can thus be sent to SQLite without any problem: | ||||||
| 
 | 
 | ||||||
| +-------------------------------+-------------+ | +-------------------------------+-------------+ | ||||||
| | Python type                   | SQLite type | | | Python type                   | SQLite type | | ||||||
| +===============================+=============+ | +===============================+=============+ | ||||||
| | ``None``                      | NULL        | | | :const:`None`                 | ``NULL``    | | ||||||
| +-------------------------------+-------------+ | +-------------------------------+-------------+ | ||||||
| | :class:`int`                  | INTEGER     | | | :class:`int`                  | ``INTEGER`` | | ||||||
| +-------------------------------+-------------+ | +-------------------------------+-------------+ | ||||||
| | :class:`float`                | REAL        | | | :class:`float`                | ``REAL``    | | ||||||
| +-------------------------------+-------------+ | +-------------------------------+-------------+ | ||||||
| | :class:`bytes` (UTF8-encoded) | TEXT        | | | :class:`bytes` (UTF8-encoded) | ``TEXT``    | | ||||||
| +-------------------------------+-------------+ | +-------------------------------+-------------+ | ||||||
| | :class:`str`                  | TEXT        | | | :class:`str`                  | ``TEXT``    | | ||||||
| +-------------------------------+-------------+ | +-------------------------------+-------------+ | ||||||
| | :class:`buffer`               | BLOB        | | | :class:`buffer`               | ``BLOB``    | | ||||||
| +-------------------------------+-------------+ | +-------------------------------+-------------+ | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| This is how SQLite types are converted to Python types by default: | This is how SQLite types are converted to Python types by default: | ||||||
| 
 | 
 | ||||||
| +-------------+---------------------------------------------+ | +-------------+---------------------------------------------+ | ||||||
| | SQLite type | Python type                                 | | | SQLite type | Python type                                 | | ||||||
| +=============+=============================================+ | +=============+=============================================+ | ||||||
| | ``NULL``    | None                                        | | | ``NULL``    | :const:`None`                               | | ||||||
| +-------------+---------------------------------------------+ | +-------------+---------------------------------------------+ | ||||||
| | ``INTEGER`` | int                                         | | | ``INTEGER`` | :class`int`                                 | | ||||||
| +-------------+---------------------------------------------+ | +-------------+---------------------------------------------+ | ||||||
| | ``REAL``    | float                                       | | | ``REAL``    | :class:`float`                              | | ||||||
| +-------------+---------------------------------------------+ | +-------------+---------------------------------------------+ | ||||||
| | ``TEXT``    | depends on text_factory, str by default     | | | ``TEXT``    | depends on text_factory, str by default     | | ||||||
| +-------------+---------------------------------------------+ | +-------------+---------------------------------------------+ | ||||||
|  | @ -701,9 +781,10 @@ Controlling Transactions | ||||||
| ------------------------ | ------------------------ | ||||||
| 
 | 
 | ||||||
| By default, the :mod:`sqlite3` module opens transactions implicitly before a | By default, the :mod:`sqlite3` module opens transactions implicitly before a | ||||||
| Data Modification Language (DML)  statement (i.e. INSERT/UPDATE/DELETE/REPLACE), | Data Modification Language (DML)  statement (i.e.  | ||||||
| and commits transactions implicitly before a non-DML, non-query statement (i. e. | ``INSERT``/``UPDATE``/``DELETE``/``REPLACE``), and commits transactions | ||||||
| anything other than SELECT/INSERT/UPDATE/DELETE/REPLACE). | implicitly before a non-DML, non-query statement (i. e. | ||||||
|  | anything other than ``SELECT`` or the aforementioned). | ||||||
| 
 | 
 | ||||||
| So if you are within a transaction and issue a command like ``CREATE TABLE | So if you are within a transaction and issue a command like ``CREATE TABLE | ||||||
| ...``, ``VACUUM``, ``PRAGMA``, the :mod:`sqlite3` module will commit implicitly | ...``, ``VACUUM``, ``PRAGMA``, the :mod:`sqlite3` module will commit implicitly | ||||||
|  | @ -712,7 +793,7 @@ is that some of these commands don't work within transactions. The other reason | ||||||
| is that pysqlite needs to keep track of the transaction state (if a transaction | is that pysqlite needs to keep track of the transaction state (if a transaction | ||||||
| is active or not). | is active or not). | ||||||
| 
 | 
 | ||||||
| You can control which kind of "BEGIN" statements pysqlite implicitly executes | You can control which kind of ``BEGIN`` statements pysqlite implicitly executes | ||||||
| (or none at all) via the *isolation_level* parameter to the :func:`connect` | (or none at all) via the *isolation_level* parameter to the :func:`connect` | ||||||
| call, or via the :attr:`isolation_level` property of connections. | call, or via the :attr:`isolation_level` property of connections. | ||||||
| 
 | 
 | ||||||
|  | @ -736,7 +817,7 @@ Using the nonstandard :meth:`execute`, :meth:`executemany` and | ||||||
| be written more concisely because you don't have to create the (often | be written more concisely because you don't have to create the (often | ||||||
| superfluous) :class:`Cursor` objects explicitly. Instead, the :class:`Cursor` | superfluous) :class:`Cursor` objects explicitly. Instead, the :class:`Cursor` | ||||||
| objects are created implicitly and these shortcut methods return the cursor | objects are created implicitly and these shortcut methods return the cursor | ||||||
| objects. This way, you can execute a SELECT statement and iterate over it | objects. This way, you can execute a ``SELECT`` statement and iterate over it | ||||||
| directly using only a single call on the :class:`Connection` object. | directly using only a single call on the :class:`Connection` object. | ||||||
| 
 | 
 | ||||||
| .. literalinclude:: ../includes/sqlite3/shortcut_methods.py | .. literalinclude:: ../includes/sqlite3/shortcut_methods.py | ||||||
|  |  | ||||||
|  | @ -335,7 +335,7 @@ Replacing /bin/sh shell backquote | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| Replacing shell pipeline | Replacing shell pipeline | ||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^ | ||||||
| 
 | 
 | ||||||
| :: | :: | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -775,9 +775,9 @@ can appear before a future statement are: | ||||||
| .. XXX change this if future is cleaned out | .. XXX change this if future is cleaned out | ||||||
| 
 | 
 | ||||||
| The features recognized by Python 3.0 are ``absolute_import``, ``division``, | The features recognized by Python 3.0 are ``absolute_import``, ``division``, | ||||||
| ``generators``, ``nested_scopes`` and ``with_statement``.  They are all | ``generators``, ``unicode_literals``, ``print_function``, ``nested_scopes`` and | ||||||
| redundant because they are always enabled, and only kept for backwards | ``with_statement``.  They are all redundant because they are always enabled, and | ||||||
| compatibility. | only kept for backwards compatibility. | ||||||
| 
 | 
 | ||||||
| A future statement is recognized and treated specially at compile time: Changes | A future statement is recognized and treated specially at compile time: Changes | ||||||
| to the semantics of core constructs are often implemented by generating | to the semantics of core constructs are often implemented by generating | ||||||
|  |  | ||||||
|  | @ -31,8 +31,8 @@ <h1>Download Python {{ release }} Documentation</h1> | ||||||
|     <td><a href="{{ dlbase }}/python-docs-html.tar.bz2">Download</a> (ca. 4 MB)</td> |     <td><a href="{{ dlbase }}/python-docs-html.tar.bz2">Download</a> (ca. 4 MB)</td> | ||||||
|   </tr> |   </tr> | ||||||
|   <tr><td>Plain Text</td> |   <tr><td>Plain Text</td> | ||||||
|     <td><a href="{{ dlbase }}/python-docs-pdf-text.zip">Download</a> (ca. 2 MB)</td> |     <td><a href="{{ dlbase }}/python-docs-text.zip">Download</a> (ca. 2 MB)</td> | ||||||
|     <td><a href="{{ dlbase }}/python-docs-pdf-text.tar.bz2">Download</a> (ca. 1.5 MB)</td> |     <td><a href="{{ dlbase }}/python-docs-text.tar.bz2">Download</a> (ca. 1.5 MB)</td> | ||||||
|   </tr> |   </tr> | ||||||
| </table> | </table> | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -4,7 +4,7 @@ | ||||||
|   <table class="contentstable" align="center"><tr> |   <table class="contentstable" align="center"><tr> | ||||||
|     <td width="50%"> |     <td width="50%"> | ||||||
|       <p class="biglink"><a class="biglink" href="{{ pathto("whatsnew/" + version) }}">What's new in Python {{ version }}?</a><br/> |       <p class="biglink"><a class="biglink" href="{{ pathto("whatsnew/" + version) }}">What's new in Python {{ version }}?</a><br/> | ||||||
|          <span class="linkdescr">changes since previous major release</span></p> |          <span class="linkdescr">or <a href="{{ pathto("whatsnew/index") }}">all "What's new" documents</a> since 2.0</span></span></p> | ||||||
|       <p class="biglink"><a class="biglink" href="{{ pathto("tutorial/index") }}">Tutorial</a><br/> |       <p class="biglink"><a class="biglink" href="{{ pathto("tutorial/index") }}">Tutorial</a><br/> | ||||||
|          <span class="linkdescr">start here</span></p> |          <span class="linkdescr">start here</span></p> | ||||||
|       <p class="biglink"><a class="biglink" href="{{ pathto("using/index") }}">Using Python</a><br/> |       <p class="biglink"><a class="biglink" href="{{ pathto("using/index") }}">Using Python</a><br/> | ||||||
|  |  | ||||||
|  | @ -1,5 +1,4 @@ | ||||||
| {% extends "!layout.html" %} | {% extends "!layout.html" %} | ||||||
| {% block rootrellink %} | {% block rootrellink %} | ||||||
| <li><img src="{{ pathto('_static/py.png', 1) }}" alt="" style="vertical-align: middle; margin-top: -1px"/></li> | <li><img src="{{ pathto('_static/py.png', 1) }}" alt="" style="vertical-align: middle; margin-top: -1px"/></li><li><a href="{{ pathto('index') }}">{{ shorttitle }}</a>{{ reldelim1 }}</li> | ||||||
| {{ super() }} |  | ||||||
| {% endblock %} | {% endblock %} | ||||||
|  |  | ||||||
|  | @ -714,7 +714,7 @@ Python's division operator, ``/``, behaves like C's division operator when | ||||||
| presented with two integer arguments: it returns an integer result that's | presented with two integer arguments: it returns an integer result that's | ||||||
| truncated down when there would be a fractional part.  For example, ``3/2`` is | truncated down when there would be a fractional part.  For example, ``3/2`` is | ||||||
| 1, not 1.5, and ``(-1)/2`` is -1, not -0.5.  This means that the results of | 1, not 1.5, and ``(-1)/2`` is -1, not -0.5.  This means that the results of | ||||||
| divison can vary unexpectedly depending on the type of the two operands and | division can vary unexpectedly depending on the type of the two operands and | ||||||
| because Python is dynamically typed, it can be difficult to determine the | because Python is dynamically typed, it can be difficult to determine the | ||||||
| possible types of the operands. | possible types of the operands. | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1196,7 +1196,7 @@ Optimizations | ||||||
| 
 | 
 | ||||||
| * The ``SET_LINENO`` opcode is now gone.  This may provide a small speed | * The ``SET_LINENO`` opcode is now gone.  This may provide a small speed | ||||||
|   increase, depending on your compiler's idiosyncrasies. See section |   increase, depending on your compiler's idiosyncrasies. See section | ||||||
|   :ref:`section-other` for a longer explanation. (Removed by Michael Hudson.) |   :ref:`23section-other` for a longer explanation. (Removed by Michael Hudson.) | ||||||
| 
 | 
 | ||||||
| * :func:`xrange` objects now have their own iterator, making ``for i in | * :func:`xrange` objects now have their own iterator, making ``for i in | ||||||
|   xrange(n)`` slightly faster than ``for i in range(n)``.  (Patch by Raymond |   xrange(n)`` slightly faster than ``for i in range(n)``.  (Patch by Raymond | ||||||
|  | @ -1951,7 +1951,7 @@ Other new platforms now supported by Python include AtheOS | ||||||
| .. ====================================================================== | .. ====================================================================== | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| .. _section-other: | .. _23section-other: | ||||||
| 
 | 
 | ||||||
| Other Changes and Fixes | Other Changes and Fixes | ||||||
| ======================= | ======================= | ||||||
|  | @ -2062,7 +2062,7 @@ code: | ||||||
| .. ====================================================================== | .. ====================================================================== | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| .. _acks: | .. _23acks: | ||||||
| 
 | 
 | ||||||
| Acknowledgements | Acknowledgements | ||||||
| ================ | ================ | ||||||
|  |  | ||||||
|  | @ -1551,7 +1551,7 @@ code: | ||||||
| .. ====================================================================== | .. ====================================================================== | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| .. _acks: | .. _24acks: | ||||||
| 
 | 
 | ||||||
| Acknowledgements | Acknowledgements | ||||||
| ================ | ================ | ||||||
|  |  | ||||||
|  | @ -16,9 +16,9 @@ release schedule. | ||||||
| The changes in Python 2.5 are an interesting mix of language and library | The changes in Python 2.5 are an interesting mix of language and library | ||||||
| improvements. The library enhancements will be more important to Python's user | improvements. The library enhancements will be more important to Python's user | ||||||
| community, I think, because several widely-useful packages were added.  New | community, I think, because several widely-useful packages were added.  New | ||||||
| modules include ElementTree for XML processing (section :ref:`module-etree`), | modules include ElementTree for XML processing (:mod:`xml.etree`), | ||||||
| the SQLite database module (section :ref:`module-sqlite`), and the :mod:`ctypes` | the SQLite database module (:mod:`sqlite`), and the :mod:`ctypes` | ||||||
| module for calling C functions (section :ref:`module-ctypes`). | module for calling C functions. | ||||||
| 
 | 
 | ||||||
| The language changes are of middling significance.  Some pleasant new features | The language changes are of middling significance.  Some pleasant new features | ||||||
| were added, but most of them aren't features that you'll use every day. | were added, but most of them aren't features that you'll use every day. | ||||||
|  | @ -736,7 +736,7 @@ add a :keyword:`return` statement at the marked location. :: | ||||||
|                # return False |                # return False | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| .. _module-contextlib: | .. _contextlibmod: | ||||||
| 
 | 
 | ||||||
| The contextlib module | The contextlib module | ||||||
| --------------------- | --------------------- | ||||||
|  | @ -1109,7 +1109,7 @@ Here are all of the changes that Python 2.5 makes to the core Python language. | ||||||
| .. ====================================================================== | .. ====================================================================== | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| .. _interactive: | .. _25interactive: | ||||||
| 
 | 
 | ||||||
| Interactive Interpreter Changes | Interactive Interpreter Changes | ||||||
| ------------------------------- | ------------------------------- | ||||||
|  | @ -1211,7 +1211,7 @@ marked in the following list. | ||||||
| .. ====================================================================== | .. ====================================================================== | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| .. _modules: | .. _25modules: | ||||||
| 
 | 
 | ||||||
| New, Improved, and Removed Modules | New, Improved, and Removed Modules | ||||||
| ================================== | ================================== | ||||||
|  | @ -1273,7 +1273,7 @@ complete list of changes, or look through the SVN logs for all the details. | ||||||
|   (Contributed by Raymond Hettinger.) |   (Contributed by Raymond Hettinger.) | ||||||
| 
 | 
 | ||||||
| * New module: The :mod:`contextlib` module contains helper functions for use | * New module: The :mod:`contextlib` module contains helper functions for use | ||||||
|   with the new ':keyword:`with`' statement.  See section :ref:`module-contextlib` |   with the new ':keyword:`with`' statement.  See section :ref:`contextlibmod` | ||||||
|   for more about this module. |   for more about this module. | ||||||
| 
 | 
 | ||||||
| * New module: The :mod:`cProfile` module is a C implementation of  the existing | * New module: The :mod:`cProfile` module is a C implementation of  the existing | ||||||
|  | @ -2272,8 +2272,6 @@ code: | ||||||
| .. ====================================================================== | .. ====================================================================== | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| .. _acks: |  | ||||||
| 
 |  | ||||||
| Acknowledgements | Acknowledgements | ||||||
| ================ | ================ | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -8,7 +8,7 @@ | ||||||
| :Release: |release| | :Release: |release| | ||||||
| :Date: |today| | :Date: |today| | ||||||
| 
 | 
 | ||||||
| .. $Id: whatsnew26.tex 55746 2007-06-02 18:33:53Z neal.norwitz $ | .. $Id$ | ||||||
|    Rules for maintenance: |    Rules for maintenance: | ||||||
| 
 | 
 | ||||||
|    * Anyone can add text to this document.  Do not spend very much time |    * Anyone can add text to this document.  Do not spend very much time | ||||||
|  | @ -49,9 +49,8 @@ | ||||||
|    This saves the maintainer some effort going through the SVN logs |    This saves the maintainer some effort going through the SVN logs | ||||||
|    when researching a change. |    when researching a change. | ||||||
| 
 | 
 | ||||||
| This article explains the new features in Python 2.6.  The release | This article explains the new features in Python 2.6, released on October 1 | ||||||
| schedule is described in :pep:`361`; currently the final release is | 2008.  The release schedule is described in :pep:`361`. | ||||||
| scheduled for October 1 2008. |  | ||||||
| 
 | 
 | ||||||
| The major theme of Python 2.6 is preparing the migration path to | The major theme of Python 2.6 is preparing the migration path to | ||||||
| Python 3.0, a major redesign of the language.  Whenever possible, | Python 3.0, a major redesign of the language.  Whenever possible, | ||||||
|  | @ -724,31 +723,32 @@ In 2.6, both 8-bit and Unicode strings have a `.format()` method that | ||||||
| treats the string as a template and takes the arguments to be formatted. | treats the string as a template and takes the arguments to be formatted. | ||||||
| The formatting template uses curly brackets (`{`, `}`) as special characters:: | The formatting template uses curly brackets (`{`, `}`) as special characters:: | ||||||
| 
 | 
 | ||||||
|      # Substitute positional argument 0 into the string. |      >>> # Substitute positional argument 0 into the string. | ||||||
|      "User ID: {0}".format("root") -> "User ID: root" |      >>> "User ID: {0}".format("root") | ||||||
| 
 |      'User ID: root' | ||||||
|      # Use the named keyword arguments |      >>> # Use the named keyword arguments | ||||||
|      'User ID: {uid}   Last seen: {last_login}'.format( |      >>> "User ID: {uid}   Last seen: {last_login}".format( | ||||||
|             uid='root', |      ...    uid="root", | ||||||
|             last_login = '5 Mar 2008 07:20') -> |      ...    last_login = "5 Mar 2008 07:20") | ||||||
|      'User ID: root   Last seen: 5 Mar 2008 07:20' |      'User ID: root   Last seen: 5 Mar 2008 07:20' | ||||||
| 
 | 
 | ||||||
| Curly brackets can be escaped by doubling them:: | Curly brackets can be escaped by doubling them:: | ||||||
| 
 | 
 | ||||||
|      format("Empty dict: {{}}") -> "Empty dict: {}" |      >>> format("Empty dict: {{}}") | ||||||
|  |      "Empty dict: {}" | ||||||
| 
 | 
 | ||||||
| Field names can be integers indicating positional arguments, such as | Field names can be integers indicating positional arguments, such as | ||||||
| ``{0}``, ``{1}``, etc. or names of keyword arguments.  You can also | ``{0}``, ``{1}``, etc. or names of keyword arguments.  You can also | ||||||
| supply compound field names that read attributes or access dictionary keys:: | supply compound field names that read attributes or access dictionary keys:: | ||||||
| 
 | 
 | ||||||
|     import sys |     >>> import sys | ||||||
|     'Platform: {0.platform}\nPython version: {0.version}'.format(sys) -> |     >>> print 'Platform: {0.platform}\nPython version: {0.version}'.format(sys) | ||||||
|         'Platform: darwin\n |     Platform: darwin | ||||||
|          Python version: 2.6a1+ (trunk:61261M, Mar  5 2008, 20:29:41) \n |     Python version: 2.6a1+ (trunk:61261M, Mar  5 2008, 20:29:41)  | ||||||
|     [GCC 4.0.1 (Apple Computer, Inc. build 5367)]' |     [GCC 4.0.1 (Apple Computer, Inc. build 5367)]' | ||||||
| 
 | 
 | ||||||
|     import mimetypes |     >>> import mimetypes | ||||||
|     'Content-type: {0[.mp4]}'.format(mimetypes.types_map) -> |     >>> 'Content-type: {0[.mp4]}'.format(mimetypes.types_map) | ||||||
|     'Content-type: video/mp4' |     'Content-type: video/mp4' | ||||||
| 
 | 
 | ||||||
| Note that when using dictionary-style notation such as ``[.mp4]``, you | Note that when using dictionary-style notation such as ``[.mp4]``, you | ||||||
|  | @ -761,29 +761,24 @@ So far we've shown how to specify which field to substitute into the | ||||||
| resulting string.  The precise formatting used is also controllable by | resulting string.  The precise formatting used is also controllable by | ||||||
| adding a colon followed by a format specifier.  For example:: | adding a colon followed by a format specifier.  For example:: | ||||||
| 
 | 
 | ||||||
|      # Field 0: left justify, pad to 15 characters |      >>> # Field 0: left justify, pad to 15 characters | ||||||
|      # Field 1: right justify, pad to 6 characters |      >>> # Field 1: right justify, pad to 6 characters | ||||||
|      fmt = '{0:15} ${1:>6}' |      >>> fmt = '{0:15} ${1:>6}' | ||||||
| 
 |      >>> fmt.format('Registration', 35) | ||||||
|      fmt.format('Registration', 35) -> |  | ||||||
|      'Registration    $    35' |      'Registration    $    35' | ||||||
| 
 |      >>> fmt.format('Tutorial', 50) | ||||||
|      fmt.format('Tutorial', 50) -> |  | ||||||
|      'Tutorial        $    50' |      'Tutorial        $    50' | ||||||
| 
 |      >>> fmt.format('Banquet', 125) | ||||||
|      fmt.format('Banquet', 125) -> |  | ||||||
|      'Banquet         $   125' |      'Banquet         $   125' | ||||||
| 
 | 
 | ||||||
| Format specifiers can reference other fields through nesting:: | Format specifiers can reference other fields through nesting:: | ||||||
| 
 | 
 | ||||||
|     fmt = '{0:{1}}' |     >>> fmt = '{0:{1}}' | ||||||
| 
 |     >>> width = 15 | ||||||
|     width = 15 |     >>> fmt.format('Invoice #1234', width) | ||||||
|     fmt.format('Invoice #1234', width) -> |  | ||||||
|     'Invoice #1234  ' |     'Invoice #1234  ' | ||||||
| 
 |     >>> width = 35 | ||||||
|     width = 35 |     >>> fmt.format('Invoice #1234', width) | ||||||
|     fmt.format('Invoice #1234', width) -> |  | ||||||
|     'Invoice #1234                      ' |     'Invoice #1234                      ' | ||||||
| 
 | 
 | ||||||
| The alignment of a field within the desired width can be specified: | The alignment of a field within the desired width can be specified: | ||||||
|  | @ -799,7 +794,7 @@ Character        Effect | ||||||
| 
 | 
 | ||||||
| Format specifiers can also include a presentation type, which | Format specifiers can also include a presentation type, which | ||||||
| controls how the value is formatted.  For example, floating-point numbers | controls how the value is formatted.  For example, floating-point numbers | ||||||
| can be formatted as a general number or in exponential notation: | can be formatted as a general number or in exponential notation:: | ||||||
| 
 | 
 | ||||||
|     >>> '{0:g}'.format(3.75) |     >>> '{0:g}'.format(3.75) | ||||||
|     '3.75' |     '3.75' | ||||||
|  | @ -807,25 +802,27 @@ can be formatted as a general number or in exponential notation: | ||||||
|     '3.750000e+00' |     '3.750000e+00' | ||||||
| 
 | 
 | ||||||
| A variety of presentation types are available.  Consult the 2.6 | A variety of presentation types are available.  Consult the 2.6 | ||||||
| documentation for a :ref:`complete list <formatstrings>`; here's a sample:: | documentation for a :ref:`complete list <formatstrings>`; here's a sample: | ||||||
| 
 | 
 | ||||||
|         'b' - Binary. Outputs the number in base 2. | ===== ======================================================================== | ||||||
|         'c' - Character. Converts the integer to the corresponding | ``b`` Binary. Outputs the number in base 2. | ||||||
|               Unicode character before printing. | ``c`` Character. Converts the integer to the corresponding Unicode character | ||||||
|         'd' - Decimal Integer. Outputs the number in base 10. |       before printing. | ||||||
|         'o' - Octal format. Outputs the number in base 8. | ``d`` Decimal Integer. Outputs the number in base 10. | ||||||
|         'x' - Hex format. Outputs the number in base 16, using lower- | ``o`` Octal format. Outputs the number in base 8. | ||||||
|               case letters for the digits above 9. | ``x`` Hex format. Outputs the number in base 16, using lower-case letters for | ||||||
|         'e' - Exponent notation. Prints the number in scientific |       the digits above 9. | ||||||
|               notation using the letter 'e' to indicate the exponent. | ``e`` Exponent notation. Prints the number in scientific notation using the | ||||||
|         'g' - General format. This prints the number as a fixed-point |       letter 'e' to indicate the exponent. | ||||||
|               number, unless the number is too large, in which case | ``g`` General format. This prints the number as a fixed-point number, unless | ||||||
|               it switches to 'e' exponent notation. |       the number is too large, in which case it switches to 'e' exponent | ||||||
|         'n' - Number. This is the same as 'g' (for floats) or 'd' (for |       notation. | ||||||
|               integers), except that it uses the current locale setting to | ``n`` Number. This is the same as 'g' (for floats) or 'd' (for integers), | ||||||
|               insert the appropriate number separator characters. |       except that it uses the current locale setting to insert the appropriate | ||||||
|         '%' - Percentage. Multiplies the number by 100 and displays |       number separator characters. | ||||||
|               in fixed ('f') format, followed by a percent sign. | ``%`` Percentage. Multiplies the number by 100 and displays in fixed ('f') | ||||||
|  |       format, followed by a percent sign. | ||||||
|  | ===== ======================================================================== | ||||||
| 
 | 
 | ||||||
| Classes and types can define a :meth:`__format__` method to control how they're | Classes and types can define a :meth:`__format__` method to control how they're | ||||||
| formatted.  It receives a single argument, the format specifier:: | formatted.  It receives a single argument, the format specifier:: | ||||||
|  | @ -866,13 +863,14 @@ by doing ``def print(...)`` or importing a new function from somewhere else. | ||||||
| Python 2.6 has a ``__future__`` import that removes ``print`` as language | Python 2.6 has a ``__future__`` import that removes ``print`` as language | ||||||
| syntax, letting you use the functional form instead.  For example:: | syntax, letting you use the functional form instead.  For example:: | ||||||
| 
 | 
 | ||||||
|     from __future__ import print_function |     >>> from __future__ import print_function | ||||||
|     print('# of entries', len(dictionary), file=sys.stderr) |     >>> print('# of entries', len(dictionary), file=sys.stderr) | ||||||
| 
 | 
 | ||||||
| The signature of the new function is:: | The signature of the new function is:: | ||||||
| 
 | 
 | ||||||
|     def print(*args, sep=' ', end='\n', file=None) |     def print(*args, sep=' ', end='\n', file=None) | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| The parameters are: | The parameters are: | ||||||
| 
 | 
 | ||||||
|  * *args*: positional arguments whose values will be printed out. |  * *args*: positional arguments whose values will be printed out. | ||||||
|  | @ -950,6 +948,20 @@ or using a :class:`bytes` constructor.  For future compatibility, | ||||||
| Python 2.6 adds :class:`bytes` as a synonym for the :class:`str` type, | Python 2.6 adds :class:`bytes` as a synonym for the :class:`str` type, | ||||||
| and it also supports the ``b''`` notation. | and it also supports the ``b''`` notation. | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | The 2.6 :class:`str` differs from 3.0's :class:`bytes` type in various | ||||||
|  | ways; most notably, the constructor is completely different.  In 3.0, | ||||||
|  | ``bytes([65, 66, 67])`` is 3 elements long, containing the bytes | ||||||
|  | representing ``ABC``; in 2.6, ``bytes([65, 66, 67])`` returns the | ||||||
|  | 12-byte string representing the :func:`str` of the list. | ||||||
|  | 
 | ||||||
|  | The primary use of :class:`bytes` in 2.6 will be to write tests of | ||||||
|  | object type such as ``isinstance(x, bytes)``.  This will help the 2to3 | ||||||
|  | converter, which can't tell whether 2.x code intends strings to | ||||||
|  | contain either characters or 8-bit bytes; you can now  | ||||||
|  | use either :class:`bytes` or :class:`str` to represent your intention  | ||||||
|  | exactly, and the resulting code will also be correct in Python 3.0. | ||||||
|  | 
 | ||||||
| There's also a ``__future__`` import that causes all string literals | There's also a ``__future__`` import that causes all string literals | ||||||
| to become Unicode strings.  This means that ``\u`` escape sequences | to become Unicode strings.  This means that ``\u`` escape sequences | ||||||
| can be used to include Unicode characters:: | can be used to include Unicode characters:: | ||||||
|  | @ -989,6 +1001,8 @@ Byte arrays support most of the methods of string types, such as | ||||||
| and some of the methods of lists, such as :meth:`append`, | and some of the methods of lists, such as :meth:`append`, | ||||||
| :meth:`pop`,  and :meth:`reverse`. | :meth:`pop`,  and :meth:`reverse`. | ||||||
| 
 | 
 | ||||||
|  | :: | ||||||
|  | 
 | ||||||
|     >>> b = bytearray('ABC') |     >>> b = bytearray('ABC') | ||||||
|     >>> b.append('d') |     >>> b.append('d') | ||||||
|     >>> b.append(ord('e')) |     >>> b.append(ord('e')) | ||||||
|  | @ -1318,7 +1332,7 @@ built-in returns the binary representation for a number:: | ||||||
| The :func:`int` and :func:`long` built-ins will now accept the "0o" | The :func:`int` and :func:`long` built-ins will now accept the "0o" | ||||||
| and "0b" prefixes when base-8 or base-2 are requested, or when the | and "0b" prefixes when base-8 or base-2 are requested, or when the | ||||||
| *base* argument is zero (signalling that the base used should be | *base* argument is zero (signalling that the base used should be | ||||||
| determined from the string): | determined from the string):: | ||||||
| 
 | 
 | ||||||
|     >>> int ('0o52', 0) |     >>> int ('0o52', 0) | ||||||
|     42 |     42 | ||||||
|  | @ -1491,7 +1505,7 @@ Some smaller changes made to the core Python language are: | ||||||
|   (Contributed by Alexander Belopolsky; :issue:`1686487`.) |   (Contributed by Alexander Belopolsky; :issue:`1686487`.) | ||||||
| 
 | 
 | ||||||
|   It's also become legal to provide keyword arguments after a ``*args`` argument |   It's also become legal to provide keyword arguments after a ``*args`` argument | ||||||
|   to a function call. |   to a function call. :: | ||||||
| 
 | 
 | ||||||
|     >>> def f(*args, **kw): |     >>> def f(*args, **kw): | ||||||
|     ...     print args, kw |     ...     print args, kw | ||||||
|  | @ -1865,8 +1879,8 @@ changes, or look through the Subversion logs for all the details. | ||||||
| 
 | 
 | ||||||
|      >>> var_type = collections.namedtuple('variable', |      >>> var_type = collections.namedtuple('variable', | ||||||
|      ...             'id name type size') |      ...             'id name type size') | ||||||
|      # Names are separated by spaces or commas. |      >>> # Names are separated by spaces or commas. | ||||||
|      # 'id, name, type, size' would also work. |      >>> # 'id, name, type, size' would also work. | ||||||
|      >>> var_type._fields |      >>> var_type._fields | ||||||
|      ('id', 'name', 'type', 'size') |      ('id', 'name', 'type', 'size') | ||||||
| 
 | 
 | ||||||
|  | @ -1916,7 +1930,9 @@ changes, or look through the Subversion logs for all the details. | ||||||
| 
 | 
 | ||||||
| * A new window method in the :mod:`curses` module, | * A new window method in the :mod:`curses` module, | ||||||
|   :meth:`chgat`, changes the display attributes for a certain number of |   :meth:`chgat`, changes the display attributes for a certain number of | ||||||
|   characters on a single line.  (Contributed by Fabian Kreutz.)  :: |   characters on a single line.  (Contributed by Fabian Kreutz.) | ||||||
|  |    | ||||||
|  |   :: | ||||||
| 
 | 
 | ||||||
|      # Boldface text starting at y=0,x=21 |      # Boldface text starting at y=0,x=21 | ||||||
|      # and affecting the rest of the line. |      # and affecting the rest of the line. | ||||||
|  | @ -1986,7 +2002,7 @@ changes, or look through the Subversion logs for all the details. | ||||||
|   order, and returns a new generator that returns the contents of all |   order, and returns a new generator that returns the contents of all | ||||||
|   the iterators, also in sorted order.  For example:: |   the iterators, also in sorted order.  For example:: | ||||||
| 
 | 
 | ||||||
|      heapq.merge([1, 3, 5, 9], [2, 8, 16]) -> |       >>> list(heapq.merge([1, 3, 5, 9], [2, 8, 16])) | ||||||
|       [1, 2, 3, 5, 8, 9, 16] |       [1, 2, 3, 5, 8, 9, 16] | ||||||
| 
 | 
 | ||||||
|   Another new function, ``heappushpop(heap, item)``, |   Another new function, ``heappushpop(heap, item)``, | ||||||
|  | @ -2021,57 +2037,55 @@ changes, or look through the Subversion logs for all the details. | ||||||
|   each of the elements; if some of the iterables are shorter than |   each of the elements; if some of the iterables are shorter than | ||||||
|   others, the missing values are set to *fillvalue*.  For example:: |   others, the missing values are set to *fillvalue*.  For example:: | ||||||
| 
 | 
 | ||||||
|      itertools.izip_longest([1,2,3], [1,2,3,4,5]) -> |      >>> tuple(itertools.izip_longest([1,2,3], [1,2,3,4,5])) | ||||||
|        (1, 1), (2, 2), (3, 3), (None, 4), (None, 5) |      ((1, 1), (2, 2), (3, 3), (None, 4), (None, 5)) | ||||||
| 
 | 
 | ||||||
|   ``product(iter1, iter2, ..., [repeat=N])`` returns the Cartesian product |   ``product(iter1, iter2, ..., [repeat=N])`` returns the Cartesian product | ||||||
|   of the supplied iterables, a set of tuples containing |   of the supplied iterables, a set of tuples containing | ||||||
|   every possible combination of the elements returned from each iterable. :: |   every possible combination of the elements returned from each iterable. :: | ||||||
| 
 | 
 | ||||||
|      itertools.product([1,2,3], [4,5,6]) -> |      >>> list(itertools.product([1,2,3], [4,5,6])) | ||||||
|         (1, 4), (1, 5), (1, 6), |      [(1, 4), (1, 5), (1, 6), | ||||||
| 	  (2, 4), (2, 5), (2, 6), | 	  (2, 4), (2, 5), (2, 6), | ||||||
| 	(3, 4), (3, 5), (3, 6) | 	  (3, 4), (3, 5), (3, 6)] | ||||||
| 
 | 
 | ||||||
|   The optional *repeat* keyword argument is used for taking the |   The optional *repeat* keyword argument is used for taking the | ||||||
|   product of an iterable or a set of iterables with themselves, |   product of an iterable or a set of iterables with themselves, | ||||||
|   repeated *N* times.  With a single iterable argument, *N*-tuples |   repeated *N* times.  With a single iterable argument, *N*-tuples | ||||||
|   are returned:: |   are returned:: | ||||||
| 
 | 
 | ||||||
|      itertools.product([1,2], repeat=3) -> |      >>> list(itertools.product([1,2], repeat=3)) | ||||||
|         (1, 1, 1), (1, 1, 2), (1, 2, 1), (1, 2, 2), |      [(1, 1, 1), (1, 1, 2), (1, 2, 1), (1, 2, 2), | ||||||
|         (2, 1, 1), (2, 1, 2), (2, 2, 1), (2, 2, 2) |       (2, 1, 1), (2, 1, 2), (2, 2, 1), (2, 2, 2)] | ||||||
| 
 | 
 | ||||||
|   With two iterables, *2N*-tuples are returned. :: |   With two iterables, *2N*-tuples are returned. :: | ||||||
| 
 | 
 | ||||||
|      itertools.product([1,2], [3,4], repeat=2) -> |      >>> list(itertools.product([1,2], [3,4], repeat=2)) | ||||||
|         (1, 3, 1, 3), (1, 3, 1, 4), (1, 3, 2, 3), (1, 3, 2, 4), |      [(1, 3, 1, 3), (1, 3, 1, 4), (1, 3, 2, 3), (1, 3, 2, 4), | ||||||
|       (1, 4, 1, 3), (1, 4, 1, 4), (1, 4, 2, 3), (1, 4, 2, 4), |       (1, 4, 1, 3), (1, 4, 1, 4), (1, 4, 2, 3), (1, 4, 2, 4), | ||||||
|       (2, 3, 1, 3), (2, 3, 1, 4), (2, 3, 2, 3), (2, 3, 2, 4), |       (2, 3, 1, 3), (2, 3, 1, 4), (2, 3, 2, 3), (2, 3, 2, 4), | ||||||
|         (2, 4, 1, 3), (2, 4, 1, 4), (2, 4, 2, 3), (2, 4, 2, 4) |       (2, 4, 1, 3), (2, 4, 1, 4), (2, 4, 2, 3), (2, 4, 2, 4)] | ||||||
| 
 | 
 | ||||||
|   ``combinations(iterable, r)`` returns sub-sequences of length *r* from |   ``combinations(iterable, r)`` returns sub-sequences of length *r* from | ||||||
|   the elements of *iterable*. :: |   the elements of *iterable*. :: | ||||||
| 
 | 
 | ||||||
|     itertools.combinations('123', 2) -> |     >>> list(itertools.combinations('123', 2)) | ||||||
|        ('1', '2'), ('1', '3'), ('2', '3') |     [('1', '2'), ('1', '3'), ('2', '3')] | ||||||
| 
 |     >>> list(itertools.combinations('123', 3)) | ||||||
|     itertools.combinations('123', 3) -> |     [('1', '2', '3')] | ||||||
|        ('1', '2', '3') |     >>> list(itertools.combinations('1234', 3)) | ||||||
| 
 |     [('1', '2', '3'), ('1', '2', '4'), | ||||||
|     itertools.combinations('1234', 3) -> |      ('1', '3', '4'), ('2', '3', '4')] | ||||||
|        ('1', '2', '3'), ('1', '2', '4'), ('1', '3', '4'), |  | ||||||
|        ('2', '3', '4') |  | ||||||
| 
 | 
 | ||||||
|   ``permutations(iter[, r])`` returns all the permutations of length *r* of |   ``permutations(iter[, r])`` returns all the permutations of length *r* of | ||||||
|   the iterable's elements.  If *r* is not specified, it will default to the |   the iterable's elements.  If *r* is not specified, it will default to the | ||||||
|   number of elements produced by the iterable. :: |   number of elements produced by the iterable. :: | ||||||
| 
 | 
 | ||||||
|     itertools.permutations([1,2,3,4], 2) -> |     >>> list(itertools.permutations([1,2,3,4], 2)) | ||||||
|        (1, 2), (1, 3), (1, 4), |     [(1, 2), (1, 3), (1, 4), | ||||||
|      (2, 1), (2, 3), (2, 4), |      (2, 1), (2, 3), (2, 4), | ||||||
|      (3, 1), (3, 2), (3, 4), |      (3, 1), (3, 2), (3, 4), | ||||||
|        (4, 1), (4, 2), (4, 3) |      (4, 1), (4, 2), (4, 3)] | ||||||
| 
 | 
 | ||||||
|   ``itertools.chain(*iterables)`` is an existing function in |   ``itertools.chain(*iterables)`` is an existing function in | ||||||
|   :mod:`itertools` that gained a new constructor in Python 2.6. |   :mod:`itertools` that gained a new constructor in Python 2.6. | ||||||
|  | @ -2080,8 +2094,8 @@ changes, or look through the Subversion logs for all the details. | ||||||
|   then return all the elements of the first iterable, then |   then return all the elements of the first iterable, then | ||||||
|   all the elements of the second, and so on. :: |   all the elements of the second, and so on. :: | ||||||
| 
 | 
 | ||||||
|     chain.from_iterable([[1,2,3], [4,5,6]]) -> |     >>> list(itertools.chain.from_iterable([[1,2,3], [4,5,6]])) | ||||||
|         1, 2, 3, 4, 5, 6 |     [1, 2, 3, 4, 5, 6] | ||||||
| 
 | 
 | ||||||
|   (All contributed by Raymond Hettinger.) |   (All contributed by Raymond Hettinger.) | ||||||
| 
 | 
 | ||||||
|  | @ -2252,16 +2266,15 @@ changes, or look through the Subversion logs for all the details. | ||||||
|   with an installed Python package.  For example:: |   with an installed Python package.  For example:: | ||||||
| 
 | 
 | ||||||
|     >>> import pkgutil |     >>> import pkgutil | ||||||
|     >>> pkgutil.get_data('test', 'exception_hierarchy.txt') |     >>> print pkgutil.get_data('test', 'exception_hierarchy.txt') | ||||||
|     'BaseException |     BaseException | ||||||
|      +-- SystemExit |      +-- SystemExit | ||||||
|      +-- KeyboardInterrupt |      +-- KeyboardInterrupt | ||||||
|      +-- GeneratorExit |      +-- GeneratorExit | ||||||
|      +-- Exception |      +-- Exception | ||||||
|           +-- StopIteration |           +-- StopIteration | ||||||
|           +-- StandardError |           +-- StandardError | ||||||
|      ...' |      ... | ||||||
|     >>> |  | ||||||
| 
 | 
 | ||||||
|   (Contributed by Paul Moore; :issue:`2439`.) |   (Contributed by Paul Moore; :issue:`2439`.) | ||||||
| 
 | 
 | ||||||
|  | @ -2535,7 +2548,7 @@ changes, or look through the Subversion logs for all the details. | ||||||
| 
 | 
 | ||||||
|       with test_support.check_warnings() as wrec: |       with test_support.check_warnings() as wrec: | ||||||
|           warnings.simplefilter("always") |           warnings.simplefilter("always") | ||||||
|           ... code that triggers a warning ... |           # ... code that triggers a warning ... | ||||||
|           assert str(wrec.message) == "function is outdated" |           assert str(wrec.message) == "function is outdated" | ||||||
|           assert len(wrec.warnings) == 1, "Multiple warnings raised" |           assert len(wrec.warnings) == 1, "Multiple warnings raised" | ||||||
| 
 | 
 | ||||||
|  | @ -2754,7 +2767,7 @@ representing a literal expression, parses and evaluates it, and | ||||||
| returns the resulting value.  A literal expression is a Python | returns the resulting value.  A literal expression is a Python | ||||||
| expression containing only strings, numbers, dictionaries, | expression containing only strings, numbers, dictionaries, | ||||||
| etc. but no statements or function calls.  If you need to | etc. but no statements or function calls.  If you need to | ||||||
| evaluate an expression but accept the security risk of using an | evaluate an expression but cannot accept the security risk of using an | ||||||
| :func:`eval` call, :func:`literal_eval` will handle it safely:: | :func:`eval` call, :func:`literal_eval` will handle it safely:: | ||||||
| 
 | 
 | ||||||
|     >>> literal = '("a", "b", {2:4, 3:8, 1:2})' |     >>> literal = '("a", "b", {2:4, 3:8, 1:2})' | ||||||
|  | @ -3040,7 +3053,7 @@ Changes to Python's build process and to the C API include: | ||||||
|   ``numfree``, and a macro ``Py<typename>_MAXFREELIST`` is |   ``numfree``, and a macro ``Py<typename>_MAXFREELIST`` is | ||||||
|   always defined. |   always defined. | ||||||
| 
 | 
 | ||||||
| * A new Makefile target, "make check", prepares the Python source tree | * A new Makefile target, "make patchcheck", prepares the Python source tree | ||||||
|   for making a patch: it fixes trailing whitespace in all modified |   for making a patch: it fixes trailing whitespace in all modified | ||||||
|   ``.py`` files, checks whether the documentation has been changed, |   ``.py`` files, checks whether the documentation has been changed, | ||||||
|   and reports whether the :file:`Misc/ACKS` and :file:`Misc/NEWS` files |   and reports whether the :file:`Misc/ACKS` and :file:`Misc/NEWS` files | ||||||
|  | @ -3261,13 +3274,13 @@ that may require changes to your code: | ||||||
| .. ====================================================================== | .. ====================================================================== | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| .. _acks: | .. _26acks: | ||||||
| 
 | 
 | ||||||
| Acknowledgements | Acknowledgements | ||||||
| ================ | ================ | ||||||
| 
 | 
 | ||||||
| The author would like to thank the following people for offering | The author would like to thank the following people for offering | ||||||
| suggestions, corrections and assistance with various drafts of this | suggestions, corrections and assistance with various drafts of this | ||||||
| article: Georg Brandl, Steve Brown, Nick Coghlan, Jim Jewett, Kent | article: Georg Brandl, Steve Brown, Nick Coghlan, Ralph Corderoy,  | ||||||
| Johnson, Chris Lambacher, Antoine Pitrou. | Jim Jewett, Kent Johnson, Chris Lambacher, Antoine Pitrou, Brian Warner. | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										138
									
								
								Doc/whatsnew/2.7.rst
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										138
									
								
								Doc/whatsnew/2.7.rst
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,138 @@ | ||||||
|  | **************************** | ||||||
|  |   What's New in Python 2.7 | ||||||
|  | **************************** | ||||||
|  | 
 | ||||||
|  | :Author: A.M. Kuchling (amk at amk.ca) | ||||||
|  | :Release: |release| | ||||||
|  | :Date: |today| | ||||||
|  | 
 | ||||||
|  | .. $Id$ | ||||||
|  |    Rules for maintenance: | ||||||
|  | 
 | ||||||
|  |    * Anyone can add text to this document.  Do not spend very much time | ||||||
|  |    on the wording of your changes, because your text will probably | ||||||
|  |    get rewritten to some degree. | ||||||
|  | 
 | ||||||
|  |    * The maintainer will go through Misc/NEWS periodically and add | ||||||
|  |    changes; it's therefore more important to add your changes to | ||||||
|  |    Misc/NEWS than to this file. | ||||||
|  | 
 | ||||||
|  |    * This is not a complete list of every single change; completeness | ||||||
|  |    is the purpose of Misc/NEWS.  Some changes I consider too small | ||||||
|  |    or esoteric to include.  If such a change is added to the text, | ||||||
|  |    I'll just remove it.  (This is another reason you shouldn't spend | ||||||
|  |    too much time on writing your addition.) | ||||||
|  | 
 | ||||||
|  |    * If you want to draw your new text to the attention of the | ||||||
|  |    maintainer, add 'XXX' to the beginning of the paragraph or | ||||||
|  |    section. | ||||||
|  | 
 | ||||||
|  |    * It's OK to just add a fragmentary note about a change.  For | ||||||
|  |    example: "XXX Describe the transmogrify() function added to the | ||||||
|  |    socket module."  The maintainer will research the change and | ||||||
|  |    write the necessary text. | ||||||
|  | 
 | ||||||
|  |    * You can comment out your additions if you like, but it's not | ||||||
|  |    necessary (especially when a final release is some months away). | ||||||
|  | 
 | ||||||
|  |    * Credit the author of a patch or bugfix.   Just the name is | ||||||
|  |    sufficient; the e-mail address isn't necessary. | ||||||
|  | 
 | ||||||
|  |    * It's helpful to add the bug/patch number in a parenthetical comment. | ||||||
|  | 
 | ||||||
|  |    XXX Describe the transmogrify() function added to the socket | ||||||
|  |    module. | ||||||
|  |    (Contributed by P.Y. Developer; :issue:`12345`.) | ||||||
|  | 
 | ||||||
|  |    This saves the maintainer some effort going through the SVN logs | ||||||
|  |    when researching a change. | ||||||
|  | 
 | ||||||
|  | This article explains the new features in Python 2.7. | ||||||
|  | No release schedule has been decided yet for 2.7. | ||||||
|  | 
 | ||||||
|  | .. Compare with previous release in 2 - 3 sentences here. | ||||||
|  |    add hyperlink when the documentation becomes available online. | ||||||
|  | 
 | ||||||
|  | .. ======================================================================== | ||||||
|  | .. Large, PEP-level features and changes should be described here. | ||||||
|  | .. Should there be a new section here for 3k migration? | ||||||
|  | .. Or perhaps a more general section describing module changes/deprecation? | ||||||
|  | .. ======================================================================== | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | Other Language Changes | ||||||
|  | ====================== | ||||||
|  | 
 | ||||||
|  | Some smaller changes made to the core Python language are: | ||||||
|  | 
 | ||||||
|  | * List of changes to be written here. | ||||||
|  | 
 | ||||||
|  | .. ====================================================================== | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | Optimizations | ||||||
|  | ------------- | ||||||
|  | 
 | ||||||
|  | To be written. | ||||||
|  | 
 | ||||||
|  | .. ====================================================================== | ||||||
|  | 
 | ||||||
|  | New, Improved, and Deprecated Modules | ||||||
|  | ===================================== | ||||||
|  | 
 | ||||||
|  | As in every release, Python's standard library received a number of | ||||||
|  | enhancements and bug fixes.  Here's a partial list of the most notable | ||||||
|  | changes, sorted alphabetically by module name. Consult the | ||||||
|  | :file:`Misc/NEWS` file in the source tree for a more complete list of | ||||||
|  | changes, or look through the Subversion logs for all the details. | ||||||
|  | 
 | ||||||
|  | * To be written. | ||||||
|  | 
 | ||||||
|  | .. ====================================================================== | ||||||
|  | .. whole new modules get described in subsections here | ||||||
|  | 
 | ||||||
|  | .. ====================================================================== | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | Build and C API Changes | ||||||
|  | ======================= | ||||||
|  | 
 | ||||||
|  | Changes to Python's build process and to the C API include: | ||||||
|  | 
 | ||||||
|  | * To be written. | ||||||
|  | 
 | ||||||
|  | .. ====================================================================== | ||||||
|  | 
 | ||||||
|  | Port-Specific Changes: Windows | ||||||
|  | ----------------------------------- | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | .. ====================================================================== | ||||||
|  | 
 | ||||||
|  | Port-Specific Changes: Mac OS X | ||||||
|  | ----------------------------------- | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | .. ====================================================================== | ||||||
|  | 
 | ||||||
|  | Porting to Python 2.7 | ||||||
|  | ===================== | ||||||
|  | 
 | ||||||
|  | This section lists previously described changes and other bugfixes | ||||||
|  | that may require changes to your code: | ||||||
|  | 
 | ||||||
|  | To be written. | ||||||
|  | 
 | ||||||
|  | .. ====================================================================== | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | .. _acks27: | ||||||
|  | 
 | ||||||
|  | Acknowledgements | ||||||
|  | ================ | ||||||
|  | 
 | ||||||
|  | The author would like to thank the following people for offering | ||||||
|  | suggestions, corrections and assistance with various drafts of this | ||||||
|  | article: no one yet. | ||||||
|  | 
 | ||||||
|  | @ -440,7 +440,7 @@ Platform-specific changes go here. | ||||||
| .. ====================================================================== | .. ====================================================================== | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| .. _section-other: | .. _30section-other: | ||||||
| 
 | 
 | ||||||
| Other Changes and Fixes | Other Changes and Fixes | ||||||
| ======================= | ======================= | ||||||
|  |  | ||||||
							
								
								
									
										22
									
								
								Doc/whatsnew/index.rst
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								Doc/whatsnew/index.rst
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,22 @@ | ||||||
|  | .. _whatsnew-index: | ||||||
|  | 
 | ||||||
|  | ###################### | ||||||
|  |  What's New in Python | ||||||
|  | ###################### | ||||||
|  | 
 | ||||||
|  | The "What's New in Python" series of essays takes tours through the most | ||||||
|  | important changes between major Python versions.  They are a "must read" for | ||||||
|  | anyone wishing to stay up-to-date after a new release. | ||||||
|  | 
 | ||||||
|  | .. toctree:: | ||||||
|  |    :maxdepth: 1 | ||||||
|  | 
 | ||||||
|  |    3.0.rst | ||||||
|  |    2.7.rst | ||||||
|  |    2.6.rst | ||||||
|  |    2.5.rst | ||||||
|  |    2.4.rst | ||||||
|  |    2.3.rst | ||||||
|  |    2.2.rst | ||||||
|  |    2.1.rst | ||||||
|  |    2.0.rst | ||||||
|  | @ -1,21 +1,13 @@ | ||||||
| """optparse - a powerful, extensible, and easy-to-use option parser. | """A powerful, extensible, and easy-to-use option parser. | ||||||
| 
 | 
 | ||||||
| By Greg Ward <gward@python.net> | By Greg Ward <gward@python.net> | ||||||
| 
 | 
 | ||||||
| Originally distributed as Optik; see http://optik.sourceforge.net/ . | Originally distributed as Optik. | ||||||
| 
 |  | ||||||
| If you have problems with this module, please do not file bugs, |  | ||||||
| patches, or feature requests with Python; instead, use Optik's |  | ||||||
| SourceForge project page: |  | ||||||
|   http://sourceforge.net/projects/optik |  | ||||||
| 
 | 
 | ||||||
| For support, use the optik-users@lists.sourceforge.net mailing list | For support, use the optik-users@lists.sourceforge.net mailing list | ||||||
| (http://lists.sourceforge.net/lists/listinfo/optik-users). | (http://lists.sourceforge.net/lists/listinfo/optik-users). | ||||||
| """ | """ | ||||||
| 
 | 
 | ||||||
| # Python developers: please do not make changes to this file, since |  | ||||||
| # it is automatically generated from the Optik source code. |  | ||||||
| 
 |  | ||||||
| __version__ = "1.5.3" | __version__ = "1.5.3" | ||||||
| 
 | 
 | ||||||
| __all__ = ['Option', | __all__ = ['Option', | ||||||
|  | @ -1263,9 +1255,19 @@ def set_usage(self, usage): | ||||||
|             self.usage = usage |             self.usage = usage | ||||||
| 
 | 
 | ||||||
|     def enable_interspersed_args(self): |     def enable_interspersed_args(self): | ||||||
|  |         """Set parsing to not stop on the first non-option, allowing | ||||||
|  |         interspersing switches with command arguments. This is the | ||||||
|  |         default behavior. See also disable_interspersed_args() and the | ||||||
|  |         class documentation description of the attribute | ||||||
|  |         allow_interspersed_args.""" | ||||||
|         self.allow_interspersed_args = True |         self.allow_interspersed_args = True | ||||||
| 
 | 
 | ||||||
|     def disable_interspersed_args(self): |     def disable_interspersed_args(self): | ||||||
|  |         """Set parsing to stop on the first non-option. Use this if | ||||||
|  |         you have a command processor which runs another command that | ||||||
|  |         has options of its own and you want to make sure these options | ||||||
|  |         don't get confused. | ||||||
|  |         """ | ||||||
|         self.allow_interspersed_args = False |         self.allow_interspersed_args = False | ||||||
| 
 | 
 | ||||||
|     def set_process_default_values(self, process): |     def set_process_default_values(self, process): | ||||||
|  |  | ||||||
|  | @ -26,12 +26,13 @@ def raise2(): | ||||||
| class TestCase(unittest.TestCase): | class TestCase(unittest.TestCase): | ||||||
|     def setUp(self): |     def setUp(self): | ||||||
|         self.stream = io.StringIO() |         self.stream = io.StringIO() | ||||||
|  |         self.save_stdout, self.save_stderr = sys.stderr, sys.stdout | ||||||
|         sys.stdout = sys.stderr = self.stream |         sys.stdout = sys.stderr = self.stream | ||||||
|         atexit._clear() |         atexit._clear() | ||||||
| 
 | 
 | ||||||
|     def tearDown(self): |     def tearDown(self): | ||||||
|         sys.stdout = sys.__stdout__ |         sys.stdout = self.save_stdout | ||||||
|         sys.stderr = sys.__stderr__ |         sys.stderr = self.save_stderr | ||||||
|         atexit._clear() |         atexit._clear() | ||||||
| 
 | 
 | ||||||
|     def test_args(self): |     def test_args(self): | ||||||
|  |  | ||||||
|  | @ -196,6 +196,17 @@ def test_vsBuiltinSort(self, n=500): | ||||||
|     def test_backcompatibility(self): |     def test_backcompatibility(self): | ||||||
|         self.assertEqual(self.module.insort, self.module.insort_right) |         self.assertEqual(self.module.insort, self.module.insort_right) | ||||||
| 
 | 
 | ||||||
|  |     def test_listDerived(self): | ||||||
|  |         class List(list): | ||||||
|  |             data = [] | ||||||
|  |             def insert(self, index, item): | ||||||
|  |                 self.data.insert(index, item) | ||||||
|  | 
 | ||||||
|  |         lst = List() | ||||||
|  |         self.module.insort_left(lst, 10) | ||||||
|  |         self.module.insort_right(lst, 5) | ||||||
|  |         self.assertEqual([5, 10], lst.data) | ||||||
|  | 
 | ||||||
| class TestInsortPython(TestInsort): | class TestInsortPython(TestInsort): | ||||||
|     module = py_bisect |     module = py_bisect | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -249,7 +249,7 @@ def test_disallowed_computations(self): | ||||||
|         self.assertRaises(TypeError, lambda: a // x) |         self.assertRaises(TypeError, lambda: a // x) | ||||||
|         self.assertRaises(TypeError, lambda: x // a) |         self.assertRaises(TypeError, lambda: x // a) | ||||||
| 
 | 
 | ||||||
|         # Divison of int by timedelta doesn't make sense. |         # Division of int by timedelta doesn't make sense. | ||||||
|         # Division by zero doesn't make sense. |         # Division by zero doesn't make sense. | ||||||
|         for zero in 0, 0: |         for zero in 0, 0: | ||||||
|             self.assertRaises(TypeError, lambda: zero // a) |             self.assertRaises(TypeError, lambda: zero // a) | ||||||
|  |  | ||||||
|  | @ -140,6 +140,23 @@ def tearDown(self): | ||||||
| 
 | 
 | ||||||
|     def setUp(self): |     def setUp(self): | ||||||
|         delete_files() |         delete_files() | ||||||
|  |         self.filename = test.support.TESTFN | ||||||
|  |         self.d = dbm.open(self.filename, 'c') | ||||||
|  |         self.d.close() | ||||||
|  | 
 | ||||||
|  |     def test_keys(self): | ||||||
|  |         self.d = dbm.open(self.filename, 'c') | ||||||
|  |         self.assertEqual(self.d.keys(), []) | ||||||
|  |         a = [(b'a', b'b'), (b'12345678910', b'019237410982340912840198242')] | ||||||
|  |         for k, v in a: | ||||||
|  |             self.d[k] = v | ||||||
|  |         self.assertEqual(sorted(self.d.keys()), sorted(k for (k, v) in a)) | ||||||
|  |         for k, v in a: | ||||||
|  |             self.assert_(k in self.d) | ||||||
|  |             self.assertEqual(self.d[k], v) | ||||||
|  |         self.assert_('xxx' not in self.d) | ||||||
|  |         self.assertRaises(KeyError, lambda: self.d['xxx']) | ||||||
|  |         self.d.close() | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def test_main(): | def test_main(): | ||||||
|  |  | ||||||
|  | @ -8,9 +8,9 @@ | ||||||
| PORT = None | PORT = None | ||||||
| 
 | 
 | ||||||
| def server(evt, numrequests): | def server(evt, numrequests): | ||||||
|     try: |  | ||||||
|     serv = DocXMLRPCServer(("localhost", 0), logRequests=False) |     serv = DocXMLRPCServer(("localhost", 0), logRequests=False) | ||||||
| 
 | 
 | ||||||
|  |     try: | ||||||
|         global PORT |         global PORT | ||||||
|         PORT = serv.socket.getsockname()[1] |         PORT = serv.socket.getsockname()[1] | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -391,6 +391,17 @@ def test_remove_keyerror_unpacking(self): | ||||||
|             else: |             else: | ||||||
|                 self.fail() |                 self.fail() | ||||||
| 
 | 
 | ||||||
|  |     def test_remove_keyerror_set(self): | ||||||
|  |         key = self.thetype([3, 4]) | ||||||
|  |         try: | ||||||
|  |             self.s.remove(key) | ||||||
|  |         except KeyError as e: | ||||||
|  |             self.assert_(e.args[0] is key, | ||||||
|  |                          "KeyError should be {0}, not {1}".format(key, | ||||||
|  |                                                                   e.args[0])) | ||||||
|  |         else: | ||||||
|  |             self.fail() | ||||||
|  | 
 | ||||||
|     def test_discard(self): |     def test_discard(self): | ||||||
|         self.s.discard('a') |         self.s.discard('a') | ||||||
|         self.assert_('a' not in self.s) |         self.assert_('a' not in self.s) | ||||||
|  |  | ||||||
|  | @ -130,8 +130,8 @@ def getFullVersion(): | ||||||
|     ), |     ), | ||||||
| 
 | 
 | ||||||
|     dict( |     dict( | ||||||
|         name="SQLite 3.3.5", |         name="SQLite 3.6.3", | ||||||
|         url="http://www.sqlite.org/sqlite-3.3.5.tar.gz", |         url="http://www.sqlite.org/sqlite-3.6.3.tar.gz", | ||||||
|         checksum='93f742986e8bc2dfa34792e16df017a6feccf3a2', |         checksum='93f742986e8bc2dfa34792e16df017a6feccf3a2', | ||||||
|         configure_pre=[ |         configure_pre=[ | ||||||
|             '--enable-threadsafe', |             '--enable-threadsafe', | ||||||
|  | @ -171,8 +171,8 @@ def getFullVersion(): | ||||||
|             ), |             ), | ||||||
|     ), |     ), | ||||||
|     dict( |     dict( | ||||||
|         name="Sleepycat DB 4.4", |         name="Sleepycat DB 4.7.25", | ||||||
|         url="http://downloads.sleepycat.com/db-4.4.20.tar.gz", |         url="http://download.oracle.com/berkeley-db/db-4.7.25.tar.gz", | ||||||
|         #name="Sleepycat DB 4.3.29", |         #name="Sleepycat DB 4.3.29", | ||||||
|         #url="http://downloads.sleepycat.com/db-4.3.29.tar.gz", |         #url="http://downloads.sleepycat.com/db-4.3.29.tar.gz", | ||||||
|         buildDir="build_unix", |         buildDir="build_unix", | ||||||
|  | @ -586,21 +586,23 @@ def buildPythonDocs(): | ||||||
|     version = getVersion() |     version = getVersion() | ||||||
|     docdir = os.path.join(rootDir, 'pydocs') |     docdir = os.path.join(rootDir, 'pydocs') | ||||||
| 
 | 
 | ||||||
|  |     novername = 'python-docs-html.tar.bz2' | ||||||
|     name = 'html-%s.tar.bz2'%(getFullVersion(),) |     name = 'html-%s.tar.bz2'%(getFullVersion(),) | ||||||
|     sourceArchive = os.path.join(DEPSRC, name) |     sourceArchive = os.path.join(DEPSRC, name) | ||||||
|     if os.path.exists(sourceArchive): |     if os.path.exists(sourceArchive): | ||||||
|         print("Using local copy of %s"%(name,)) |         print("Using local copy of %s"%(name,)) | ||||||
| 
 | 
 | ||||||
|     else: |     else: | ||||||
|         print("Downloading %s"%(name,)) |         print "Downloading %s"%(novername,) | ||||||
|         downloadURL('http://www.python.org/ftp/python/doc/%s/%s'%( |         downloadURL('http://www.python.org/ftp/python/doc/%s/%s'%( | ||||||
|             getFullVersion(), name), sourceArchive) |             getFullVersion(), novername), sourceArchive) | ||||||
|         print("Archive for %s stored as %s"%(name, sourceArchive)) |         print("Archive for %s stored as %s"%(name, sourceArchive)) | ||||||
| 
 | 
 | ||||||
|     extractArchive(os.path.dirname(docdir), sourceArchive) |     extractArchive(os.path.dirname(docdir), sourceArchive) | ||||||
|  | 
 | ||||||
|     os.rename( |     os.rename( | ||||||
|             os.path.join( |             os.path.join( | ||||||
|                 os.path.dirname(docdir), 'Python-Docs-%s'%(getFullVersion(),)), |                 os.path.dirname(docdir), 'python-docs-html'), | ||||||
|             docdir) |             docdir) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -1029,11 +1031,11 @@ def main(): | ||||||
|     buildPython() |     buildPython() | ||||||
|     buildPythonDocs() |     buildPythonDocs() | ||||||
|     fn = os.path.join(WORKDIR, "_root", "Applications", |     fn = os.path.join(WORKDIR, "_root", "Applications", | ||||||
|                 "MacPython %s"%(getVersion(),), "Update Shell Profile.command") |                 "Python %s"%(getVersion(),), "Update Shell Profile.command") | ||||||
|     patchFile("scripts/postflight.patch-profile",  fn) |     patchFile("scripts/postflight.patch-profile",  fn) | ||||||
|     os.chmod(fn, 0755) |     os.chmod(fn, 0755) | ||||||
| 
 | 
 | ||||||
|     folder = os.path.join(WORKDIR, "_root", "Applications", "MacPython %s"%( |     folder = os.path.join(WORKDIR, "_root", "Applications", "Python %s"%( | ||||||
|         getVersion(),)) |         getVersion(),)) | ||||||
|     os.chmod(folder, 0755) |     os.chmod(folder, 0755) | ||||||
|     setIcon(folder, "../Icons/Python Folder.icns") |     setIcon(folder, "../Icons/Python Folder.icns") | ||||||
|  |  | ||||||
|  | @ -176,8 +176,8 @@ PYTHON=		python$(EXE) | ||||||
| BUILDPYTHON=	python$(BUILDEXE) | BUILDPYTHON=	python$(BUILDEXE) | ||||||
| 
 | 
 | ||||||
| # The task to run while instrument when building the profile-opt target | # The task to run while instrument when building the profile-opt target | ||||||
| PROFILE_TASK=	Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck | PROFILE_TASK=	$(srcdir)/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck | ||||||
| #PROFILE_TASK=	Lib/test/regrtest.py | #PROFILE_TASK=	$(srcdir)/Lib/test/regrtest.py | ||||||
| 
 | 
 | ||||||
| # === Definitions added by makesetup === | # === Definitions added by makesetup === | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -82,7 +82,7 @@ insort_right(PyObject *self, PyObject *args, PyObject *kw) | ||||||
| 	index = internal_bisect_right(list, item, lo, hi); | 	index = internal_bisect_right(list, item, lo, hi); | ||||||
| 	if (index < 0) | 	if (index < 0) | ||||||
| 		return NULL; | 		return NULL; | ||||||
| 	if (PyList_Check(list)) { | 	if (PyList_CheckExact(list)) { | ||||||
| 		if (PyList_Insert(list, index, item) < 0) | 		if (PyList_Insert(list, index, item) < 0) | ||||||
| 			return NULL; | 			return NULL; | ||||||
| 	} else { | 	} else { | ||||||
|  | @ -183,7 +183,7 @@ insort_left(PyObject *self, PyObject *args, PyObject *kw) | ||||||
| 	index = internal_bisect_left(list, item, lo, hi); | 	index = internal_bisect_left(list, item, lo, hi); | ||||||
| 	if (index < 0) | 	if (index < 0) | ||||||
| 		return NULL; | 		return NULL; | ||||||
| 	if (PyList_Check(list)) { | 	if (PyList_CheckExact(list)) { | ||||||
| 		if (PyList_Insert(list, index, item) < 0) | 		if (PyList_Insert(list, index, item) < 0) | ||||||
| 			return NULL; | 			return NULL; | ||||||
| 	} else { | 	} else { | ||||||
|  |  | ||||||
|  | @ -108,7 +108,7 @@ Decodes obj using the codec registered for encoding. encoding defaults\n\ | ||||||
| to the default encoding. errors may be given to set a different error\n\ | to the default encoding. errors may be given to set a different error\n\ | ||||||
| handling scheme. Default is 'strict' meaning that encoding errors raise\n\ | handling scheme. Default is 'strict' meaning that encoding errors raise\n\ | ||||||
| a ValueError. Other possible values are 'ignore' and 'replace'\n\ | a ValueError. Other possible values are 'ignore' and 'replace'\n\ | ||||||
| as well as any other name registerd with codecs.register_error that is\n\ | as well as any other name registered with codecs.register_error that is\n\ | ||||||
| able to handle ValueErrors."); | able to handle ValueErrors."); | ||||||
| 
 | 
 | ||||||
| static PyObject * | static PyObject * | ||||||
|  |  | ||||||
|  | @ -36,7 +36,7 @@ PyDoc_STRVAR(MultibyteCodec_Decode__doc__, | ||||||
| Decodes `string' using I, an MultibyteCodec instance. errors may be given\n\ | Decodes `string' using I, an MultibyteCodec instance. errors may be given\n\ | ||||||
| to set a different error handling scheme. Default is 'strict' meaning\n\ | to set a different error handling scheme. Default is 'strict' meaning\n\ | ||||||
| that encoding errors raise a UnicodeDecodeError. Other possible values\n\ | that encoding errors raise a UnicodeDecodeError. Other possible values\n\ | ||||||
| are 'ignore' and 'replace' as well as any other name registerd with\n\ | are 'ignore' and 'replace' as well as any other name registered with\n\ | ||||||
| codecs.register_error that is able to handle UnicodeDecodeErrors."); | codecs.register_error that is able to handle UnicodeDecodeErrors."); | ||||||
| 
 | 
 | ||||||
| static char *codeckwarglist[] = {"input", "errors", NULL}; | static char *codeckwarglist[] = {"input", "errors", NULL}; | ||||||
|  |  | ||||||
|  | @ -751,11 +751,16 @@ win32_wchdir(LPCWSTR path) | ||||||
| 	if (!result) | 	if (!result) | ||||||
| 		return FALSE; | 		return FALSE; | ||||||
| 	if (result > MAX_PATH+1) { | 	if (result > MAX_PATH+1) { | ||||||
| 		new_path = malloc(result); | 		new_path = malloc(result * sizeof(wchar_t)); | ||||||
| 		if (!new_path) { | 		if (!new_path) { | ||||||
| 			SetLastError(ERROR_OUTOFMEMORY); | 			SetLastError(ERROR_OUTOFMEMORY); | ||||||
| 			return FALSE; | 			return FALSE; | ||||||
| 		} | 		} | ||||||
|  | 		result = GetCurrentDirectoryW(result, new_path); | ||||||
|  | 		if (!result) { | ||||||
|  | 			free(new_path); | ||||||
|  | 			return FALSE; | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
| 	if (wcsncmp(new_path, L"\\\\", 2) == 0 || | 	if (wcsncmp(new_path, L"\\\\", 2) == 0 || | ||||||
| 	    wcsncmp(new_path, L"//", 2) == 0) | 	    wcsncmp(new_path, L"//", 2) == 0) | ||||||
|  |  | ||||||
|  | @ -1870,16 +1870,18 @@ PyDoc_STRVAR(setdefault_doc__, | ||||||
| "D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D"); | "D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D"); | ||||||
| 
 | 
 | ||||||
| PyDoc_STRVAR(pop__doc__, | PyDoc_STRVAR(pop__doc__, | ||||||
| "D.pop(k[,d]) -> v, remove specified key and return the corresponding value\n\
 | "D.pop(k[,d]) -> v, remove specified key and return the corresponding value.\n\
 | ||||||
| If key is not found, d is returned if given, otherwise KeyError is raised"); | If key is not found, d is returned if given, otherwise KeyError is raised"); | ||||||
| 
 | 
 | ||||||
| PyDoc_STRVAR(popitem__doc__, | PyDoc_STRVAR(popitem__doc__, | ||||||
| "D.popitem() -> (k, v), remove and return some (key, value) pair as a\n\
 | "D.popitem() -> (k, v), remove and return some (key, value) pair as a\n\
 | ||||||
| 2-tuple; but raise KeyError if D is empty"); | 2-tuple; but raise KeyError if D is empty."); | ||||||
| 
 | 
 | ||||||
| PyDoc_STRVAR(update__doc__, | PyDoc_STRVAR(update__doc__, | ||||||
| "D.update(E, **F) -> None.  Update D from E and F: for k in E: D[k] = E[k]\
 | "D.update(E, **F) -> None.  Update D from dict/iterable E and F.\n" | ||||||
| \n(if E has keys else: for (k, v) in E: D[k] = v) then: for k in F: D[k] = F[k]"); | "If E has a .keys() method, does:     for k in E: D[k] = E[k]\n\
 | ||||||
|  | If E lacks .keys() method, does:     for (k, v) in E: D[k] = v\n\ | ||||||
|  | In either case, this is followed by: for k in F: D[k] = F[k]"); | ||||||
| 
 | 
 | ||||||
| PyDoc_STRVAR(fromkeys__doc__, | PyDoc_STRVAR(fromkeys__doc__, | ||||||
| "dict.fromkeys(S[,v]) -> New dict with keys from S and values equal to v.\n\
 | "dict.fromkeys(S[,v]) -> New dict with keys from S and values equal to v.\n\
 | ||||||
|  |  | ||||||
|  | @ -1457,7 +1457,7 @@ float_as_integer_ratio(PyObject *v, PyObject *unused) | ||||||
| #ifdef Py_NAN | #ifdef Py_NAN | ||||||
| 	if (Py_IS_NAN(self)) { | 	if (Py_IS_NAN(self)) { | ||||||
| 	  PyErr_SetString(PyExc_ValueError, | 	  PyErr_SetString(PyExc_ValueError, | ||||||
| 			  "Cannot pass nan to float.as_integer_ratio."); | 			  "Cannot pass NaN to float.as_integer_ratio."); | ||||||
| 	  return NULL; | 	  return NULL; | ||||||
| 	} | 	} | ||||||
| #endif | #endif | ||||||
|  | @ -1516,7 +1516,7 @@ PyDoc_STRVAR(float_as_integer_ratio_doc, | ||||||
| "\n" | "\n" | ||||||
| "Returns a pair of integers, whose ratio is exactly equal to the original\n" | "Returns a pair of integers, whose ratio is exactly equal to the original\n" | ||||||
| "float and with a positive denominator.\n" | "float and with a positive denominator.\n" | ||||||
| "Raises OverflowError on infinities and a ValueError on nans.\n" | "Raises OverflowError on infinities and a ValueError on NaNs.\n" | ||||||
| "\n" | "\n" | ||||||
| ">>> (10.0).as_integer_ratio()\n" | ">>> (10.0).as_integer_ratio()\n" | ||||||
| "(10, 1)\n" | "(10, 1)\n" | ||||||
|  |  | ||||||
|  | @ -2286,11 +2286,14 @@ PyDoc_STRVAR(extend_doc, | ||||||
| PyDoc_STRVAR(insert_doc, | PyDoc_STRVAR(insert_doc, | ||||||
| "L.insert(index, object) -- insert object before index"); | "L.insert(index, object) -- insert object before index"); | ||||||
| PyDoc_STRVAR(pop_doc, | PyDoc_STRVAR(pop_doc, | ||||||
| "L.pop([index]) -> item -- remove and return item at index (default last)"); | "L.pop([index]) -> item -- remove and return item at index (default last).\n" | ||||||
|  | "Raises IndexError if list is empty or index is out of range."); | ||||||
| PyDoc_STRVAR(remove_doc, | PyDoc_STRVAR(remove_doc, | ||||||
| "L.remove(value) -- remove first occurrence of value"); | "L.remove(value) -- remove first occurrence of value.\n" | ||||||
|  | "Raises ValueError if the value is not present."); | ||||||
| PyDoc_STRVAR(index_doc, | PyDoc_STRVAR(index_doc, | ||||||
| "L.index(value, [start, [stop]]) -> integer -- return first index of value"); | "L.index(value, [start, [stop]]) -> integer -- return first index of value.\n" | ||||||
|  | "Raises ValueError if the value is not present."); | ||||||
| PyDoc_STRVAR(count_doc, | PyDoc_STRVAR(count_doc, | ||||||
| "L.count(value) -> integer -- return number of occurrences of value"); | "L.count(value) -> integer -- return number of occurrences of value"); | ||||||
| PyDoc_STRVAR(reverse_doc, | PyDoc_STRVAR(reverse_doc, | ||||||
|  |  | ||||||
|  | @ -746,7 +746,8 @@ set_pop(PySetObject *so) | ||||||
| 	return key; | 	return key; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| PyDoc_STRVAR(pop_doc, "Remove and return an arbitrary set element."); | PyDoc_STRVAR(pop_doc, "Remove and return an arbitrary set element.\n\
 | ||||||
|  | Raises KeyError if the set is empty."); | ||||||
| 
 | 
 | ||||||
| static int | static int | ||||||
| set_traverse(PySetObject *so, visitproc visit, void *arg) | set_traverse(PySetObject *so, visitproc visit, void *arg) | ||||||
|  | @ -1861,7 +1862,7 @@ PyDoc_STRVAR(contains_doc, "x.__contains__(y) <==> y in x."); | ||||||
| static PyObject * | static PyObject * | ||||||
| set_remove(PySetObject *so, PyObject *key) | set_remove(PySetObject *so, PyObject *key) | ||||||
| { | { | ||||||
| 	PyObject *tmpkey, *result; | 	PyObject *tmpkey; | ||||||
| 	int rv; | 	int rv; | ||||||
| 
 | 
 | ||||||
| 	rv = set_discard_key(so, key); | 	rv = set_discard_key(so, key); | ||||||
|  | @ -1873,11 +1874,14 @@ set_remove(PySetObject *so, PyObject *key) | ||||||
| 		if (tmpkey == NULL) | 		if (tmpkey == NULL) | ||||||
| 			return NULL; | 			return NULL; | ||||||
| 		set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key); | 		set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key); | ||||||
| 		result = set_remove(so, tmpkey); | 		rv = set_discard_key(so, tmpkey); | ||||||
| 		set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key); | 		set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key); | ||||||
| 		Py_DECREF(tmpkey); | 		Py_DECREF(tmpkey); | ||||||
| 		return result; | 		if (rv == -1) | ||||||
| 	} else if (rv == DISCARD_NOTFOUND) { | 			return NULL; | ||||||
|  | 	}  | ||||||
|  | 
 | ||||||
|  | 	if (rv == DISCARD_NOTFOUND) { | ||||||
| 		set_key_error(key); | 		set_key_error(key); | ||||||
| 		return NULL; | 		return NULL; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -694,7 +694,9 @@ tuple_sizeof(PyTupleObject *self) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| PyDoc_STRVAR(index_doc, | PyDoc_STRVAR(index_doc, | ||||||
| "T.index(value, [start, [stop]]) -> integer -- return first index of value"); | "T.index(value, [start, [stop]]) -> integer -- return first index of value.\n" | ||||||
|  | "Raises ValueError if the value is not present." | ||||||
|  | ); | ||||||
| PyDoc_STRVAR(count_doc, | PyDoc_STRVAR(count_doc, | ||||||
| "T.count(value) -> integer -- return number of occurrences of value"); | "T.count(value) -> integer -- return number of occurrences of value"); | ||||||
| PyDoc_STRVAR(sizeof_doc, | PyDoc_STRVAR(sizeof_doc, | ||||||
|  |  | ||||||
|  | @ -7300,7 +7300,7 @@ unicode_length(PyUnicodeObject *self) | ||||||
| PyDoc_STRVAR(ljust__doc__, | PyDoc_STRVAR(ljust__doc__, | ||||||
| "S.ljust(width[, fillchar]) -> str\n\
 | "S.ljust(width[, fillchar]) -> str\n\
 | ||||||
| \n\ | \n\ | ||||||
| Return S left justified in a Unicode string of length width. Padding is\n\ | Return S left-justified in a Unicode string of length width. Padding is\n\ | ||||||
| done using the specified fill character (default is a space)."); | done using the specified fill character (default is a space)."); | ||||||
| 
 | 
 | ||||||
| static PyObject * | static PyObject * | ||||||
|  | @ -7815,7 +7815,7 @@ unicode_rindex(PyUnicodeObject *self, PyObject *args) | ||||||
| PyDoc_STRVAR(rjust__doc__, | PyDoc_STRVAR(rjust__doc__, | ||||||
| "S.rjust(width[, fillchar]) -> str\n\
 | "S.rjust(width[, fillchar]) -> str\n\
 | ||||||
| \n\ | \n\ | ||||||
| Return S right justified in a string of length width. Padding is\n\ | Return S right-justified in a string of length width. Padding is\n\ | ||||||
| done using the specified fill character (default is a space)."); | done using the specified fill character (default is a space)."); | ||||||
| 
 | 
 | ||||||
| static PyObject * | static PyObject * | ||||||
|  | @ -7945,7 +7945,7 @@ PyDoc_STRVAR(partition__doc__, | ||||||
| \n\ | \n\ | ||||||
| Search for the separator sep in S, and return the part before it,\n\ | Search for the separator sep in S, and return the part before it,\n\ | ||||||
| the separator itself, and the part after it.  If the separator is not\n\ | the separator itself, and the part after it.  If the separator is not\n\ | ||||||
| found, returns S and two empty strings."); | found, return S and two empty strings."); | ||||||
| 
 | 
 | ||||||
| static PyObject* | static PyObject* | ||||||
| unicode_partition(PyUnicodeObject *self, PyObject *separator) | unicode_partition(PyUnicodeObject *self, PyObject *separator) | ||||||
|  | @ -7958,7 +7958,7 @@ PyDoc_STRVAR(rpartition__doc__, | ||||||
| \n\ | \n\ | ||||||
| Search for the separator sep in S, starting at the end of S, and return\n\ | Search for the separator sep in S, starting at the end of S, and return\n\ | ||||||
| the part before it, the separator itself, and the part after it.  If the\n\ | the part before it, the separator itself, and the part after it.  If the\n\ | ||||||
| separator is not found, returns two empty strings and S."); | separator is not found, return two empty strings and S."); | ||||||
| 
 | 
 | ||||||
| static PyObject* | static PyObject* | ||||||
| unicode_rpartition(PyUnicodeObject *self, PyObject *separator) | unicode_rpartition(PyUnicodeObject *self, PyObject *separator) | ||||||
|  |  | ||||||
							
								
								
									
										1
									
								
								setup.py
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								setup.py
									
										
									
									
									
								
							|  | @ -730,6 +730,7 @@ def detect_modules(self): | ||||||
|             ] |             ] | ||||||
|             sqlite_libfile = self.compiler.find_library_file( |             sqlite_libfile = self.compiler.find_library_file( | ||||||
|                                 sqlite_dirs_to_check + lib_dirs, 'sqlite3') |                                 sqlite_dirs_to_check + lib_dirs, 'sqlite3') | ||||||
|  |             if sqlite_libfile: | ||||||
|                 sqlite_libdir = [os.path.abspath(os.path.dirname(sqlite_libfile))] |                 sqlite_libdir = [os.path.abspath(os.path.dirname(sqlite_libfile))] | ||||||
| 
 | 
 | ||||||
|         if sqlite_incdir and sqlite_libdir: |         if sqlite_incdir and sqlite_libdir: | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Benjamin Peterson
						Benjamin Peterson