Skip to content

Commit 90aa764

Browse files
committed
python#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
1 parent 99170a5 commit 90aa764

File tree

144 files changed

+1306
-1153
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+1306
-1153
lines changed

Doc/whatsnew/2.6.rst

Lines changed: 157 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ new feature.
7272
Python 3.0
7373
================
7474

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

100100
.. seealso::
101101

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

106+
107+
Development Changes
108+
==================================================
109+
110+
While 2.6 was being developed, the Python development process
111+
underwent two significant changes: the developer group
112+
switched from SourceForge's issue tracker to a customized
113+
Roundup installation, and the documentation was converted from
114+
LaTeX to reStructured Text.
115+
116+
117+
New Issue Tracker: Roundup
118+
--------------------------------------------------
119+
120+
XXX write this.
121+
122+
123+
New Documentation Format: ReStructured Text
124+
--------------------------------------------------
125+
126+
Python's documentation had been written using LaTeX since the
127+
project's inception around 1989. At that time, most documentation was
128+
printed out for later study, not viewed online. LaTeX was widely used
129+
because it provided attractive printed output while
130+
remaining straightforward to write, once the basic rules
131+
of the markup have been learned.
132+
133+
LaTeX is still used today for writing technical publications destined
134+
for printing, but the landscape for programming tools has shifted. We
135+
no longer print out reams of documentation; instead, we browse through
136+
it online and HTML is the most important format to support.
137+
Unfortunately, converting LaTeX to HTML is fairly complicated, and
138+
Fred L. Drake Jr., the Python documentation editor for many years,
139+
spent a lot of time wrestling the conversion process into shape.
140+
Occasionally people would suggest converting the documentation into
141+
SGML or, later, XML, but performing a good conversion is a major task
142+
and no one pursued the task to completion.
143+
144+
During the 2.6 development cycle, Georg Brandl put a substantial
145+
effort into building a new toolchain called Sphinx
146+
for processing the documentation.
147+
The input format is reStructured Text,
148+
a markup commonly used in the Python community that supports
149+
custom extensions and directives. Sphinx concentrates
150+
on its HTML output, producing attractively styled
151+
and modern HTML. (XXX finish this -- mention new search feature)
152+
153+
.. seealso::
154+
155+
`Docutils <http://docutils.sf.net>`__: The fundamental
156+
reStructured Text parser and toolset.
157+
158+
`Documenting Python <XXX>`__: Describes how to write for
159+
Python's documentation.
160+
161+
106162
PEP 343: The 'with' statement
107163
=============================
108164

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

353409
.. % ======================================================================
354410
411+
.. _pep-0366:
412+
413+
PEP 366: Explicit Relative Imports From a Main Module
414+
============================================================
415+
416+
Python's :option:`-m` switch allows running a module as a script.
417+
When you ran a module that was located inside a package, relative
418+
imports didn't work correctly.
419+
420+
The fix in Python 2.6 adds a :attr:`__package__` attribute to modules.
421+
When present, relative imports will be relative to the value of this
422+
attribute instead of the :attr:`__name__` attribute. PEP 302-style
423+
importers can then set :attr:`__package__`. The :mod:`runpy` module
424+
that implements the :option:`-m` switch now does this, so relative imports
425+
can now be used in scripts running from inside a package.
426+
427+
.. % ======================================================================
428+
355429
.. _pep-3110:
356430

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

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

444518
.. % Revision 57619
445519
520+
* Properties now have two attributes,
521+
:attr:`setter` and :attr:`deleter`, that are useful shortcuts for
522+
adding a setter or deleter function to an existing property.
523+
You would use them like this::
524+
525+
class C(object):
526+
@property
527+
def x(self):
528+
return self._x
529+
530+
@x.setter
531+
def x(self, value):
532+
self._x = value
533+
534+
@x.deleter
535+
def x(self):
536+
del self._x
537+
538+
446539
* C functions and methods that use
447540
:cfunc:`PyComplex_AsCComplex` will now accept arguments that
448541
have a :meth:`__complex__` method. In particular, the functions in the
@@ -452,11 +545,26 @@ Here are all of the changes that Python 2.6 makes to the core Python language.
452545

453546
.. % Patch #1675423
454547
548+
A numerical nicety: when creating a complex number from two floats
549+
on systems that support signed zeros (-0 and +0), the
550+
:func:`complex()` constructor will now preserve the sign
551+
of the zero.
552+
553+
.. % Patch 1507
554+
455555
* Changes to the :class:`Exception` interface
456556
as dictated by :pep:`352` continue to be made. For 2.6,
457557
the :attr:`message` attribute is being deprecated in favor of the
458558
:attr:`args` attribute.
459559

560+
* The :exc:`GeneratorExit` exception now subclasses
561+
:exc:`BaseException` instead of :exc:`Exception`. This means
562+
that an exception handler that does ``except Exception:``
563+
will not inadvertently catch :exc:`GeneratorExit`.
564+
(Contributed by Chad Austin.)
565+
566+
.. % Patch #1537
567+
460568
* The :func:`compile` built-in function now accepts keyword arguments
461569
as well as positional parameters. (Contributed by Thomas Wouters.)
462570

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

654762
.. % Patch #1490190
655763
764+
* The :mod:`new` module has been removed from Python 3.0.
765+
Importing it therefore
766+
triggers a warning message when Python is running in 3.0-warning
767+
mode.
768+
769+
* New functions in the :mod:`os` module include
770+
``fchmod(fd, mode)``, ``fchown(fd, uid, gid)``,
771+
and ``lchmod(path, mode)``, on operating systems that support these
772+
functions. :func:`fchmod` and :func:`fchown` let you change the mode
773+
and ownership of an opened file, and :func:`lchmod` changes the mode
774+
of a symlink.
775+
776+
(Contributed by Georg Brandl and Christian Heimes.)
777+
656778
* The :func:`os.walk` function now has a ``followlinks`` parameter. If
657779
set to True, it will follow symlinks pointing to directories and
658780
visit the directory's contents. For backward compatibility, the
@@ -703,6 +825,15 @@ complete list of changes, or look through the CVS logs for all the details.
703825
changed and :const:`UF_APPEND` to indicate that data can only be appended to the
704826
file. (Contributed by M. Levinson.)
705827

828+
* The :mod:`random` module's :class:`Random` objects can
829+
now be pickled on a 32-bit system and unpickled on a 64-bit
830+
system, and vice versa. Unfortunately, this change also means
831+
that Python 2.6's :class:`Random` objects can't be unpickled correctly
832+
on earlier versions of Python.
833+
(Contributed by Shawn Ligocki.)
834+
835+
.. % Issue 1727780
836+
706837
* The :mod:`rgbimg` module has been removed.
707838

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

726857
.. % Patch #957003
727858
859+
* A new variable in the :mod:`sys` module,
860+
:attr:`float_info`, is a dictionary
861+
containing information about the platform's floating-point support
862+
derived from the :file:`float.h` file. Key/value pairs
863+
in this dictionary include
864+
``"mant_dig"`` (number of digits in the mantissa), ``"epsilon"``
865+
(smallest difference between 1.0 and the next largest value
866+
representable), and several others. (Contributed by Christian Heimes.)
867+
868+
.. % Patch 1534
869+
728870
* The :mod:`tarfile` module now supports POSIX.1-2001 (pax) and
729871
POSIX.1-1988 (ustar) format tarfiles, in addition to the GNU tar
730872
format that was already supported. The default format
@@ -883,6 +1025,17 @@ Changes to Python's build process and to the C API include:
8831025

8841026
.. % Patch 1551895
8851027
1028+
* Several functions return information about the platform's
1029+
floating-point support. :cfunc:`PyFloat_GetMax` returns
1030+
the maximum representable floating point value,
1031+
and :cfunc:`PyFloat_GetMin` returns the minimum
1032+
positive value. :cfunc:`PyFloat_GetInfo` returns a dictionary
1033+
containing more information from the :file:`float.h` file, such as
1034+
``"mant_dig"`` (number of digits in the mantissa), ``"epsilon"``
1035+
(smallest difference between 1.0 and the next largest value
1036+
representable), and several others.
1037+
1038+
.. % Issue 1534
8861039
8871040
.. % ======================================================================
8881041

Include/abstract.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
10701070
*/
10711071

10721072
#define PySequence_ITEM(o, i)\
1073-
( Py_Type(o)->tp_as_sequence->sq_item(o, i) )
1073+
( Py_TYPE(o)->tp_as_sequence->sq_item(o, i) )
10741074
/* Assume tp_as_sequence and sq_item exist and that i does not
10751075
need to be corrected for a negative index
10761076
*/

Include/boolobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ extern "C" {
99

1010
PyAPI_DATA(PyTypeObject) PyBool_Type;
1111

12-
#define PyBool_Check(x) (Py_Type(x) == &PyBool_Type)
12+
#define PyBool_Check(x) (Py_TYPE(x) == &PyBool_Type)
1313

1414
/* Py_False and Py_True are the only two bools in existence.
1515
Don't forget to apply Py_INCREF() when returning either!!! */

Include/bytesobject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ PyAPI_DATA(PyTypeObject) PyBytesIter_Type;
3333

3434
/* Type check macros */
3535
#define PyBytes_Check(self) PyObject_TypeCheck(self, &PyBytes_Type)
36-
#define PyBytes_CheckExact(self) (Py_Type(self) == &PyBytes_Type)
36+
#define PyBytes_CheckExact(self) (Py_TYPE(self) == &PyBytes_Type)
3737

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

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

5050
#ifdef __cplusplus
5151
}

Include/cStringIO.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ static struct PycStringIO_CAPI {
6060

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

6767
#ifdef __cplusplus
6868
}

Include/cellobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ typedef struct {
1313

1414
PyAPI_DATA(PyTypeObject) PyCell_Type;
1515

16-
#define PyCell_Check(op) (Py_Type(op) == &PyCell_Type)
16+
#define PyCell_Check(op) (Py_TYPE(op) == &PyCell_Type)
1717

1818
PyAPI_FUNC(PyObject *) PyCell_New(PyObject *);
1919
PyAPI_FUNC(PyObject *) PyCell_Get(PyObject *);

Include/cobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ extern "C" {
1616

1717
PyAPI_DATA(PyTypeObject) PyCObject_Type;
1818

19-
#define PyCObject_Check(op) (Py_Type(op) == &PyCObject_Type)
19+
#define PyCObject_Check(op) (Py_TYPE(op) == &PyCObject_Type)
2020

2121
/* Create a PyCObject from a pointer to a C object and an optional
2222
destructor function. If the second argument is non-null, then it

Include/code.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ typedef struct {
5959

6060
PyAPI_DATA(PyTypeObject) PyCode_Type;
6161

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

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

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

7878
typedef struct _addr_pair {

Include/complexobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ typedef struct {
4343
PyAPI_DATA(PyTypeObject) PyComplex_Type;
4444

4545
#define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type)
46-
#define PyComplex_CheckExact(op) (Py_Type(op) == &PyComplex_Type)
46+
#define PyComplex_CheckExact(op) (Py_TYPE(op) == &PyComplex_Type)
4747

4848
PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex);
4949
PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag);

Include/datetime.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,19 +166,19 @@ typedef struct {
166166

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

171171
#define PyDateTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateTimeType)
172-
#define PyDateTime_CheckExact(op) (Py_Type(op) == &PyDateTime_DateTimeType)
172+
#define PyDateTime_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DateTimeType)
173173

174174
#define PyTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_TimeType)
175-
#define PyTime_CheckExact(op) (Py_Type(op) == &PyDateTime_TimeType)
175+
#define PyTime_CheckExact(op) (Py_TYPE(op) == &PyDateTime_TimeType)
176176

177177
#define PyDelta_Check(op) PyObject_TypeCheck(op, &PyDateTime_DeltaType)
178-
#define PyDelta_CheckExact(op) (Py_Type(op) == &PyDateTime_DeltaType)
178+
#define PyDelta_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DeltaType)
179179

180180
#define PyTZInfo_Check(op) PyObject_TypeCheck(op, &PyDateTime_TZInfoType)
181-
#define PyTZInfo_CheckExact(op) (Py_Type(op) == &PyDateTime_TZInfoType)
181+
#define PyTZInfo_CheckExact(op) (Py_TYPE(op) == &PyDateTime_TZInfoType)
182182

183183
#else
184184

@@ -198,19 +198,19 @@ static PyDateTime_CAPI *PyDateTimeAPI;
198198

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

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

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

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

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

215215
/* Macros for accessing constructors in a simplified fashion. */
216216
#define PyDate_FromDate(year, month, day) \

0 commit comments

Comments
 (0)