Skip to content

Commit

Permalink
python#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TY…
Browse files Browse the repository at this point in the history
…PE and Py_REFCNT.
  • Loading branch information
tiran committed Dec 19, 2007
1 parent 99170a5 commit 90aa764
Show file tree
Hide file tree
Showing 144 changed files with 1,306 additions and 1,153 deletions.
161 changes: 157 additions & 4 deletions Doc/whatsnew/2.6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ new feature.
Python 3.0
================

.. % XXX add general comment about Python 3.0 features in 2.6
The development cycle for Python 2.6 also saw the release of the first
alphas of Python 3.0, and the development of 3.0 has influenced
a number of features in 2.6.
Expand All @@ -95,14 +93,72 @@ are:
A new command-line switch, :option:`-3`, enables warnings
about features that will be removed in Python 3.0. You can run code
with this switch to see how much work will be necessary to port
code to 3.0.
code to 3.0. The value of this switch is available
to Python code as the boolean variable ``sys.py3kwarning``,
and to C extension code as :cdata:`Py_Py3kWarningFlag`.

.. seealso::

The 3xxx series of PEPs, which describes the development process for
Python 3.0 and various features that have been accepted, rejected,
or are still under consideration.


Development Changes
==================================================

While 2.6 was being developed, the Python development process
underwent two significant changes: the developer group
switched from SourceForge's issue tracker to a customized
Roundup installation, and the documentation was converted from
LaTeX to reStructured Text.


New Issue Tracker: Roundup
--------------------------------------------------

XXX write this.


New Documentation Format: ReStructured Text
--------------------------------------------------

Python's documentation had been written using LaTeX since the
project's inception around 1989. At that time, most documentation was
printed out for later study, not viewed online. LaTeX was widely used
because it provided attractive printed output while
remaining straightforward to write, once the basic rules
of the markup have been learned.

LaTeX is still used today for writing technical publications destined
for printing, but the landscape for programming tools has shifted. We
no longer print out reams of documentation; instead, we browse through
it online and HTML is the most important format to support.
Unfortunately, converting LaTeX to HTML is fairly complicated, and
Fred L. Drake Jr., the Python documentation editor for many years,
spent a lot of time wrestling the conversion process into shape.
Occasionally people would suggest converting the documentation into
SGML or, later, XML, but performing a good conversion is a major task
and no one pursued the task to completion.

During the 2.6 development cycle, Georg Brandl put a substantial
effort into building a new toolchain called Sphinx
for processing the documentation.
The input format is reStructured Text,
a markup commonly used in the Python community that supports
custom extensions and directives. Sphinx concentrates
on its HTML output, producing attractively styled
and modern HTML. (XXX finish this -- mention new search feature)

.. seealso::

`Docutils <http://docutils.sf.net>`__: The fundamental
reStructured Text parser and toolset.

`Documenting Python <XXX>`__: Describes how to write for
Python's documentation.


PEP 343: The 'with' statement
=============================

Expand Down Expand Up @@ -352,6 +408,24 @@ bound to a variable, and calls ``object.close`` at the end of the block. ::

.. % ======================================================================
.. _pep-0366:

PEP 366: Explicit Relative Imports From a Main Module
============================================================

Python's :option:`-m` switch allows running a module as a script.
When you ran a module that was located inside a package, relative
imports didn't work correctly.

The fix in Python 2.6 adds a :attr:`__package__` attribute to modules.
When present, relative imports will be relative to the value of this
attribute instead of the :attr:`__name__` attribute. PEP 302-style
importers can then set :attr:`__package__`. The :mod:`runpy` module
that implements the :option:`-m` switch now does this, so relative imports
can now be used in scripts running from inside a package.

.. % ======================================================================
.. _pep-3110:

PEP 3110: Exception-Handling Changes
Expand Down Expand Up @@ -414,7 +488,7 @@ XXX
:pep:`3119` - Introducing Abstract Base Classes
PEP written by Guido van Rossum and Talin.
Implemented by XXX.
Backported to 2.6 by Benjamin Aranguren (with Alex Martelli).
Backported to 2.6 by Benjamin Aranguren, with Alex Martelli.

Other Language Changes
======================
Expand Down Expand Up @@ -443,6 +517,25 @@ Here are all of the changes that Python 2.6 makes to the core Python language.

.. % Revision 57619
* Properties now have two attributes,
:attr:`setter` and :attr:`deleter`, that are useful shortcuts for
adding a setter or deleter function to an existing property.
You would use them like this::

class C(object):
@property
def x(self):
return self._x

@x.setter
def x(self, value):
self._x = value

@x.deleter
def x(self):
del self._x


* C functions and methods that use
:cfunc:`PyComplex_AsCComplex` will now accept arguments that
have a :meth:`__complex__` method. In particular, the functions in the
Expand All @@ -452,11 +545,26 @@ Here are all of the changes that Python 2.6 makes to the core Python language.

.. % Patch #1675423
A numerical nicety: when creating a complex number from two floats
on systems that support signed zeros (-0 and +0), the
:func:`complex()` constructor will now preserve the sign
of the zero.

.. % Patch 1507
* Changes to the :class:`Exception` interface
as dictated by :pep:`352` continue to be made. For 2.6,
the :attr:`message` attribute is being deprecated in favor of the
:attr:`args` attribute.

* The :exc:`GeneratorExit` exception now subclasses
:exc:`BaseException` instead of :exc:`Exception`. This means
that an exception handler that does ``except Exception:``
will not inadvertently catch :exc:`GeneratorExit`.
(Contributed by Chad Austin.)

.. % Patch #1537
* The :func:`compile` built-in function now accepts keyword arguments
as well as positional parameters. (Contributed by Thomas Wouters.)

Expand Down Expand Up @@ -653,6 +761,20 @@ complete list of changes, or look through the CVS logs for all the details.

.. % Patch #1490190
* The :mod:`new` module has been removed from Python 3.0.
Importing it therefore
triggers a warning message when Python is running in 3.0-warning
mode.

* New functions in the :mod:`os` module include
``fchmod(fd, mode)``, ``fchown(fd, uid, gid)``,
and ``lchmod(path, mode)``, on operating systems that support these
functions. :func:`fchmod` and :func:`fchown` let you change the mode
and ownership of an opened file, and :func:`lchmod` changes the mode
of a symlink.

(Contributed by Georg Brandl and Christian Heimes.)

* The :func:`os.walk` function now has a ``followlinks`` parameter. If
set to True, it will follow symlinks pointing to directories and
visit the directory's contents. For backward compatibility, the
Expand Down Expand Up @@ -703,6 +825,15 @@ complete list of changes, or look through the CVS logs for all the details.
changed and :const:`UF_APPEND` to indicate that data can only be appended to the
file. (Contributed by M. Levinson.)

* The :mod:`random` module's :class:`Random` objects can
now be pickled on a 32-bit system and unpickled on a 64-bit
system, and vice versa. Unfortunately, this change also means
that Python 2.6's :class:`Random` objects can't be unpickled correctly
on earlier versions of Python.
(Contributed by Shawn Ligocki.)

.. % Issue 1727780
* The :mod:`rgbimg` module has been removed.

* The :mod:`sets` module has been deprecated; it's better to
Expand All @@ -725,6 +856,17 @@ complete list of changes, or look through the CVS logs for all the details.

.. % Patch #957003
* A new variable in the :mod:`sys` module,
:attr:`float_info`, is a dictionary
containing information about the platform's floating-point support
derived from the :file:`float.h` file. Key/value pairs
in this dictionary include
``"mant_dig"`` (number of digits in the mantissa), ``"epsilon"``
(smallest difference between 1.0 and the next largest value
representable), and several others. (Contributed by Christian Heimes.)

.. % Patch 1534
* The :mod:`tarfile` module now supports POSIX.1-2001 (pax) and
POSIX.1-1988 (ustar) format tarfiles, in addition to the GNU tar
format that was already supported. The default format
Expand Down Expand Up @@ -883,6 +1025,17 @@ Changes to Python's build process and to the C API include:

.. % Patch 1551895
* Several functions return information about the platform's
floating-point support. :cfunc:`PyFloat_GetMax` returns
the maximum representable floating point value,
and :cfunc:`PyFloat_GetMin` returns the minimum
positive value. :cfunc:`PyFloat_GetInfo` returns a dictionary
containing more information from the :file:`float.h` file, such as
``"mant_dig"`` (number of digits in the mantissa), ``"epsilon"``
(smallest difference between 1.0 and the next largest value
representable), and several others.

.. % Issue 1534
.. % ======================================================================
Expand Down
2 changes: 1 addition & 1 deletion Include/abstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
*/

#define PySequence_ITEM(o, i)\
( Py_Type(o)->tp_as_sequence->sq_item(o, i) )
( Py_TYPE(o)->tp_as_sequence->sq_item(o, i) )
/* Assume tp_as_sequence and sq_item exist and that i does not
need to be corrected for a negative index
*/
Expand Down
2 changes: 1 addition & 1 deletion Include/boolobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extern "C" {

PyAPI_DATA(PyTypeObject) PyBool_Type;

#define PyBool_Check(x) (Py_Type(x) == &PyBool_Type)
#define PyBool_Check(x) (Py_TYPE(x) == &PyBool_Type)

/* Py_False and Py_True are the only two bools in existence.
Don't forget to apply Py_INCREF() when returning either!!! */
Expand Down
4 changes: 2 additions & 2 deletions Include/bytesobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ PyAPI_DATA(PyTypeObject) PyBytesIter_Type;

/* Type check macros */
#define PyBytes_Check(self) PyObject_TypeCheck(self, &PyBytes_Type)
#define PyBytes_CheckExact(self) (Py_Type(self) == &PyBytes_Type)
#define PyBytes_CheckExact(self) (Py_TYPE(self) == &PyBytes_Type)

/* Direct API functions */
PyAPI_FUNC(PyObject *) PyBytes_FromObject(PyObject *);
Expand All @@ -45,7 +45,7 @@ PyAPI_FUNC(int) PyBytes_Resize(PyObject *, Py_ssize_t);

/* Macros, trading safety for speed */
#define PyBytes_AS_STRING(self) (assert(PyBytes_Check(self)),((PyBytesObject *)(self))->ob_bytes)
#define PyBytes_GET_SIZE(self) (assert(PyBytes_Check(self)),Py_Size(self))
#define PyBytes_GET_SIZE(self) (assert(PyBytes_Check(self)),Py_SIZE(self))

#ifdef __cplusplus
}
Expand Down
4 changes: 2 additions & 2 deletions Include/cStringIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ static struct PycStringIO_CAPI {

/* These can be used to test if you have one */
#define PycStringIO_InputCheck(O) \
(Py_Type(O)==PycStringIO->InputType)
(Py_TYPE(O)==PycStringIO->InputType)
#define PycStringIO_OutputCheck(O) \
(Py_Type(O)==PycStringIO->OutputType)
(Py_TYPE(O)==PycStringIO->OutputType)

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion Include/cellobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ typedef struct {

PyAPI_DATA(PyTypeObject) PyCell_Type;

#define PyCell_Check(op) (Py_Type(op) == &PyCell_Type)
#define PyCell_Check(op) (Py_TYPE(op) == &PyCell_Type)

PyAPI_FUNC(PyObject *) PyCell_New(PyObject *);
PyAPI_FUNC(PyObject *) PyCell_Get(PyObject *);
Expand Down
2 changes: 1 addition & 1 deletion Include/cobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extern "C" {

PyAPI_DATA(PyTypeObject) PyCObject_Type;

#define PyCObject_Check(op) (Py_Type(op) == &PyCObject_Type)
#define PyCObject_Check(op) (Py_TYPE(op) == &PyCObject_Type)

/* Create a PyCObject from a pointer to a C object and an optional
destructor function. If the second argument is non-null, then it
Expand Down
4 changes: 2 additions & 2 deletions Include/code.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ typedef struct {

PyAPI_DATA(PyTypeObject) PyCode_Type;

#define PyCode_Check(op) (Py_Type(op) == &PyCode_Type)
#define PyCode_Check(op) (Py_TYPE(op) == &PyCode_Type)
#define PyCode_GetNumFree(op) (PyTuple_GET_SIZE((op)->co_freevars))

/* Public interface */
Expand All @@ -72,7 +72,7 @@ PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int);

/* for internal use only */
#define _PyCode_GETCODEPTR(co, pp) \
((*Py_Type((co)->co_code)->tp_as_buffer->bf_getreadbuffer) \
((*Py_TYPE((co)->co_code)->tp_as_buffer->bf_getreadbuffer) \
((co)->co_code, 0, (void **)(pp)))

typedef struct _addr_pair {
Expand Down
2 changes: 1 addition & 1 deletion Include/complexobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ typedef struct {
PyAPI_DATA(PyTypeObject) PyComplex_Type;

#define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type)
#define PyComplex_CheckExact(op) (Py_Type(op) == &PyComplex_Type)
#define PyComplex_CheckExact(op) (Py_TYPE(op) == &PyComplex_Type)

PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex);
PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag);
Expand Down
20 changes: 10 additions & 10 deletions Include/datetime.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,19 +166,19 @@ typedef struct {

/* Macros for type checking when building the Python core. */
#define PyDate_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateType)
#define PyDate_CheckExact(op) (Py_Type(op) == &PyDateTime_DateType)
#define PyDate_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DateType)

#define PyDateTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateTimeType)
#define PyDateTime_CheckExact(op) (Py_Type(op) == &PyDateTime_DateTimeType)
#define PyDateTime_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DateTimeType)

#define PyTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_TimeType)
#define PyTime_CheckExact(op) (Py_Type(op) == &PyDateTime_TimeType)
#define PyTime_CheckExact(op) (Py_TYPE(op) == &PyDateTime_TimeType)

#define PyDelta_Check(op) PyObject_TypeCheck(op, &PyDateTime_DeltaType)
#define PyDelta_CheckExact(op) (Py_Type(op) == &PyDateTime_DeltaType)
#define PyDelta_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DeltaType)

#define PyTZInfo_Check(op) PyObject_TypeCheck(op, &PyDateTime_TZInfoType)
#define PyTZInfo_CheckExact(op) (Py_Type(op) == &PyDateTime_TZInfoType)
#define PyTZInfo_CheckExact(op) (Py_TYPE(op) == &PyDateTime_TZInfoType)

#else

Expand All @@ -198,19 +198,19 @@ static PyDateTime_CAPI *PyDateTimeAPI;

/* Macros for type checking when not building the Python core. */
#define PyDate_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateType)
#define PyDate_CheckExact(op) (Py_Type(op) == PyDateTimeAPI->DateType)
#define PyDate_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DateType)

#define PyDateTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateTimeType)
#define PyDateTime_CheckExact(op) (Py_Type(op) == PyDateTimeAPI->DateTimeType)
#define PyDateTime_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DateTimeType)

#define PyTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TimeType)
#define PyTime_CheckExact(op) (Py_Type(op) == PyDateTimeAPI->TimeType)
#define PyTime_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->TimeType)

#define PyDelta_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DeltaType)
#define PyDelta_CheckExact(op) (Py_Type(op) == PyDateTimeAPI->DeltaType)
#define PyDelta_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DeltaType)

#define PyTZInfo_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TZInfoType)
#define PyTZInfo_CheckExact(op) (Py_Type(op) == PyDateTimeAPI->TZInfoType)
#define PyTZInfo_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->TZInfoType)

/* Macros for accessing constructors in a simplified fashion. */
#define PyDate_FromDate(year, month, day) \
Expand Down
2 changes: 1 addition & 1 deletion Include/descrobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *,
struct PyGetSetDef *);
PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *,
struct wrapperbase *, void *);
#define PyDescr_IsData(d) (Py_Type(d)->tp_descr_set != NULL)
#define PyDescr_IsData(d) (Py_TYPE(d)->tp_descr_set != NULL)

PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *);
PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *);
Expand Down
Loading

0 comments on commit 90aa764

Please sign in to comment.