blob: 11b56ccd05407641d3448104ceb446b001462ba8 [file] [log] [blame]
Georg Brandl116aa622007-08-15 14:28:22 +00001****************************
2 What's New in Python 3.0
3****************************
4
Andrew M. Kuchlingbbb809e2007-09-01 19:26:28 +00005:Author: Guido van Rossum
Georg Brandl5a165582007-08-31 06:15:01 +00006:Release: 0.1
Georg Brandl116aa622007-08-15 14:28:22 +00007
Georg Brandl5a165582007-08-31 06:15:01 +00008.. Rules for maintenance:
9
10 * Anyone can add text to this document. Do not spend very much time
11 on the wording of your changes, because your text will probably
12 get rewritten to some degree.
13
14 * The maintainer will go through Misc/NEWS periodically and add
15 changes; it's therefore more important to add your changes to
16 Misc/NEWS than to this file.
17
18 * This is not a complete list of every single change; completeness
19 is the purpose of Misc/NEWS. Some changes I consider too small
20 or esoteric to include. If such a change is added to the text,
21 I'll just remove it. (This is another reason you shouldn't spend
22 too much time on writing your addition.)
23
24 * If you want to draw your new text to the attention of the
25 maintainer, add 'XXX' to the beginning of the paragraph or
26 section.
27
28 * It's OK to just add a fragmentary note about a change. For
29 example: "XXX Describe the transmogrify() function added to the
30 socket module." The maintainer will research the change and
31 write the necessary text.
32
33 * You can comment out your additions if you like, but it's not
34 necessary (especially when a final release is some months away).
35
36 * Credit the author of a patch or bugfix. Just the name is
37 sufficient; the e-mail address isn't necessary.
38
39 * It's helpful to add the bug/patch number as a comment:
40
41 % Patch 12345
42 XXX Describe the transmogrify() function added to the socket
43 module.
44 (Contributed by P.Y. Developer.)
45
46 This saves the maintainer the effort of going through the SVN log
47 when researching a change.
Georg Brandl116aa622007-08-15 14:28:22 +000048
Guido van Rossumb197f3c2007-08-31 00:37:00 +000049This article explains the new features in Python 3.0, comparing to 2.6
50(or in some cases 2.5, since 2.6 isn't released yet).
Georg Brandl116aa622007-08-15 14:28:22 +000051
Guido van Rossumb197f3c2007-08-31 00:37:00 +000052The best estimate for a release date is August 2008.
53
54This article doesn't attempt to provide a complete specification of
55the new features, but instead provides a convenient overview. For
56full details, you should refer to the documentation for Python 3.0. If
57you want to understand the complete implementation and design
58rationale, refer to the PEP for a particular new feature.
Georg Brandl116aa622007-08-15 14:28:22 +000059
Georg Brandl5a165582007-08-31 06:15:01 +000060.. Compare with previous release in 2 - 3 sentences here.
61.. add hyperlink when the documentation becomes available online.
Georg Brandl116aa622007-08-15 14:28:22 +000062
Georg Brandl5a165582007-08-31 06:15:01 +000063.. ======================================================================
64.. Large, PEP-level features and changes should be described here.
65.. Should there be a new section here for 3k migration?
66.. Or perhaps a more general section describing module changes/deprecation?
67.. sets module deprecated
68.. ======================================================================
Georg Brandl116aa622007-08-15 14:28:22 +000069
70
Guido van Rossumb197f3c2007-08-31 00:37:00 +000071Common Stumbling Blocks
72=======================
73
74This section briefly lists the changes that are more likely to trip
75people up, without necessarily raising obvious errors. These are all
76explained in more detail below. (I'm not listing syntactic changes
77and removed or renamed features here, since those tend to produce hard
78and fast errors; it's the subtle behavioral changes in code that
79remains syntactically valid that trips people up. I'm also omitting
80changes to rarely used features.)
81
Georg Brandlec17d202008-02-02 10:44:37 +000082* The ``print`` statement has been replaced with a :func:`print` function,
Guido van Rossumdff1c312007-09-06 14:46:41 +000083 with keyword arguments to replace most of the special syntax of the
84 old ``print`` statement (PEP 3105). Examples::
85
86 Old: print "The answer is", 2*2
87 New: print("The answer is", 2*2)
88
89 Old: print x, # Trailing comma suppresses newline
90 New: print(x, end=" ") # Appends a space instead of a newline
91
92 Old: print # Prints a newline
93 New: print() # You must call the function!
94
95 Old: print >>sys.stderr, "fatal error"
96 New: print("fatal error", file=sys.stderr)
97
98 Old: print (x, y) # prints repr((x, y))
99 New: print((x, y)) # Not the same as print(x, y)!
100
101 You can also customize the separator between items, e.g.::
102
103 print("There are <", 2**32, "> possibilities!", sep="")
104
105 which produces::
106
107 There are <4294967296> possibilities!
108
Georg Brandlec17d202008-02-02 10:44:37 +0000109 Notes about the :func:`print` function:
Guido van Rossumdff1c312007-09-06 14:46:41 +0000110
Georg Brandlec17d202008-02-02 10:44:37 +0000111 * The :func:`print` function doesn't support the "softspace" feature of
Guido van Rossumdff1c312007-09-06 14:46:41 +0000112 the old ``print`` statement. For example, in Python 2.x,
113 ``print "A\n", "B"`` would write ``"A\nB\n"``; but in Python 3.0,
114 ``print("A\n", "B")`` writes ``"A\n B\n"``.
115
116 * Initially, you'll be finding yourself typing the old ``print x``
117 a lot in interactive mode. Time to retrain your fingers to type
118 ``print(x)`` instead!
119
120 * When using the ``2to3`` source-to-source conversion tool, all
Georg Brandlec17d202008-02-02 10:44:37 +0000121 ``print`` statements are autmatically converted to :func:`print`
Guido van Rossumdff1c312007-09-06 14:46:41 +0000122 function calls, so this is mostly a non-issue for larger projects.
123
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000124* Python 3.0 uses strings and bytes instead of the Unicode strings and
125 8-bit strings. This means that pretty much all code that uses
126 Unicode, encodings or binary data in any way has to change. The
127 change is for the better, as in the 2.x world there were numerous
128 bugs having to do with mixing encoded and unencoded text.
129
130* Text files enforce an encoding; binary files use bytes. This means
131 that if a file is opened using an incorrect mode or encoding, I/O
132 will likely fail.
133
Georg Brandlec17d202008-02-02 10:44:37 +0000134* :func:`map` and :func:`filter` return iterators. A quick fix is e.g.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000135 ``list(map(...))``, but a better fix is often to use a list
Georg Brandlec17d202008-02-02 10:44:37 +0000136 comprehension (especially when the original code uses :keyword:`lambda`).
137 Particularly tricky is :func:`map` invoked for the side effects of the
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000138 function; the correct transformation is to use a for-loop.
139
Georg Brandlec17d202008-02-02 10:44:37 +0000140* :class:`dict` methods :meth:`dict.keys`, :meth:`dict.items` and
141 :meth:`dict.values` return views instead of lists. For example, this no
142 longer works: ``k = d.keys(); k.sort()``. Use ``k = sorted(d)`` instead.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000143
Kurt B. Kaiser2bc6b5e2008-02-13 18:03:11 +0000144* :meth:`builtin.sorted` and :meth:`list.sort` no longer accept the *cmp*
Kurt B. Kaiser9d0d6162008-02-14 02:47:50 +0000145 argument providing a comparison function. Use the *key* argument
Kurt B. Kaiser2bc6b5e2008-02-13 18:03:11 +0000146 instead. N.B. the *key* and *reverse* arguments are now "keyword-only".
Kurt B. Kaisera1401012008-02-13 16:09:27 +0000147
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000148* ``1/2`` returns a float. Use ``1//2`` to get the truncating behavior.
149
Georg Brandlec17d202008-02-02 10:44:37 +0000150* The :func:`repr` of a long integer doesn't include the trailing ``L``
Georg Brandlcc595bd2007-12-09 09:04:01 +0000151 anymore, so code that unconditionally strips that character will
152 chop off the last digit instead.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000153
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000154
155Strings and Bytes
156=================
157
Georg Brandlec17d202008-02-02 10:44:37 +0000158* There is only one string type; its name is :class:`str` but its behavior and
159 implementation are like :class:`unicode` in 2.x.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000160
Georg Brandlec17d202008-02-02 10:44:37 +0000161* The :class:`basestring` superclass has been removed. The ``2to3`` tool
162 replaces every occurence of :class:`basestring` with :class:`str`.
Christian Heimesf534f7b2008-01-25 11:02:28 +0000163
Georg Brandlec17d202008-02-02 10:44:37 +0000164* PEP 3137: There is a new type, :class:`bytes`, to represent binary data (and
165 encoded text, which is treated as binary data until you decide to decode it).
166 The :class:`str` and :class:`bytes` types cannot be mixed; you must always
167 explicitly convert between them, using the :meth:`str.encode` (str -> bytes)
168 or :meth:`bytes.decode` (bytes -> str) methods.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000169
Benjamin Petersona2f837f2008-04-28 21:05:10 +0000170* All backslashes in raw strings are interpreted literally. This means that
171 Unicode escapes are not treated specially.
172
Georg Brandlec17d202008-02-02 10:44:37 +0000173.. XXX add bytearray
174
175* PEP 3112: Bytes literals, e.g. ``b"abc"``, create :class:`bytes` instances.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000176
177* PEP 3120: UTF-8 default source encoding.
178
Georg Brandlec17d202008-02-02 10:44:37 +0000179* PEP 3131: Non-ASCII identifiers. (However, the standard library remains
180 ASCII-only with the exception of contributor names in comments.)
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000181
182* PEP 3116: New I/O Implementation. The API is nearly 100% backwards
Georg Brandlec17d202008-02-02 10:44:37 +0000183 compatible, but completely reimplemented (currently mostly in Python). Also,
184 binary files use bytes instead of strings.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000185
Georg Brandlec17d202008-02-02 10:44:37 +0000186* The :mod:`StringIO` and :mod:`cStringIO` modules are gone. Instead, import
187 :class:`io.StringIO` or :class:`io.BytesIO`.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000188
Benjamin Petersona2f837f2008-04-28 21:05:10 +0000189* ``'\U'`` and ``'\u'`` escapes in raw strings are not treated specially.
190
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000191
192PEP 3101: A New Approach to String Formatting
193=============================================
194
Georg Brandl396ef802008-02-02 10:30:18 +0000195.. XXX expand this
196
Georg Brandlec17d202008-02-02 10:44:37 +0000197* A new system for built-in string formatting operations replaces the ``%``
198 string formatting operator.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000199
200
Georg Brandlec17d202008-02-02 10:44:37 +0000201PEP 3106: Revamping dict :meth:`dict.keys`, :meth:`dict.items` and :meth:`dict.values`
202======================================================================================
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000203
Georg Brandl396ef802008-02-02 10:30:18 +0000204.. XXX expand this
205
Georg Brandlec17d202008-02-02 10:44:37 +0000206* The :meth:`dict.iterkeys`, :meth:`dict.itervalues` and :meth:`dict.iteritems`
207 methods have been removed.
Georg Brandl396ef802008-02-02 10:30:18 +0000208
Georg Brandlec17d202008-02-02 10:44:37 +0000209* :meth:`dict.keys`, :meth:`dict.values` and :meth:`dict.items` return objects
210 with set behavior that reference the underlying dict.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000211
212
213PEP 3107: Function Annotations
214==============================
215
Georg Brandl396ef802008-02-02 10:30:18 +0000216.. XXX expand this
217
Georg Brandlec17d202008-02-02 10:44:37 +0000218* A standardized way of annotating a function's parameters and return values.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000219
220
221Exception Stuff
222===============
223
Georg Brandlec17d202008-02-02 10:44:37 +0000224* PEP 352: Exceptions must derive from :exc:`BaseException`. This is the root
225 of the exception hierarchy.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000226
Georg Brandlec17d202008-02-02 10:44:37 +0000227* :exc:`StandardError` was removed (already in 2.6).
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000228
Georg Brandlec17d202008-02-02 10:44:37 +0000229* Dropping sequence behavior (slicing!) and :attr:`message` attribute of
Georg Brandl5a165582007-08-31 06:15:01 +0000230 exception instances.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000231
Georg Brandlec17d202008-02-02 10:44:37 +0000232* PEP 3109: Raising exceptions. You must now use ``raise Exception(args)``
233 instead of ``raise Exception, args``.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000234
235* PEP 3110: Catching exceptions.
236
Georg Brandlec17d202008-02-02 10:44:37 +0000237* PEP 3134: Exception chaining. (The :attr:`__context__` feature from the PEP
238 hasn't been implemented yet in 3.0a2.)
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000239
Georg Brandlec17d202008-02-02 10:44:37 +0000240* A few exception messages are improved when Windows fails to load an extension
241 module. For example, ``error code 193`` is now ``%1 is not a valid Win32
242 application``. Strings now deal with non-English locales.
Georg Brandl396ef802008-02-02 10:30:18 +0000243
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000244
245New Class and Metaclass Stuff
246=============================
247
248* Classic classes are gone.
249
250* PEP 3115: New Metaclass Syntax.
251
Skip Montanaroa86f5d42007-09-04 02:48:01 +0000252* PEP 3119: Abstract Base Classes (ABCs); ``@abstractmethod`` and
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000253 ``@abstractproperty`` decorators; collection ABCs.
254
255* PEP 3129: Class decorators.
256
257* PEP 3141: Numeric ABCs.
258
259
Georg Brandl116aa622007-08-15 14:28:22 +0000260Other Language Changes
261======================
262
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000263Here are most of the changes that Python 3.0 makes to the core Python
264language and built-in functions.
Georg Brandl116aa622007-08-15 14:28:22 +0000265
Georg Brandlec17d202008-02-02 10:44:37 +0000266* Removed backticks (use :func:`repr` instead).
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000267
268* Removed ``<>`` (use ``!=`` instead).
269
Georg Brandl396ef802008-02-02 10:30:18 +0000270* ``!=`` now returns the opposite of ``==``, unless ``==`` returns
271 ``NotImplemented``.
272
Georg Brandlec17d202008-02-02 10:44:37 +0000273* :keyword:`as` and :keyword:`with` are keywords.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000274
Georg Brandl396ef802008-02-02 10:30:18 +0000275* ``True``, ``False``, and ``None`` are keywords.
276
Georg Brandlec17d202008-02-02 10:44:37 +0000277* PEP 237: :class:`long` renamed to :class:`int`. That is, there is only one
278 built-in integral type, named :class:`int`; but it behaves like the old
279 :class:`long` type, with the exception that the literal suffix ``L`` is
280 neither supported by the parser nor produced by :func:`repr` anymore.
281 :data:`sys.maxint` was also removed since the int type has no maximum value
282 anymore.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000283
284* PEP 238: int division returns a float.
285
Georg Brandlec17d202008-02-02 10:44:37 +0000286* The ordering operators behave differently: for example, ``x < y`` where ``x``
287 and ``y`` have incompatible types raises :exc:`TypeError` instead of returning
288 a pseudo-random boolean.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000289
Georg Brandlec17d202008-02-02 10:44:37 +0000290* :meth:`__getslice__` and friends killed. The syntax ``a[i:j]`` now translates
291 to ``a.__getitem__(slice(i, j))`` (or :meth:`__setitem__` or
292 :meth:`__delitem__`, depending on context).
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000293
Georg Brandlec17d202008-02-02 10:44:37 +0000294* PEP 3102: Keyword-only arguments. Named parameters occurring after ``*args``
295 in the parameter list *must* be specified using keyword syntax in the call.
296 You can also use a bare ``*`` in the parameter list to indicate that you don't
297 accept a variable-length argument list, but you do have keyword-only
298 arguments.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000299
Georg Brandlec17d202008-02-02 10:44:37 +0000300* PEP 3104: :keyword:`nonlocal` statement. Using ``nonlocal x`` you can now
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000301 assign directly to a variable in an outer (but non-global) scope.
302
Georg Brandlec17d202008-02-02 10:44:37 +0000303* PEP 3111: :func:`raw_input` renamed to :func:`input`. That is, the new
304 :func:`input` function reads a line from :data:`sys.stdin` and returns it with
305 the trailing newline stripped. It raises :exc:`EOFError` if the input is
306 terminated prematurely. To get the old behavior of :func:`input`, use
307 ``eval(input())``.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000308
Georg Brandl67b8cad2008-04-09 07:32:07 +0000309* :func:`xrange` renamed to :func:`range`, so :func:`range` will no longer
310 produce a list but an iterable yielding integers when iterated over.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000311
Georg Brandlec17d202008-02-02 10:44:37 +0000312* PEP 3113: Tuple parameter unpacking removed. You can no longer write ``def
313 foo(a, (b, c)): ...``. Use ``def foo(a, b_c): b, c = b_c`` instead.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000314
Georg Brandlec17d202008-02-02 10:44:37 +0000315* PEP 3114: ``.next()`` renamed to :meth:`__next__`, new builtin :func:`next` to
316 call the :meth:`__next__` method on an object.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000317
Georg Brandlec17d202008-02-02 10:44:37 +0000318* PEP 3127: New octal literals; binary literals and :func:`bin`. Instead of
319 ``0666``, you write ``0o666``. The :func:`oct` function is modified
320 accordingly. Also, ``0b1010`` equals 10, and ``bin(10)`` returns
321 ``"0b1010"``. ``0666`` is now a :exc:`SyntaxError`.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000322
Georg Brandlec17d202008-02-02 10:44:37 +0000323* PEP 3132: Extended Iterable Unpacking. You can now write things like ``a, b,
324 *rest = some_sequence``. And even ``*rest, a = stuff``. The ``rest`` object
325 is always a list; the right-hand side may be any iterable.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000326
Georg Brandlec17d202008-02-02 10:44:37 +0000327* PEP 3135: New :func:`super`. You can now invoke :func:`super` without
328 arguments and the right class and instance will automatically be chosen. With
329 arguments, its behavior is unchanged.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000330
Georg Brandlec17d202008-02-02 10:44:37 +0000331* :func:`zip`, :func:`map` and :func:`filter` return iterators.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000332
Georg Brandlec17d202008-02-02 10:44:37 +0000333* :data:`string.letters` and its friends (:data:`string.lowercase` and
334 :data:`string.uppercase`) are gone. Use :data:`string.ascii_letters`
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000335 etc. instead.
336
Georg Brandlec17d202008-02-02 10:44:37 +0000337* Removed: :func:`apply`, :func:`callable`, :func:`coerce`, :func:`execfile`,
338 :func:`file`, :func:`reduce`, :func:`reload`.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000339
Georg Brandl0327e602008-02-18 22:20:55 +0000340* Removed: :meth:`dict.has_key` -- use the ``in`` operator instead.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000341
Georg Brandlec17d202008-02-02 10:44:37 +0000342* :func:`exec` is now a function.
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000343
Georg Brandlec17d202008-02-02 10:44:37 +0000344* There is a new free format floating point representation, which is based on
345 "Floating-Point Printer Sample Code", by Robert G. Burger. ``repr(11./5)``
346 now returns ``2.2`` instead of ``2.2000000000000002``.
Georg Brandl396ef802008-02-02 10:30:18 +0000347
Georg Brandlec17d202008-02-02 10:44:37 +0000348* The :meth:`__oct__` and :meth:`__hex__` special methods are removed --
349 :func:`oct` and :func:`hex` use :meth:`__index__` now to convert the argument
350 to an integer.
Georg Brandl396ef802008-02-02 10:30:18 +0000351
Georg Brandlec17d202008-02-02 10:44:37 +0000352* Support is removed for :attr:`__members__` and :attr:`__methods__`.
Georg Brandl396ef802008-02-02 10:30:18 +0000353
Georg Brandlec17d202008-02-02 10:44:37 +0000354* Renamed the boolean conversion C-level slot and method: ``nb_nonzero`` is now
355 ``nb_bool`` and :meth:`__nonzero__` is now :meth:`__bool__`.
Georg Brandl396ef802008-02-02 10:30:18 +0000356
Georg Brandlec17d202008-02-02 10:44:37 +0000357* Removed :data:`sys.maxint`. Use :data:`sys.maxsize`.
Georg Brandl396ef802008-02-02 10:30:18 +0000358
Georg Brandl116aa622007-08-15 14:28:22 +0000359
Georg Brandl5a165582007-08-31 06:15:01 +0000360.. ======================================================================
Georg Brandl116aa622007-08-15 14:28:22 +0000361
362
363Optimizations
364-------------
365
366* Detailed changes are listed here.
367
Georg Brandlec17d202008-02-02 10:44:37 +0000368The net result of the 3.0 generalizations is that Python 3.0 runs the pystone
369benchmark around 33% slower than Python 2.5. There's room for improvement; we
370expect to be optimizing string and integer operations significantly before the
371final 3.0 release!
Georg Brandl116aa622007-08-15 14:28:22 +0000372
Georg Brandl5a165582007-08-31 06:15:01 +0000373.. ======================================================================
Georg Brandl116aa622007-08-15 14:28:22 +0000374
375
376New, Improved, and Deprecated Modules
377=====================================
378
Georg Brandlec17d202008-02-02 10:44:37 +0000379As usual, Python's standard library received a number of enhancements and bug
380fixes. Here's a partial list of the most notable changes, sorted alphabetically
381by module name. Consult the :file:`Misc/NEWS` file in the source tree for a more
382complete list of changes, or look through the Subversion logs for all the
383details.
Georg Brandl116aa622007-08-15 14:28:22 +0000384
Georg Brandlec17d202008-02-02 10:44:37 +0000385* The :mod:`cPickle` module is gone. Use :mod:`pickle` instead. Eventually
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000386 we'll have a transparent accelerator module.
Georg Brandl116aa622007-08-15 14:28:22 +0000387
Georg Brandlec17d202008-02-02 10:44:37 +0000388* The :mod:`imageop` module is gone.
Georg Brandl396ef802008-02-02 10:30:18 +0000389
Georg Brandlec17d202008-02-02 10:44:37 +0000390* The :mod:`audiodev`, :mod:`Bastion`, :mod:`bsddb185`, :mod:`exceptions`,
391 :mod:`linuxaudiodev`, :mod:`md5`, :mod:`MimeWriter`, :mod:`mimify`,
392 :mod:`popen2`, :mod:`rexec`, :mod:`sets`, :mod:`sha`, :mod:`stringold`,
393 :mod:`strop`, :mod:`sunaudiodev`, :mod:`timing`, and :mod:`xmllib` modules are
394 gone.
Georg Brandl396ef802008-02-02 10:30:18 +0000395
Georg Brandlec17d202008-02-02 10:44:37 +0000396* The :mod:`new` module is gone.
Georg Brandl396ef802008-02-02 10:30:18 +0000397
Georg Brandlec17d202008-02-02 10:44:37 +0000398* The functions :func:`os.tmpnam`, :func:`os.tempnam` and :func:`os.tmpfile`
399 have been removed in favor of the :mod:`tempfile` module.
Georg Brandl396ef802008-02-02 10:30:18 +0000400
Trent Nelson428de652008-03-18 22:41:35 +0000401* The :mod:`tokenize` module has been changed to work with bytes. The main
402 entry point is now :func:`tokenize.tokenize`, instead of generate_tokens.
403
Georg Brandl5a165582007-08-31 06:15:01 +0000404.. ======================================================================
405.. whole new modules get described in subsections here
Georg Brandl116aa622007-08-15 14:28:22 +0000406
Georg Brandl5a165582007-08-31 06:15:01 +0000407.. ======================================================================
Georg Brandl116aa622007-08-15 14:28:22 +0000408
409
410Build and C API Changes
411=======================
412
413Changes to Python's build process and to the C API include:
414
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000415* PEP 3118: New Buffer API.
416
417* PEP 3121: Extension Module Initialization & Finalization.
418
Georg Brandlec17d202008-02-02 10:44:37 +0000419* PEP 3123: Making :cmacro:`PyObject_HEAD` conform to standard C.
Georg Brandl116aa622007-08-15 14:28:22 +0000420
Georg Brandl396ef802008-02-02 10:30:18 +0000421* No more C API support for restricted execution.
422
Georg Brandlec17d202008-02-02 10:44:37 +0000423* :cfunc:`PyNumber_Coerce`, :cfunc:`PyNumber_CoerceEx`, :cfunc:`PyMember_Get`,
424 and :cfunc:`PyMember_Set` C APIs are removed.
Georg Brandl396ef802008-02-02 10:30:18 +0000425
Georg Brandlec17d202008-02-02 10:44:37 +0000426* New C API :cfunc:`PyImport_ImportModuleNoBlock`, works like
427 :cfunc:`PyImport_ImportModule` but won't block on the import lock (returning
Georg Brandl396ef802008-02-02 10:30:18 +0000428 an error instead).
429
Georg Brandl5a165582007-08-31 06:15:01 +0000430.. ======================================================================
Georg Brandl116aa622007-08-15 14:28:22 +0000431
432
433Port-Specific Changes
434---------------------
435
436Platform-specific changes go here.
437
Georg Brandl396ef802008-02-02 10:30:18 +0000438
Georg Brandl5a165582007-08-31 06:15:01 +0000439.. ======================================================================
Georg Brandl116aa622007-08-15 14:28:22 +0000440
441
442.. _section-other:
443
444Other Changes and Fixes
445=======================
446
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000447As usual, there were a bunch of other improvements and bugfixes
448scattered throughout the source tree. A search through the change
449logs finds there were XXX patches applied and YYY bugs fixed between
450Python 2.6 and 3.0. Both figures are likely to be underestimates.
Georg Brandl116aa622007-08-15 14:28:22 +0000451
452Some of the more notable changes are:
453
454* Details go here.
455
Georg Brandl5a165582007-08-31 06:15:01 +0000456.. ======================================================================
Georg Brandl116aa622007-08-15 14:28:22 +0000457
458
459Porting to Python 3.0
460=====================
461
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000462This section lists previously described changes that may require
463changes to your code:
Georg Brandl116aa622007-08-15 14:28:22 +0000464
465* Everything is all in the details!
466
Georg Brandl72748582008-01-20 10:59:44 +0000467* Developers can include :file:`intobject.h` after :file:`Python.h` for
468 some ``PyInt_`` aliases.
Christian Heimesf78b1c62007-12-02 16:52:32 +0000469
Georg Brandl5a165582007-08-31 06:15:01 +0000470.. ======================================================================
Georg Brandl116aa622007-08-15 14:28:22 +0000471
472
473.. _acks:
474
475Acknowledgements
476================
477
Guido van Rossumb197f3c2007-08-31 00:37:00 +0000478The author would like to thank the following people for offering
479suggestions, corrections and assistance with various drafts of this
Georg Brandl5a165582007-08-31 06:15:01 +0000480article: Georg Brandl.
Georg Brandl116aa622007-08-15 14:28:22 +0000481