Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2a241ca

Browse files
committed
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62055-62058,62060-62066,62068-62074,62076-62079,62081-62083,62086-62089,62092-62094,62098,62101,62104,62106-62109,62115-62122,62124-62125,62128,62130,62132,62134-62135,62137,62139-62140,62144,62146,62151,62155,62157,62162-62174 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r62167 | martin.v.loewis | 2008-04-05 17:45:25 +0200 (Sa, 05 Apr 2008) | 1 line Extend sizes of various fields, to support the CRT90 merge module. ........ r62168 | martin.v.loewis | 2008-04-05 17:48:36 +0200 (Sa, 05 Apr 2008) | 1 line Add two features to distinguish between private and SxS CRT. ........ r62169 | martin.v.loewis | 2008-04-05 17:50:58 +0200 (Sa, 05 Apr 2008) | 1 line Add script to merge msvcr90. ........ r62170 | andrew.kuchling | 2008-04-05 17:57:46 +0200 (Sa, 05 Apr 2008) | 1 line Markup fixes; write PEP 3118 section ........ r62173 | georg.brandl | 2008-04-05 19:45:58 +0200 (Sa, 05 Apr 2008) | 2 lines Mention that the tuple returned by __reduce__ is pickled as normal. ........ r62174 | andrew.kuchling | 2008-04-05 20:15:30 +0200 (Sa, 05 Apr 2008) | 1 line Write PEP 3119 section ........
1 parent 2a03373 commit 2a241ca

5 files changed

Lines changed: 319 additions & 99 deletions

File tree

Doc/library/pickle.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,9 @@ local name relative to its module; the pickle module searches the module
468468
namespace to determine the object's module.
469469

470470
When a tuple is returned, it must be between two and five elements long.
471-
Optional elements can either be omitted, or ``None`` can be provided as their
472-
value. The semantics of each element are:
471+
Optional elements can either be omitted, or ``None`` can be provided as their
472+
value. The contents of this tuple are pickled as normal and used to
473+
reconstruct the object at unpickling time. The semantics of each element are:
473474

474475
* A callable object that will be called to create the initial version of the
475476
object. The next element of the tuple will provide arguments for this callable,

Doc/whatsnew/2.6.rst

Lines changed: 180 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,18 @@ http://svn.python.org/view/tracker/importer/.
156156

157157
.. seealso::
158158

159-
http://bugs.python.org: The Python bug tracker.
159+
http://bugs.python.org
160+
The Python bug tracker.
160161

161-
http://bugs.jython.org: The Jython bug tracker.
162+
http://bugs.jython.org:
163+
The Jython bug tracker.
162164

163-
http://roundup.sourceforge.net/: Roundup downloads and documentation.
165+
http://roundup.sourceforge.net/
166+
Roundup downloads and documentation.
164167

165168

166-
New Documentation Format: ReStructured Text
167-
--------------------------------------------------
169+
New Documentation Format: ReStructured Text Using Sphinx
170+
-----------------------------------------------------------
168171

169172
Since the Python project's inception around 1989, the documentation
170173
had been written using LaTeX. At that time, most documentation was
@@ -191,16 +194,20 @@ The input format is reStructured Text,
191194
a markup commonly used in the Python community that supports
192195
custom extensions and directives. Sphinx concentrates
193196
on HTML output, producing attractively styled
194-
and modern HTML, but printed output is still supported through
195-
conversion to LaTeX as an output format.
197+
and modern HTML, though printed output is still supported through
198+
conversion to LaTeX. Sphinx is a standalone package that
199+
can be used in documenting other projects.
196200

197201
.. seealso::
198202

199-
`Docutils <http://docutils.sf.net>`__: The fundamental
200-
reStructured Text parser and toolset.
203+
:ref:`documenting-index`
204+
Describes how to write for Python's documentation.
205+
206+
`Sphinx <http://sphinx.pocoo.org/>`__
207+
Documentation and code for the Sphinx toolchain.
201208

202-
:ref:`documenting-index`: Describes how to write for
203-
Python's documentation.
209+
`Docutils <http://docutils.sf.net>`__
210+
The underlying reStructured Text parser and toolset.
204211

205212

206213
PEP 343: The 'with' statement
@@ -487,8 +494,7 @@ can now be used in scripts running from inside a package.
487494
.. seealso::
488495

489496
:pep:`370` - XXX
490-
491-
PEP written by XXX; implemented by Christian Heimes.
497+
PEP written by XXX; implemented by Christian Heimes.
492498

493499
494500
.. ======================================================================
@@ -633,9 +639,8 @@ PEP 3105: ``print`` As a Function
633639
=====================================================
634640

635641
The ``print`` statement becomes the :func:`print` function in Python 3.0.
636-
Making :func:`print` a function makes it easier to replace within a
637-
module by doing 'def print(...)' or importing a new
638-
function from somewhere else.
642+
Making :func:`print` a function makes it easier to change
643+
by doing 'def print(...)' or importing a new function from somewhere else.
639644

640645
Python 2.6 has a ``__future__`` import that removes ``print`` as language
641646
syntax, letting you use the functional form instead. For example::
@@ -750,13 +755,50 @@ XXX write this.
750755
PEP 3118: Revised Buffer Protocol
751756
=====================================================
752757

753-
The buffer protocol is a C-level API that lets Python extensions
754-
XXX
758+
The buffer protocol is a C-level API that lets Python types
759+
exchange pointers into their internal representations. A
760+
memory-mapped file can be viewed as a buffer of characters, for
761+
example, and this lets another module such as :mod:`re`
762+
treat memory-mapped files as a string of characters to be searched.
763+
764+
The primary users of the buffer protocol are numeric-processing
765+
packages such as NumPy, which can expose the internal representation
766+
of arrays so that callers can write data directly into an array instead
767+
of going through a slower API. This PEP updates the buffer protocol in light of experience
768+
from NumPy development, adding a number of new features
769+
such as indicating the shape of an array,
770+
locking memory .
771+
772+
The most important new C API function is
773+
``PyObject_GetBuffer(PyObject *obj, Py_buffer *view, int flags)``, which
774+
takes an object and a set of flags, and fills in the
775+
``Py_buffer`` structure with information
776+
about the object's memory representation. Objects
777+
can use this operation to lock memory in place
778+
while an external caller could be modifying the contents,
779+
so there's a corresponding
780+
``PyObject_ReleaseBuffer(PyObject *obj, Py_buffer *view)`` to
781+
indicate that the external caller is done.
782+
783+
The **flags** argument to :cfunc:`PyObject_GetBuffer` specifies
784+
constraints upon the memory returned. Some examples are:
785+
786+
* :const:`PyBUF_WRITABLE` indicates that the memory must be writable.
787+
788+
* :const:`PyBUF_LOCK` requests a read-only or exclusive lock on the memory.
789+
790+
* :const:`PyBUF_C_CONTIGUOUS` and :const:`PyBUF_F_CONTIGUOUS`
791+
requests a C-contiguous (last dimension varies the fastest) or
792+
Fortran-contiguous (first dimension varies the fastest) layout.
793+
794+
.. XXX this feature is not in 2.6 docs yet
755795
756796
.. seealso::
757797

758798
:pep:`3118` - Revising the buffer protocol
759-
PEP written by Travis Oliphant and Carl Banks.
799+
PEP written by Travis Oliphant and Carl Banks; implemented by
800+
Travis Oliphant.
801+
760802

761803
.. ======================================================================
762804
@@ -765,41 +807,142 @@ XXX
765807
PEP 3119: Abstract Base Classes
766808
=====================================================
767809

768-
XXX write this -- this section is currently just brief notes.
810+
Some object-oriented languages such as Java support interfaces: declarations
811+
that a class has a given set of methods or supports a given access protocol.
812+
Abstract Base Classes (or ABCs) are an equivalent feature for Python. The ABC
813+
support consists of an :mod:`abc` module containing a metaclass called
814+
:class:`ABCMeta`, special handling
815+
of this metaclass by the :func:`isinstance` and :func:`issubclass` built-ins,
816+
and a collection of basic ABCs that the Python developers think will be widely
817+
useful.
818+
819+
Let's say you have a particular class and wish to know whether it supports
820+
dictionary-style access. The phrase "dictionary-style" is vague, however.
821+
It probably means that accessing items with ``obj[1]`` works.
822+
Does it imply that setting items with ``obj[2] = value`` works?
823+
Or that the object will have :meth:`keys`, :meth:`values`, and :meth:`items`
824+
methods? What about the iterative variants such as :meth:`iterkeys`? :meth:`copy`
825+
and :meth:`update`? Iterating over the object with :func:`iter`?
826+
827+
Python 2.6 includes a number of different ABCs in the :mod:`collections`
828+
module. :class:`Iterable` indicates that a class defines :meth:`__iter__`,
829+
and :class:`Container` means the class supports ``x in y`` expressions
830+
by defining a :meth:`__contains__` method. The basic dictionary interface of
831+
getting items, setting items, and
832+
:meth:`keys`, :meth:`values`, and :meth:`items`, is defined by the
833+
:class:`MutableMapping` ABC.
834+
835+
You can derive your own classes from a particular ABC
836+
to indicate they support that ABC's interface::
837+
838+
import collections
839+
840+
class Storage(collections.MutableMapping):
841+
...
769842

770-
How to identify a file object?
771843

772-
ABCs are a collection of classes describing various interfaces.
773-
Classes can derive from an ABC to indicate they support that ABC's
774-
interface. Concrete classes should obey the semantics specified by
775-
an ABC, but Python can't check this; it's up to the implementor.
844+
Alternatively, you could write the class without deriving from
845+
the desired ABC and instead register the class by
846+
calling the ABC's :meth:`register` method::
776847

777-
A metaclass lets you declare that an existing class or type
778-
derives from a particular ABC. You can even
848+
import collections
849+
850+
class Storage:
851+
...
852+
853+
collections.MutableMapping.register(Storage)
854+
855+
For classes that you write, deriving from the ABC is probably clearer.
856+
The :meth:`register` method is useful when you've written a new
857+
ABC that can describe an existing type or class, or if you want
858+
to declare that some third-party class implements an ABC.
859+
For example, if you defined a :class:`PrintableType` ABC,
860+
it's legal to do:
861+
862+
# Register Python's types
863+
PrintableType.register(int)
864+
PrintableType.register(float)
865+
PrintableType.register(str)
866+
867+
Classes should obey the semantics specified by an ABC, but
868+
Python can't check this; it's up to the class author to
869+
understand the ABC's requirements and to implement the code accordingly.
870+
871+
To check whether an object supports a particular interface, you can
872+
now write::
873+
874+
def func(d):
875+
if not isinstance(d, collections.MutableMapping):
876+
raise ValueError("Mapping object expected, not %r" % d)
877+
878+
(Don't feel that you must now begin writing lots of checks as in the
879+
above example. Python has a strong tradition of duck-typing, where
880+
explicit type-checking isn't done and code simply calls methods on
881+
an object, trusting that those methods will be there and raising an
882+
exception if they aren't. Be judicious in checking for ABCs
883+
and only do it where it helps.)
884+
885+
You can write your own ABCs by using ``abc.ABCMeta`` as the
886+
metaclass in a class definition::
887+
888+
from abc import ABCMeta
889+
890+
class Drawable():
891+
__metaclass__ = ABCMeta
892+
893+
def draw(self, x, y, scale=1.0):
894+
pass
779895

780-
class AppendableSequence:
781-
__metaclass__ = ABCMeta
896+
def draw_doubled(self, x, y):
897+
self.draw(x, y, scale=2.0)
782898

783-
AppendableSequence.register(list)
784-
assert issubclass(list, AppendableSequence)
785-
assert isinstance([], AppendableSequence)
899+
900+
class Square(Drawable):
901+
def draw(self, x, y, scale):
902+
...
786903

787-
@abstractmethod decorator -- you can't instantiate classes w/
788-
an abstract method.
904+
905+
In the :class:`Drawable` ABC above, the :meth:`draw_doubled` method
906+
renders the object at twice its size and can be implemented in terms
907+
of other methods described in :class:`Drawable`. Classes implementing
908+
this ABC therefore don't need to provide their own implementation
909+
of :meth:`draw_doubled`, though they can do so. An implementation
910+
of :meth:`draw` is necessary, though; the ABC can't provide
911+
a useful generic implementation. You
912+
can apply the ``@abstractmethod`` decorator to methods such as
913+
:meth:`draw` that must be implemented; Python will
914+
then raise an exception for classes that
915+
don't define the method::
916+
917+
class Drawable():
918+
__metaclass__ = ABCMeta
919+
920+
@abstractmethod
921+
def draw(self, x, y, scale):
922+
pass
923+
924+
Note that the exception is only raised when you actually
925+
try to create an instance of a subclass without the method::
926+
927+
>>> s=Square()
928+
Traceback (most recent call last):
929+
File "<stdin>", line 1, in <module>
930+
TypeError: Can't instantiate abstract class Square with abstract methods draw
931+
>>>
789932

790-
::
933+
Abstract data attributes can be declared using the ``@abstractproperty`` decorator::
791934

792-
@abstractproperty decorator
793935
@abstractproperty
794936
def readonly(self):
795937
return self._x
796938

939+
Subclasses must then define a :meth:`readonly` property
797940

798941
.. seealso::
799942

800943
:pep:`3119` - Introducing Abstract Base Classes
801944
PEP written by Guido van Rossum and Talin.
802-
Implemented by XXX.
945+
Implemented by Guido van Rossum.
803946
Backported to 2.6 by Benjamin Aranguren, with Alex Martelli.
804947

805948
.. ======================================================================

Tools/msi/merge.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import msilib,os,win32com,tempfile
2+
PCBUILD="PCBuild"
3+
from config import *
4+
5+
Win64 = "amd64" in PCBUILD
6+
7+
mod_dir = os.path.join(os.environ["ProgramFiles"], "Common Files", "Merge Modules")
8+
if Win64:
9+
modules = ["Microsoft_VC90_CRT_x86.msm", "policy_8_0_Microsoft_VC80_CRT_x86_x64.msm"]
10+
msi = "python-%s.amd64.msi" % full_current_version
11+
else:
12+
modules = ["Microsoft_VC90_CRT_x86.msm","policy_8_0_Microsoft_VC80_CRT_x86.msm"]
13+
msi = "python-%s.msi" % full_current_version
14+
for i, n in enumerate(modules):
15+
modules[i] = os.path.join(mod_dir, n)
16+
17+
def merge(msi, feature, rootdir, modules):
18+
cab_and_filecount = []
19+
# Step 1: Merge databases, extract cabfiles
20+
m = msilib.MakeMerge2()
21+
m.OpenLog("merge.log")
22+
print "Opened Log"
23+
m.OpenDatabase(msi)
24+
print "Opened DB"
25+
for module in modules:
26+
print module
27+
m.OpenModule(module,0)
28+
print "Opened Module",module
29+
m.Merge(feature, rootdir)
30+
print "Errors:"
31+
for e in m.Errors:
32+
print e.Type, e.ModuleTable, e.DatabaseTable
33+
print " Modkeys:",
34+
for s in e.ModuleKeys: print s,
35+
print
36+
print " DBKeys:",
37+
for s in e.DatabaseKeys: print s,
38+
print
39+
cabname = tempfile.mktemp(suffix=".cab")
40+
m.ExtractCAB(cabname)
41+
cab_and_filecount.append((cabname, len(m.ModuleFiles)))
42+
m.CloseModule()
43+
m.CloseDatabase(True)
44+
m.CloseLog()
45+
46+
# Step 2: Add CAB files
47+
i = msilib.MakeInstaller()
48+
db = i.OpenDatabase(msi, win32com.client.constants.msiOpenDatabaseModeTransact)
49+
50+
v = db.OpenView("SELECT LastSequence FROM Media")
51+
v.Execute(None)
52+
maxmedia = -1
53+
while 1:
54+
r = v.Fetch()
55+
if not r: break
56+
seq = r.IntegerData(1)
57+
if seq > maxmedia:
58+
maxmedia = seq
59+
print "Start of Media", maxmedia
60+
61+
for cabname, count in cab_and_filecount:
62+
stream = "merged%d" % maxmedia
63+
msilib.add_data(db, "Media",
64+
[(maxmedia+1, maxmedia+count, None, "#"+stream, None, None)])
65+
msilib.add_stream(db, stream, cabname)
66+
os.unlink(cabname)
67+
maxmedia += count
68+
db.Commit()
69+
70+
merge(msi, "SharedCRT", "TARGETDIR", modules)

Tools/msi/msi.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,12 @@ def add_features(db):
799799
default_feature = Feature(db, "DefaultFeature", "Python",
800800
"Python Interpreter and Libraries",
801801
1, directory = "TARGETDIR")
802+
shared_crt = Feature(db, "SharedCRT", "MSVCRT", "C Run-Time (system-wide)", 0,
803+
level=0)
804+
private_crt = Feature(db, "PrivateCRT", "MSVCRT", "C Run-Time (private)", 0,
805+
level=0)
806+
add_data(db, "Condition", [("SharedCRT", 1, sys32cond),
807+
("PrivateCRT", 1, "not "+sys32cond)])
802808
# We don't support advertisement of extensions
803809
ext_feature = Feature(db, "Extensions", "Register Extensions",
804810
"Make this Python installation the default Python installation", 3,
@@ -899,7 +905,7 @@ def add_files(db):
899905
DLLs = PyDirectory(db, cab, root, srcdir + "/" + PCBUILD, "DLLs", "DLLS|DLLs")
900906
# XXX determine dependencies
901907
if MSVCR == "90":
902-
root.start_component("msvcr90")
908+
root.start_component("msvcr90", feature=private_crt)
903909
for file, kw in extract_msvcr90():
904910
root.add_file(file, **kw)
905911
if file.endswith("manifest"):

0 commit comments

Comments
 (0)