~ubuntu-branches/ubuntu/saucy/python2.7/saucy-updates

« back to all changes in this revision

Viewing changes to debian/patches/hg-updates.diff

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-01-26 15:58:08 UTC
  • Revision ID: package-import@ubuntu.com-20130126155808-ej97ewsp21txdk9d
Tags: 2.7.3-15ubuntu2
* Update to 20130126, taken from the 2.7 branch.
  - Issue #10156: In the interpreter's initialization phase, unicode globals
    are now initialized dynamically as needed.
  - Issue #16975: Fix error handling bug in the escape-decode decoder.
  - Issue #9290: In IDLE the sys.std* streams now implement io.TextIOBase
    interface and support all mandatory methods and properties.
  - Issue #13454: Fix a crash when deleting an iterator created by
    itertools.tee() if all other iterators were very advanced before.
  - Issue #3754: fix typo in pthread AC_CACHE_VAL.
  - Issue #17029: Let h2py search the multiarch system include directory.
* python2.7-dbg, libpython2.7-dbg: Drop dependency on python.
* python2.7-dbg: Make gdb (not gdb-minimal) a recommendation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# DP: hg updates of the 2.7 release branch (until 2013-01-24).
 
1
# DP: hg updates of the 2.7 release branch (until 2013-01-26).
2
2
 
3
3
# hg diff -r v2.7.3 | filterdiff --exclude=.*ignore --exclude=.hg* --remove-timestamps
4
4
 
12557
12557
 
12558
12558
 
12559
12559
 .. function:: Comment(text=None)
12560
 
@@ -196,8 +498,7 @@
 
12560
@@ -101,8 +403,9 @@
 
12561
    going on to the user.  *source* is a filename or file object containing XML
 
12562
    data.  *events* is a list of events to report back.  If omitted, only "end"
 
12563
    events are reported.  *parser* is an optional parser instance.  If not
 
12564
-   given, the standard :class:`XMLParser` parser is used.  Returns an
 
12565
-   :term:`iterator` providing ``(event, elem)`` pairs.
 
12566
+   given, the standard :class:`XMLParser` parser is used.  *parser* is not
 
12567
+   supported by ``cElementTree``. Returns an :term:`iterator` providing
 
12568
+   ``(event, elem)`` pairs.
 
12569
 
 
12570
    .. note::
 
12571
 
 
12572
@@ -196,8 +499,7 @@
12561
12573
 .. _elementtree-element-objects:
12562
12574
 
12563
12575
 Element Objects
12567
12579
 
12568
12580
 .. class:: Element(tag, attrib={}, **extra)
12569
12581
 
12570
 
@@ -387,7 +688,7 @@
 
12582
@@ -387,7 +689,7 @@
12571
12583
 .. _elementtree-elementtree-objects:
12572
12584
 
12573
12585
 ElementTree Objects
12576
12588
 
12577
12589
 
12578
12590
 .. class:: ElementTree(element=None, file=None)
12579
 
@@ -466,13 +767,15 @@
 
12591
@@ -466,13 +768,15 @@
12580
12592
       root element.
12581
12593
 
12582
12594
 
12594
12606
       ``"xml"``, ``"html"`` or ``"text"`` (default is ``"xml"``).  Returns an
12595
12607
       encoded string.
12596
12608
 
12597
 
@@ -507,7 +810,7 @@
 
12609
@@ -507,7 +811,7 @@
12598
12610
 .. _elementtree-qname-objects:
12599
12611
 
12600
12612
 QName Objects
12603
12615
 
12604
12616
 
12605
12617
 .. class:: QName(text_or_uri, tag=None)
12606
 
@@ -523,7 +826,7 @@
 
12618
@@ -523,7 +827,7 @@
12607
12619
 .. _elementtree-treebuilder-objects:
12608
12620
 
12609
12621
 TreeBuilder Objects
12612
12624
 
12613
12625
 
12614
12626
 .. class:: TreeBuilder(element_factory=None)
12615
 
@@ -574,7 +877,7 @@
 
12627
@@ -574,7 +878,7 @@
12616
12628
 .. _elementtree-xmlparser-objects:
12617
12629
 
12618
12630
 XMLParser Objects
17153
17165
 class ModifiedUndoDelegator(UndoDelegator):
17154
17166
     "Extend base class: forbid insert/delete before the I/O mark"
17155
17167
 
17156
 
@@ -417,6 +428,9 @@
 
17168
@@ -417,7 +428,8 @@
17157
17169
         except socket.timeout, err:
17158
17170
             self.display_no_subprocess_error()
17159
17171
             return None
17160
 
+        # Can't regiter self.tkconsole.stdin, since run.py wants to
17161
 
+        # call non-TextIO methods on it (such as getvar)
17162
 
+        # XXX should be renamed to "console"
17163
 
         self.rpcclt.register("stdin", self.tkconsole)
 
17172
-        self.rpcclt.register("stdin", self.tkconsole)
 
17173
+        self.rpcclt.register("console", self.tkconsole)
 
17174
+        self.rpcclt.register("stdin", self.tkconsole.stdin)
17164
17175
         self.rpcclt.register("stdout", self.tkconsole.stdout)
17165
17176
         self.rpcclt.register("stderr", self.tkconsole.stderr)
17166
 
@@ -870,13 +884,14 @@
 
17177
         self.rpcclt.register("flist", self.tkconsole.flist)
 
17178
@@ -870,13 +882,14 @@
17167
17179
         self.save_stderr = sys.stderr
17168
17180
         self.save_stdin = sys.stdin
17169
17181
         from idlelib import IOBinding
17170
 
+        self.stdin = PseudoInputFile(self)
17171
 
         self.stdout = PseudoFile(self, "stdout", IOBinding.encoding)
17172
 
         self.stderr = PseudoFile(self, "stderr", IOBinding.encoding)
17173
 
         self.console = PseudoFile(self, "console", IOBinding.encoding)
 
17182
-        self.stdout = PseudoFile(self, "stdout", IOBinding.encoding)
 
17183
-        self.stderr = PseudoFile(self, "stderr", IOBinding.encoding)
 
17184
-        self.console = PseudoFile(self, "console", IOBinding.encoding)
 
17185
+        self.stdin = PseudoInputFile(self, "stdin", IOBinding.encoding)
 
17186
+        self.stdout = PseudoOutputFile(self, "stdout", IOBinding.encoding)
 
17187
+        self.stderr = PseudoOutputFile(self, "stderr", IOBinding.encoding)
 
17188
+        self.console = PseudoOutputFile(self, "console", IOBinding.encoding)
17174
17189
         if not use_subprocess:
17175
17190
             sys.stdout = self.stdout
17176
17191
             sys.stderr = self.stderr
17179
17194
         #
17180
17195
         self.history = self.History(self.text)
17181
17196
         #
17182
 
@@ -1251,6 +1266,19 @@
 
17197
@@ -1251,28 +1264,98 @@
17183
17198
             if not use_subprocess:
17184
17199
                 raise KeyboardInterrupt
17185
17200
 
 
17201
-class PseudoFile(object):
17186
17202
+    def rmenu_check_cut(self):
17187
17203
+        try:
17188
17204
+            if self.text.compare('sel.first', '<', 'iomark'):
17196
17212
+            return 'disabled'
17197
17213
+        return super(PyShell, self).rmenu_check_paste()
17198
17214
+
17199
 
 class PseudoFile(object):
 
17215
+class PseudoFile(io.TextIOBase):
17200
17216
 
17201
17217
     def __init__(self, shell, tags, encoding=None):
17202
 
@@ -1260,6 +1288,8 @@
17203
 
         self.encoding = encoding
17204
 
 
17205
 
     def write(self, s):
 
17218
         self.shell = shell
 
17219
         self.tags = tags
 
17220
         self.softspace = 0
 
17221
-        self.encoding = encoding
 
17222
+        self._encoding = encoding
 
17223
 
 
17224
-    def write(self, s):
 
17225
-        self.shell.write(s, self.tags)
 
17226
+    @property
 
17227
+    def encoding(self):
 
17228
+        return self._encoding
 
17229
 
 
17230
-    def writelines(self, lines):
 
17231
-        for line in lines:
 
17232
-            self.write(line)
 
17233
-
 
17234
-    def flush(self):
 
17235
-        pass
 
17236
+    @property
 
17237
+    def name(self):
 
17238
+        return '<%s>' % self.tags
 
17239
 
 
17240
     def isatty(self):
 
17241
         return True
 
17242
 
 
17243
 
 
17244
+class PseudoOutputFile(PseudoFile):
 
17245
+
 
17246
+    def writable(self):
 
17247
+        return True
 
17248
+
 
17249
+    def write(self, s):
 
17250
+        if self.closed:
 
17251
+            raise ValueError("write to closed file")
17206
17252
+        if not isinstance(s, (basestring, bytearray)):
17207
17253
+            raise TypeError('must be string, not ' + type(s).__name__)
17208
 
         self.shell.write(s, self.tags)
17209
 
 
17210
 
     def writelines(self, lines):
17211
 
@@ -1272,6 +1302,15 @@
17212
 
     def isatty(self):
17213
 
         return True
17214
 
 
17215
 
+class PseudoInputFile(object):
17216
 
+    def __init__(self, shell):
17217
 
+        self.readline = shell.readline
17218
 
+        self.isatty = shell.isatty
17219
 
+
17220
 
+    def write(self, s):
17221
 
+        raise io.UnsupportedOperation("not writable")
17222
 
+    writelines = write
17223
 
+
17224
 
 
 
17254
+        return self.shell.write(s, self.tags)
 
17255
+
 
17256
+
 
17257
+class PseudoInputFile(PseudoFile):
 
17258
+
 
17259
+    def __init__(self, shell, tags, encoding=None):
 
17260
+        PseudoFile.__init__(self, shell, tags, encoding)
 
17261
+        self._line_buffer = ''
 
17262
+
 
17263
+    def readable(self):
 
17264
+        return True
 
17265
+
 
17266
+    def read(self, size=-1):
 
17267
+        if self.closed:
 
17268
+            raise ValueError("read from closed file")
 
17269
+        if size is None:
 
17270
+            size = -1
 
17271
+        elif not isinstance(size, int):
 
17272
+            raise TypeError('must be int, not ' + type(size).__name__)
 
17273
+        result = self._line_buffer
 
17274
+        self._line_buffer = ''
 
17275
+        if size < 0:
 
17276
+            while True:
 
17277
+                line = self.shell.readline()
 
17278
+                if not line: break
 
17279
+                result += line
 
17280
+        else:
 
17281
+            while len(result) < size:
 
17282
+                line = self.shell.readline()
 
17283
+                if not line: break
 
17284
+                result += line
 
17285
+            self._line_buffer = result[size:]
 
17286
+            result = result[:size]
 
17287
+        return result
 
17288
+
 
17289
+    def readline(self, size=-1):
 
17290
+        if self.closed:
 
17291
+            raise ValueError("read from closed file")
 
17292
+        if size is None:
 
17293
+            size = -1
 
17294
+        elif not isinstance(size, int):
 
17295
+            raise TypeError('must be int, not ' + type(size).__name__)
 
17296
+        line = self._line_buffer or self.shell.readline()
 
17297
+        if size < 0:
 
17298
+            size = len(line)
 
17299
+        self._line_buffer = line[size:]
 
17300
+        return line[:size]
 
17301
+
 
17302
+
17225
17303
 usage_msg = """\
17226
17304
 
17227
 
@@ -1412,8 +1451,10 @@
 
17305
 USAGE: idle  [-deins] [-t title] [file]*
 
17306
@@ -1412,8 +1495,10 @@
17228
17307
 
17229
17308
     if enable_edit:
17230
17309
         if not (cmd or script):
17237
17316
             if not args:
17238
17317
                 flist.new()
17239
17318
     if enable_shell:
17240
 
@@ -1456,7 +1497,8 @@
 
17319
@@ -1456,7 +1541,8 @@
17241
17320
     if tkversionwarning:
17242
17321
         shell.interp.runcommand(''.join(("print('", tkversionwarning, "')")))
17243
17322
 
17549
17628
 import linecache
17550
17629
 import time
17551
17630
 import socket
17552
 
@@ -248,6 +249,43 @@
 
17631
@@ -14,6 +15,8 @@
 
17632
 from idlelib import RemoteObjectBrowser
 
17633
 from idlelib import StackViewer
 
17634
 from idlelib import rpc
 
17635
+from idlelib import PyShell
 
17636
+from idlelib import IOBinding
 
17637
 
 
17638
 import __main__
 
17639
 
 
17640
@@ -248,19 +251,19 @@
17553
17641
             quitting = True
17554
17642
             thread.interrupt_main()
17555
17643
 
17556
 
+class _RPCFile(io.TextIOBase):
17557
 
+    """Wrapper class for the RPC proxy to typecheck arguments
17558
 
+    that may not support pickling. The base class is there only
17559
 
+    to support type tests; all implementations come from the remote
17560
 
+    object."""
17561
 
+
17562
 
+    def __init__(self, rpc):
17563
 
+        super.__setattr__(self, 'rpc', rpc)
17564
 
+
17565
 
+    def __getattribute__(self, name):
17566
 
+        # When accessing the 'rpc' attribute, or 'write', use ours
17567
 
+        if name in ('rpc', 'write', 'writelines'):
17568
 
+            return io.TextIOBase.__getattribute__(self, name)
17569
 
+        # Else only look into the remote object only
17570
 
+        return getattr(self.rpc, name)
17571
 
+
17572
 
+    def __setattr__(self, name, value):
17573
 
+        return setattr(self.rpc, name, value)
17574
 
+
17575
 
+    @staticmethod
17576
 
+    def _ensure_string(func):
17577
 
+        def f(self, s):
17578
 
+            if not isinstance(s, basestring):
17579
 
+                raise TypeError('must be str, not ' + type(s).__name__)
17580
 
+            return func(self, s)
17581
 
+        return f
17582
 
+
17583
 
+class _RPCOutputFile(_RPCFile):
17584
 
+    @_RPCFile._ensure_string
17585
 
+    def write(self, s):
17586
 
+        return self.rpc.write(s)
17587
 
+
17588
 
+class _RPCInputFile(_RPCFile):
17589
 
+    @_RPCFile._ensure_string
17590
 
+    def write(self, s):
17591
 
+        raise io.UnsupportedOperation("not writable")
17592
 
+    writelines = write
17593
 
 
 
17644
-
17594
17645
 class MyHandler(rpc.RPCHandler):
17595
17646
 
17596
 
@@ -255,9 +293,10 @@
 
17647
     def handle(self):
17597
17648
         """Override base method"""
17598
17649
         executive = Executive(self)
17599
17650
         self.register("exec", executive)
17600
17651
-        sys.stdin = self.console = self.get_remote_proxy("stdin")
17601
17652
-        sys.stdout = self.get_remote_proxy("stdout")
17602
17653
-        sys.stderr = self.get_remote_proxy("stderr")
17603
 
+        self.console = self.get_remote_proxy("stdin")
17604
 
+        sys.stdin = _RPCInputFile(self.console)
17605
 
+        sys.stdout = _RPCOutputFile(self.get_remote_proxy("stdout"))
17606
 
+        sys.stderr = _RPCOutputFile(self.get_remote_proxy("stderr"))
17607
 
         from idlelib import IOBinding
17608
 
         sys.stdin.encoding = sys.stdout.encoding = \
17609
 
                              sys.stderr.encoding = IOBinding.encoding
 
17654
-        from idlelib import IOBinding
 
17655
-        sys.stdin.encoding = sys.stdout.encoding = \
 
17656
-                             sys.stderr.encoding = IOBinding.encoding
 
17657
+        self.console = self.get_remote_proxy("console")
 
17658
+        sys.stdin = PyShell.PseudoInputFile(self.console, "stdin",
 
17659
+                IOBinding.encoding)
 
17660
+        sys.stdout = PyShell.PseudoOutputFile(self.console, "stdout",
 
17661
+                IOBinding.encoding)
 
17662
+        sys.stderr = PyShell.PseudoOutputFile(self.console, "stderr",
 
17663
+                IOBinding.encoding)
 
17664
         self.interp = self.get_remote_proxy("interp")
 
17665
         rpc.RPCHandler.getresponse(self, myseq=None, wait=0.05)
 
17666
 
17610
17667
diff -r 70274d53c1dd Lib/io.py
17611
17668
--- a/Lib/io.py
17612
17669
+++ b/Lib/io.py
21576
21633
     def test_extended_set_del_slice(self):
21577
21634
         indices = (0, None, 1, 3, 19, 300, 1<<333, -1, -2, -31, -300)
21578
21635
         for start in indices:
 
21636
@@ -905,6 +925,7 @@
 
21637
         self.assertEqual(bytes(b"abc") < b"ab", False)
 
21638
         self.assertEqual(bytes(b"abc") <= b"ab", False)
 
21639
 
 
21640
+    @test.test_support.requires_docstrings
 
21641
     def test_doc(self):
 
21642
         self.assertIsNotNone(bytearray.__doc__)
 
21643
         self.assertTrue(bytearray.__doc__.startswith("bytearray("), bytearray.__doc__)
21579
21644
diff -r 70274d53c1dd Lib/test/test_bz2.py
21580
21645
--- a/Lib/test/test_bz2.py
21581
21646
+++ b/Lib/test/test_bz2.py
22118
22183
             ]
22119
22184
         )
22120
22185
 
22121
 
@@ -1495,6 +1551,14 @@
 
22186
@@ -674,6 +730,50 @@
 
22187
     def test_empty(self):
 
22188
         self.assertEqual(codecs.escape_decode(""), ("", 0))
 
22189
 
 
22190
+    def test_raw(self):
 
22191
+        for b in ''.join(map(chr, range(256))):
 
22192
+            if b != '\\':
 
22193
+                self.assertEqual(codecs.escape_decode(b + '0'),
 
22194
+                                 (b + '0', 2))
 
22195
+
 
22196
+    def test_escape(self):
 
22197
+        self.assertEqual(codecs.escape_decode(b"[\\\n]"), (b"[]", 4))
 
22198
+        self.assertEqual(codecs.escape_decode(br'[\"]'), (b'["]', 4))
 
22199
+        self.assertEqual(codecs.escape_decode(br"[\']"), (b"[']", 4))
 
22200
+        self.assertEqual(codecs.escape_decode(br"[\\]"), (br"[\]", 4))
 
22201
+        self.assertEqual(codecs.escape_decode(br"[\a]"), (b"[\x07]", 4))
 
22202
+        self.assertEqual(codecs.escape_decode(br"[\b]"), (b"[\x08]", 4))
 
22203
+        self.assertEqual(codecs.escape_decode(br"[\t]"), (b"[\x09]", 4))
 
22204
+        self.assertEqual(codecs.escape_decode(br"[\n]"), (b"[\x0a]", 4))
 
22205
+        self.assertEqual(codecs.escape_decode(br"[\v]"), (b"[\x0b]", 4))
 
22206
+        self.assertEqual(codecs.escape_decode(br"[\f]"), (b"[\x0c]", 4))
 
22207
+        self.assertEqual(codecs.escape_decode(br"[\r]"), (b"[\x0d]", 4))
 
22208
+        self.assertEqual(codecs.escape_decode(br"[\7]"), (b"[\x07]", 4))
 
22209
+        self.assertEqual(codecs.escape_decode(br"[\8]"), (br"[\8]", 4))
 
22210
+        self.assertEqual(codecs.escape_decode(br"[\78]"), (b"[\x078]", 5))
 
22211
+        self.assertEqual(codecs.escape_decode(br"[\41]"), (b"[!]", 5))
 
22212
+        self.assertEqual(codecs.escape_decode(br"[\418]"), (b"[!8]", 6))
 
22213
+        self.assertEqual(codecs.escape_decode(br"[\101]"), (b"[A]", 6))
 
22214
+        self.assertEqual(codecs.escape_decode(br"[\1010]"), (b"[A0]", 7))
 
22215
+        self.assertEqual(codecs.escape_decode(br"[\501]"), (b"[A]", 6))
 
22216
+        self.assertEqual(codecs.escape_decode(br"[\x41]"), (b"[A]", 6))
 
22217
+        self.assertEqual(codecs.escape_decode(br"[\X41]"), (br"[\X41]", 6))
 
22218
+        self.assertEqual(codecs.escape_decode(br"[\x410]"), (b"[A0]", 7))
 
22219
+        for b in ''.join(map(chr, range(256))):
 
22220
+            if b not in '\n"\'\\abtnvfr01234567x':
 
22221
+                self.assertEqual(codecs.escape_decode('\\' + b),
 
22222
+                                 ('\\' + b, 2))
 
22223
+
 
22224
+    def test_errors(self):
 
22225
+        self.assertRaises(ValueError, codecs.escape_decode, br"\x")
 
22226
+        self.assertRaises(ValueError, codecs.escape_decode, br"[\x]")
 
22227
+        self.assertEqual(codecs.escape_decode(br"[\x]\x", "ignore"), (b"[]", 6))
 
22228
+        self.assertEqual(codecs.escape_decode(br"[\x]\x", "replace"), (b"[?]?", 6))
 
22229
+        self.assertRaises(ValueError, codecs.escape_decode, br"\x0")
 
22230
+        self.assertRaises(ValueError, codecs.escape_decode, br"[\x0]")
 
22231
+        self.assertEqual(codecs.escape_decode(br"[\x0]\x0", "ignore"), (b"[]", 8))
 
22232
+        self.assertEqual(codecs.escape_decode(br"[\x0]\x0", "replace"), (b"[?]?", 8))
 
22233
+
 
22234
 class RecodingTest(unittest.TestCase):
 
22235
     def test_recoding(self):
 
22236
         f = StringIO.StringIO()
 
22237
@@ -1495,6 +1595,14 @@
22122
22238
             (u"abc", 3)
22123
22239
         )
22124
22240
 
22133
22249
         self.assertEqual(
22134
22250
             codecs.charmap_decode("\x00\x01\x02", "replace", u"ab"),
22135
22251
             (u"ab\ufffd", 3)
22136
 
@@ -1521,6 +1585,149 @@
 
22252
@@ -1521,6 +1629,149 @@
22137
22253
             (u"", len(allbytes))
22138
22254
         )
22139
22255
 
24684
24800
 
24685
24801
 def test_main():
24686
24802
     run_unittest(TestCase)
 
24803
diff -r 70274d53c1dd Lib/test/test_itertools.py
 
24804
--- a/Lib/test/test_itertools.py
 
24805
+++ b/Lib/test/test_itertools.py
 
24806
@@ -906,6 +906,12 @@
 
24807
         del a
 
24808
         self.assertRaises(ReferenceError, getattr, p, '__class__')
 
24809
 
 
24810
+    # Issue 13454: Crash when deleting backward iterator from tee()
 
24811
+    def test_tee_del_backward(self):
 
24812
+        forward, backward = tee(repeat(None, 20000000))
 
24813
+        any(forward)  # exhaust the iterator
 
24814
+        del backward
 
24815
+
 
24816
     def test_StopIteration(self):
 
24817
         self.assertRaises(StopIteration, izip().next)
 
24818
 
24687
24819
diff -r 70274d53c1dd Lib/test/test_logging.py
24688
24820
--- a/Lib/test/test_logging.py
24689
24821
+++ b/Lib/test/test_logging.py
27282
27414
diff -r 70274d53c1dd Lib/test/test_support.py
27283
27415
--- a/Lib/test/test_support.py
27284
27416
+++ b/Lib/test/test_support.py
27285
 
@@ -18,6 +18,8 @@
 
27417
@@ -18,6 +18,9 @@
27286
27418
 import UserDict
27287
27419
 import re
27288
27420
 import time
27289
27421
+import struct
27290
27422
+import _testcapi
 
27423
+import sysconfig
27291
27424
 try:
27292
27425
     import thread
27293
27426
 except ImportError:
27294
 
@@ -179,15 +181,79 @@
 
27427
@@ -179,15 +182,79 @@
27295
27428
     except KeyError:
27296
27429
         pass
27297
27430
 
27373
27506
     except OSError, e:
27374
27507
         # Unix returns ENOENT, Windows returns ESRCH.
27375
27508
         if e.errno not in (errno.ENOENT, errno.ESRCH):
27376
 
@@ -405,7 +471,7 @@
 
27509
@@ -405,7 +472,7 @@
27377
27510
     the CWD, an error is raised.  If it's True, only a warning is raised
27378
27511
     and the original CWD is used.
27379
27512
     """
27382
27515
         try:
27383
27516
             name = name.encode(sys.getfilesystemencoding() or 'ascii')
27384
27517
         except UnicodeEncodeError:
27385
 
@@ -767,6 +833,9 @@
 
27518
@@ -767,6 +834,9 @@
27386
27519
         ('EAI_FAIL', -4),
27387
27520
         ('EAI_NONAME', -2),
27388
27521
         ('EAI_NODATA', -5),
27392
27525
     ]
27393
27526
 
27394
27527
     denied = ResourceDenied("Resource '%s' is not available" % resource_name)
27395
 
@@ -858,6 +927,32 @@
 
27528
@@ -858,6 +928,32 @@
27396
27529
     gc.collect()
27397
27530
 
27398
27531
 
27425
27558
 #=======================================================================
27426
27559
 # Decorator for running a function in a different locale, correctly resetting
27427
27560
 # it afterwards.
 
27561
@@ -1016,6 +1112,10 @@
 
27562
     else:
 
27563
         return unittest.skip("resource {0!r} is not enabled".format(resource))
 
27564
 
 
27565
+requires_docstrings = unittest.skipUnless(
 
27566
+    sysconfig.get_config_var('WITH_DOC_STRINGS'),
 
27567
+    "test requires docstrings")
 
27568
+
 
27569
 def cpython_only(test):
 
27570
     """
 
27571
     Decorator for tests only applicable on CPython.
27428
27572
diff -r 70274d53c1dd Lib/test/test_sys.py
27429
27573
--- a/Lib/test/test_sys.py
27430
27574
+++ b/Lib/test/test_sys.py
28632
28776
 
28633
28777
 from test import test_support
28634
28778
 
28635
 
@@ -137,6 +139,23 @@
 
28779
@@ -137,6 +139,27 @@
28636
28780
             unicode, "\\NSPACE", 'unicode-escape', 'strict'
28637
28781
         )
28638
28782
 
28641
28785
+    @unittest.skipUnless(_testcapi.UINT_MAX < sys.maxint,
28642
28786
+                         "needs UINT_MAX < sys.maxint")
28643
28787
+    @test_support.bigmemtest(minsize=_testcapi.UINT_MAX + 1,
28644
 
+                             memuse=1 + 4 // len(u'\U00010000'))
 
28788
+                             memuse=2 + 4 // len(u'\U00010000'))
28645
28789
+    def test_issue16335(self, size):
 
28790
+        func = self.test_issue16335
 
28791
+        if size < func.minsize:
 
28792
+            raise unittest.SkipTest("not enough memory: %.1fG minimum needed" %
 
28793
+                    (func.minsize * func.memuse / float(1024**3),))
28646
28794
+        # very very long bogus character name
28647
28795
+        x = b'\\N{SPACE' + b'x' * int(_testcapi.UINT_MAX + 1) + b'}'
28648
28796
+        self.assertEqual(len(x), len(b'\\N{SPACE}') +
31454
31602
 MAKESETUP=      $(srcdir)/Modules/makesetup
31455
31603
 
31456
31604
 # Compiler options
31457
 
@@ -152,7 +156,7 @@
 
31605
@@ -82,6 +86,9 @@
 
31606
 # Machine-dependent subdirectories
 
31607
 MACHDEP=       @MACHDEP@
 
31608
 
 
31609
+# Multiarch directory (may be empty)
 
31610
+MULTIARCH=     @MULTIARCH@
 
31611
+
 
31612
 # Install prefix for architecture-independent files
 
31613
 prefix=                @prefix@
 
31614
 
 
31615
@@ -152,7 +159,7 @@
31458
31616
 SUBDIRSTOO=    Include Lib Misc Demo
31459
31617
 
31460
31618
 # Files and directories to be distributed
31463
31621
 DISTFILES=     README ChangeLog $(CONFIGFILES)
31464
31622
 DISTDIRS=      $(SUBDIRS) $(SUBDIRSTOO) Ext-dummy
31465
31623
 DIST=          $(DISTFILES) $(DISTDIRS)
31466
 
@@ -204,8 +208,8 @@
 
31624
@@ -204,8 +211,8 @@
31467
31625
 
31468
31626
 ##########################################################################
31469
31627
 # Grammar
31474
31632
 GRAMMAR_INPUT= $(srcdir)/Grammar/Grammar
31475
31633
 
31476
31634
 
31477
 
@@ -246,9 +250,9 @@
 
31635
@@ -246,9 +253,9 @@
31478
31636
 
31479
31637
 ##########################################################################
31480
31638
 # AST
31486
31644
 AST_C=         $(AST_C_DIR)/Python-ast.c
31487
31645
 AST_ASDL=      $(srcdir)/Parser/Python.asdl
31488
31646
 
31489
 
@@ -406,11 +410,16 @@
 
31647
@@ -406,11 +413,16 @@
31490
31648
 
31491
31649
 
31492
31650
 # Build the shared modules
31507
31665
 
31508
31666
 # Build static library
31509
31667
 # avoid long command lines, same as LIBRARY_OBJS
31510
 
@@ -559,9 +568,11 @@
 
31668
@@ -559,9 +571,11 @@
31511
31669
 Parser/pgenmain.o:     $(srcdir)/Include/parsetok.h
31512
31670
 
31513
31671
 $(AST_H): $(AST_ASDL) $(ASDLGEN_FILES)
31519
31677
        $(ASDLGEN) -c $(AST_C_DIR) $(AST_ASDL)
31520
31678
 
31521
31679
 Python/compile.o Python/symtable.o Python/ast.o: $(GRAMMAR_H) $(AST_H)
31522
 
@@ -957,7 +968,9 @@
 
31680
@@ -957,7 +971,9 @@
31523
31681
                -d $(LIBDEST)/site-packages -f \
31524
31682
                -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
31525
31683
        -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
31530
31688
 
31531
31689
 # Create the PLATDIR source directory, if one wasn't distributed..
31532
31690
 $(srcdir)/Lib/$(PLATDIR):
31533
 
@@ -1165,7 +1178,7 @@
 
31691
@@ -967,6 +983,7 @@
 
31692
        export PYTHONPATH; PYTHONPATH="`pwd`/Lib"; \
 
31693
        export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \
 
31694
        export EXE; EXE="$(BUILDEXE)"; \
 
31695
+       if [ -n "$(MULTIARCH)" ]; then export MULTIARCH; MULTIARCH=$(MULTIARCH); fi; \
 
31696
        cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen
 
31697
 
 
31698
 python-config: $(srcdir)/Misc/python-config.in
 
31699
@@ -1165,7 +1182,7 @@
31534
31700
        $(SHELL) config.status --recheck
31535
31701
        $(SHELL) config.status
31536
31702
 
32412
32578
diff -r 70274d53c1dd Misc/NEWS
32413
32579
--- a/Misc/NEWS
32414
32580
+++ b/Misc/NEWS
32415
 
@@ -1,17 +1,801 @@
 
32581
@@ -1,17 +1,819 @@
32416
32582
 Python News
32417
32583
 +++++++++++
32418
32584
 
32428
32594
+Core and Builtins
32429
32595
+-----------------
32430
32596
+
 
32597
+- Issue #10156: In the interpreter's initialization phase, unicode globals
 
32598
+  are now initialized dynamically as needed.
 
32599
+
 
32600
+- Issue #16975: Fix error handling bug in the escape-decode decoder.
 
32601
+
32431
32602
+- Issue #14850: Now a charmap decoder treats U+FFFE as "undefined mapping"
32432
32603
+  in any mapping, not only in a Unicode string.
32433
32604
+
32600
32771
+- Issue #13521: dict.setdefault() now does only one lookup for the given key,
32601
32772
+  making it "atomic" for many purposes.  Patch by Filip Gruszczyński.
32602
32773
+
 
32774
+- Issue #1602133: on Mac OS X a shared library build (``--enable-shared``)
 
32775
+  now fills the ``os.environ`` variable correctly.
 
32776
+
32603
32777
+- Issue #10538: When using the "s*" code with PyArg_ParseTuple() to fill a
32604
32778
+  Py_buffer structure with data from an object supporting only the old
32605
32779
+  PyBuffer interface, a reference to the source objects is now properly added
32608
32782
 Library
32609
32783
 -------
32610
32784
 
 
32785
+- Issue #9290: In IDLE the sys.std* streams now implement io.TextIOBase
 
32786
+  interface and support all mandatory methods and properties.
 
32787
+
 
32788
+- Issue #13454: Fix a crash when deleting an iterator created by itertools.tee()
 
32789
+  if all other iterators were very advanced before.
 
32790
+
32611
32791
+- Issue #1159051: GzipFile now raises EOFError when reading a corrupted file
32612
32792
+  with truncated header or footer.
32613
32793
+
33122
33302
+Build
33123
33303
+-----
33124
33304
+
 
33305
+- Issue #3754: fix typo in pthread AC_CACHE_VAL.
 
33306
+
 
33307
+- Issue #17029: Let h2py search the multiarch system include directory.
 
33308
+
33125
33309
+- Issue #16953: Fix socket module compilation on platforms with
33126
33310
+  HAVE_BROKEN_POLL. Patch by Jeffrey Armstrong.
33127
33311
+
33218
33402
 
33219
33403
 What's New in Python 2.7.3 release candidate 2?
33220
33404
 ===============================================
33221
 
@@ -451,7 +1235,7 @@
 
33405
@@ -451,7 +1253,7 @@
33222
33406
   check or set the MACOSX_DEPLOYMENT_TARGET environment variable for the
33223
33407
   interpreter process.  This could cause failures in non-Distutils subprocesses
33224
33408
   and was unreliable since tests or user programs could modify the interpreter
33227
33411
   deployment target only in the environment of each build subprocess.  It is
33228
33412
   still possible to globally override the default by setting
33229
33413
   MACOSX_DEPLOYMENT_TARGET before launching the interpreter; its value must be
33230
 
@@ -498,6 +1282,10 @@
 
33414
@@ -498,6 +1300,10 @@
33231
33415
 Extension Modules
33232
33416
 -----------------
33233
33417
 
33238
33422
 - bsddb module: Erratic behaviour of "DBEnv->rep_elect()" because a typo.
33239
33423
   Possible crash.
33240
33424
 
33241
 
@@ -572,6 +1360,9 @@
 
33425
@@ -572,6 +1378,9 @@
33242
33426
 Tests
33243
33427
 -----
33244
33428
 
33248
33432
 - Issue #11689: Fix a variable scoping error in an sqlite3 test.
33249
33433
   Initial patch by Torsten Landschoff.
33250
33434
 
33251
 
@@ -624,7 +1415,8 @@
 
33435
@@ -624,7 +1433,8 @@
33252
33436
 Documentation
33253
33437
 -------------
33254
33438
 
33258
33442
 
33259
33443
 - Issue #13402: Document absoluteness of sys.executable.
33260
33444
 
33261
 
@@ -731,7 +1523,7 @@
 
33445
@@ -731,7 +1541,7 @@
33262
33446
   rather than the Py_IsInitialized flag, avoiding a Fatal Python
33263
33447
   error in certain circumstances when an import is done in __del__.
33264
33448
 
33267
33451
   Patch by Torsten Becker.
33268
33452
 
33269
33453
 - Issue #10674: Remove unused 'dictmaker' rule from grammar.
33270
 
@@ -797,7 +1589,7 @@
 
33454
@@ -797,7 +1607,7 @@
33271
33455
 - Issue #11927: SMTP_SSL now uses port 465 by default as documented.  Patch
33272
33456
   by Kasun Herath.
33273
33457
 
33276
33460
   detect mtime changes by comparing to the system clock instead of to the
33277
33461
   previous value of the mtime.
33278
33462
 
33279
 
@@ -2873,7 +3665,7 @@
 
33463
@@ -2873,7 +3683,7 @@
33280
33464
 Tests
33281
33465
 -----
33282
33466
 
33285
33469
   instead of a hard coded port.
33286
33470
 
33287
33471
 Documentation
33288
 
@@ -4371,7 +5163,7 @@
 
33472
@@ -4371,7 +5181,7 @@
33289
33473
 - Restore Python 2.3 compatibility for decimal.py.
33290
33474
 
33291
33475
 - Issue #1702551: distutils sdist was not excluding VCS directories under
33294
33478
 
33295
33479
 - The _tkinter module functions "createfilehandler", "deletefilehandler",
33296
33480
   "createtimerhandler", "mainloop", "dooneevent" and "quit" have been deprecated
33297
 
@@ -4439,7 +5231,7 @@
 
33481
@@ -4439,7 +5249,7 @@
33298
33482
   backporting to maintenance branches.  Original patch by Alexander Belopolsky.
33299
33483
 
33300
33484
 - Issue #4163: Use unicode-friendly word splitting in the textwrap functions
36193
36377
diff -r 70274d53c1dd Modules/itertoolsmodule.c
36194
36378
--- a/Modules/itertoolsmodule.c
36195
36379
+++ b/Modules/itertoolsmodule.c
36196
 
@@ -903,11 +903,13 @@
 
36380
@@ -401,14 +401,31 @@
 
36381
     return 0;
 
36382
 }
 
36383
 
 
36384
+static void
 
36385
+teedataobject_safe_decref(PyObject *obj)
 
36386
+{
 
36387
+    while (obj && Py_TYPE(obj) == &teedataobject_type &&
 
36388
+           Py_REFCNT(obj) == 1) {
 
36389
+        PyObject *nextlink = ((teedataobject *)obj)->nextlink;
 
36390
+        ((teedataobject *)obj)->nextlink = NULL;
 
36391
+        Py_DECREF(obj);
 
36392
+        obj = nextlink;
 
36393
+    }
 
36394
+    Py_XDECREF(obj);
 
36395
+}
 
36396
+
 
36397
 static int
 
36398
 teedataobject_clear(teedataobject *tdo)
 
36399
 {
 
36400
     int i;
 
36401
+    PyObject *tmp;
 
36402
+
 
36403
     Py_CLEAR(tdo->it);
 
36404
     for (i=0 ; i<tdo->numread ; i++)
 
36405
         Py_CLEAR(tdo->values[i]);
 
36406
-    Py_CLEAR(tdo->nextlink);
 
36407
+    tmp = tdo->nextlink;
 
36408
+    tdo->nextlink = NULL;
 
36409
+    teedataobject_safe_decref(tmp);
 
36410
     return 0;
 
36411
 }
 
36412
 
 
36413
@@ -475,6 +492,8 @@
 
36414
 
 
36415
     if (to->index >= LINKCELLS) {
 
36416
         link = teedataobject_jumplink(to->dataobj);
 
36417
+        if (link == NULL)
 
36418
+            return NULL;
 
36419
         Py_DECREF(to->dataobj);
 
36420
         to->dataobj = (teedataobject *)link;
 
36421
         to->index = 0;
 
36422
@@ -903,11 +922,13 @@
36197
36423
         }
36198
36424
         ok = PyObject_IsTrue(good);
36199
36425
         Py_DECREF(good);
36208
36434
     }
36209
36435
 }
36210
36436
 
36211
 
@@ -1043,10 +1045,11 @@
 
36437
@@ -1043,10 +1064,11 @@
36212
36438
     }
36213
36439
     ok = PyObject_IsTrue(good);
36214
36440
     Py_DECREF(good);
36222
36448
     return NULL;
36223
36449
 }
36224
36450
 
36225
 
@@ -3001,9 +3004,11 @@
 
36451
@@ -3001,9 +3023,11 @@
36226
36452
             ok = PyObject_IsTrue(good);
36227
36453
             Py_DECREF(good);
36228
36454
         }
36235
36461
     }
36236
36462
 }
36237
36463
 
36238
 
@@ -3144,9 +3149,11 @@
 
36464
@@ -3144,9 +3168,11 @@
36239
36465
             ok = PyObject_IsTrue(good);
36240
36466
             Py_DECREF(good);
36241
36467
         }
36528
36754
  * Normally, an invalid fd is likely to be a C program error and therefore
36529
36755
  * an assertion can be useful, but it does contradict the POSIX standard
36530
36756
  * which for write(2) states:
36531
 
@@ -1956,7 +1956,9 @@
 
36757
@@ -441,9 +441,10 @@
 
36758
 #endif
 
36759
 
 
36760
 /* Return a dictionary corresponding to the POSIX environment table */
 
36761
-#ifdef WITH_NEXT_FRAMEWORK
 
36762
+#if defined(WITH_NEXT_FRAMEWORK) || (defined(__APPLE__) && defined(Py_ENABLE_SHARED))
 
36763
 /* On Darwin/MacOSX a shared library or framework has no access to
 
36764
-** environ directly, we must obtain it with _NSGetEnviron().
 
36765
+** environ directly, we must obtain it with _NSGetEnviron(). See also
 
36766
+** man environ(7).
 
36767
 */
 
36768
 #include <crt_externs.h>
 
36769
 static char **environ;
 
36770
@@ -463,7 +464,7 @@
 
36771
     d = PyDict_New();
 
36772
     if (d == NULL)
 
36773
         return NULL;
 
36774
-#ifdef WITH_NEXT_FRAMEWORK
 
36775
+#if defined(WITH_NEXT_FRAMEWORK) || (defined(__APPLE__) && defined(Py_ENABLE_SHARED))
 
36776
     if (environ == NULL)
 
36777
         environ = *_NSGetEnviron();
 
36778
 #endif
 
36779
@@ -1956,7 +1957,9 @@
36532
36780
 "getcwd() -> path\n\n\
36533
36781
 Return a string representing the current working directory.");
36534
36782
 
38396
38644
diff -r 70274d53c1dd Objects/stringobject.c
38397
38645
--- a/Objects/stringobject.c
38398
38646
+++ b/Objects/stringobject.c
38399
 
@@ -3545,7 +3545,7 @@
 
38647
@@ -726,6 +726,10 @@
 
38648
                              errors);
 
38649
                 goto failed;
 
38650
             }
 
38651
+            /* skip \x */
 
38652
+            if (s < end && isxdigit(Py_CHARMASK(s[0])))
 
38653
+                s++; /* and a hexdigit */
 
38654
+            break;
 
38655
 #ifndef Py_USING_UNICODE
 
38656
         case 'u':
 
38657
         case 'U':
 
38658
@@ -3545,7 +3549,7 @@
38400
38659
 
38401
38660
 
38402
38661
 PyDoc_STRVAR(splitlines__doc__,
38405
38664
 \n\
38406
38665
 Return a list of the lines in S, breaking at line boundaries.\n\
38407
38666
 Line breaks are not included in the resulting list unless keepends\n\
38408
 
@@ -3799,7 +3799,7 @@
 
38667
@@ -3799,7 +3803,7 @@
38409
38668
 };
38410
38669
 
38411
38670
 PyDoc_STRVAR(string_doc,
38414
38673
 \n\
38415
38674
 Return a nice string representation of the object.\n\
38416
38675
 If the argument is a string, the return value is the same object.");
38417
 
@@ -4254,7 +4254,7 @@
 
38676
@@ -4254,7 +4258,7 @@
38418
38677
         arglen = -1;
38419
38678
         argidx = -2;
38420
38679
     }
38423
38682
         !PyObject_TypeCheck(args, &PyBaseString_Type))
38424
38683
         dict = args;
38425
38684
     while (--fmtcnt >= 0) {
38426
 
@@ -4355,7 +4355,9 @@
 
38685
@@ -4355,7 +4359,9 @@
38427
38686
                                     "* wants int");
38428
38687
                     goto error;
38429
38688
                 }
38434
38693
                 if (width < 0) {
38435
38694
                     flags |= F_LJUST;
38436
38695
                     width = -width;
38437
 
@@ -4369,7 +4371,7 @@
 
38696
@@ -4369,7 +4375,7 @@
38438
38697
                     c = Py_CHARMASK(*fmt++);
38439
38698
                     if (!isdigit(c))
38440
38699
                         break;
38443
38702
                         PyErr_SetString(
38444
38703
                             PyExc_ValueError,
38445
38704
                             "width too big");
38446
 
@@ -4392,7 +4394,9 @@
 
38705
@@ -4392,7 +4398,9 @@
38447
38706
                             "* wants int");
38448
38707
                         goto error;
38449
38708
                     }
38454
38713
                     if (prec < 0)
38455
38714
                         prec = 0;
38456
38715
                     if (--fmtcnt >= 0)
38457
 
@@ -4404,7 +4408,7 @@
 
38716
@@ -4404,7 +4412,7 @@
38458
38717
                         c = Py_CHARMASK(*fmt++);
38459
38718
                         if (!isdigit(c))
38460
38719
                             break;
38463
38722
                             PyErr_SetString(
38464
38723
                                 PyExc_ValueError,
38465
38724
                                 "prec too big");
38466
 
@@ -4489,7 +4493,10 @@
 
38725
@@ -4489,7 +4497,10 @@
38467
38726
                     }
38468
38727
                     else {
38469
38728
                         iobj = PyNumber_Int(v);
38662
38921
diff -r 70274d53c1dd Objects/unicodeobject.c
38663
38922
--- a/Objects/unicodeobject.c
38664
38923
+++ b/Objects/unicodeobject.c
38665
 
@@ -1861,7 +1861,7 @@
 
38924
@@ -82,8 +82,9 @@
 
38925
 
 
38926
 /* --- Globals ------------------------------------------------------------
 
38927
 
 
38928
-   The globals are initialized by the _PyUnicode_Init() API and should
 
38929
-   not be used before calling that API.
 
38930
+NOTE: In the interpreter's initialization phase, some globals are currently
 
38931
+      initialized dynamically as needed. In the process Unicode objects may
 
38932
+      be created before the Unicode type is ready.
 
38933
 
 
38934
 */
 
38935
 
 
38936
@@ -93,15 +94,27 @@
 
38937
 #endif
 
38938
 
 
38939
 /* Free list for Unicode objects */
 
38940
-static PyUnicodeObject *free_list;
 
38941
-static int numfree;
 
38942
+static PyUnicodeObject *free_list = NULL;
 
38943
+static int numfree = 0;
 
38944
 
 
38945
 /* The empty Unicode object is shared to improve performance. */
 
38946
-static PyUnicodeObject *unicode_empty;
 
38947
+static PyUnicodeObject *unicode_empty = NULL;
 
38948
+
 
38949
+#define _Py_RETURN_UNICODE_EMPTY()                      \
 
38950
+    do {                                                \
 
38951
+        if (unicode_empty != NULL)                      \
 
38952
+            Py_INCREF(unicode_empty);                   \
 
38953
+        else {                                          \
 
38954
+            unicode_empty = _PyUnicode_New(0);          \
 
38955
+            if (unicode_empty != NULL)                  \
 
38956
+                Py_INCREF(unicode_empty);               \
 
38957
+        }                                               \
 
38958
+        return (PyObject *)unicode_empty;               \
 
38959
+    } while (0)
 
38960
 
 
38961
 /* Single character Unicode strings in the Latin-1 range are being
 
38962
    shared as well. */
 
38963
-static PyUnicodeObject *unicode_latin1[256];
 
38964
+static PyUnicodeObject *unicode_latin1[256] = {NULL};
 
38965
 
 
38966
 /* Default encoding to use and assume when NULL is passed as encoding
 
38967
    parameter; it is initialized by _PyUnicode_Init().
 
38968
@@ -110,7 +123,7 @@
 
38969
    PyUnicode_GetDefaultEncoding() APIs to access this global.
 
38970
 
 
38971
 */
 
38972
-static char unicode_default_encoding[100];
 
38973
+static char unicode_default_encoding[100 + 1] = "ascii";
 
38974
 
 
38975
 /* Fast detection of the most frequent whitespace characters */
 
38976
 const unsigned char _Py_ascii_whitespace[] = {
 
38977
@@ -204,7 +217,7 @@
 
38978
 
 
38979
 #define BLOOM_MASK unsigned long
 
38980
 
 
38981
-static BLOOM_MASK bloom_linebreak;
 
38982
+static BLOOM_MASK bloom_linebreak = ~(BLOOM_MASK)0;
 
38983
 
 
38984
 #define BLOOM_ADD(mask, ch) ((mask |= (1UL << ((ch) & (BLOOM_WIDTH - 1)))))
 
38985
 #define BLOOM(mask, ch)     ((mask &  (1UL << ((ch) & (BLOOM_WIDTH - 1)))))
 
38986
@@ -448,10 +461,8 @@
 
38987
     if (u != NULL) {
 
38988
 
 
38989
         /* Optimization for empty strings */
 
38990
-        if (size == 0 && unicode_empty != NULL) {
 
38991
-            Py_INCREF(unicode_empty);
 
38992
-            return (PyObject *)unicode_empty;
 
38993
-        }
 
38994
+        if (size == 0)
 
38995
+            _Py_RETURN_UNICODE_EMPTY();
 
38996
 
 
38997
         /* Single character Unicode objects in the Latin-1 range are
 
38998
            shared when using this constructor */
 
38999
@@ -497,10 +508,8 @@
 
39000
     if (u != NULL) {
 
39001
 
 
39002
         /* Optimization for empty strings */
 
39003
-        if (size == 0 && unicode_empty != NULL) {
 
39004
-            Py_INCREF(unicode_empty);
 
39005
-            return (PyObject *)unicode_empty;
 
39006
-        }
 
39007
+        if (size == 0)
 
39008
+            _Py_RETURN_UNICODE_EMPTY();
 
39009
 
 
39010
         /* Single characters are shared when using this constructor.
 
39011
            Restrict to ASCII, since the input must be UTF-8. */
 
39012
@@ -1162,13 +1171,10 @@
 
39013
     }
 
39014
 
 
39015
     /* Convert to Unicode */
 
39016
-    if (len == 0) {
 
39017
-        Py_INCREF(unicode_empty);
 
39018
-        v = (PyObject *)unicode_empty;
 
39019
-    }
 
39020
-    else
 
39021
-        v = PyUnicode_Decode(s, len, encoding, errors);
 
39022
-
 
39023
+    if (len == 0)
 
39024
+        _Py_RETURN_UNICODE_EMPTY();
 
39025
+
 
39026
+    v = PyUnicode_Decode(s, len, encoding, errors);
 
39027
     return v;
 
39028
 
 
39029
   onError:
 
39030
@@ -1381,7 +1387,7 @@
 
39031
     Py_DECREF(v);
 
39032
     strncpy(unicode_default_encoding,
 
39033
             encoding,
 
39034
-            sizeof(unicode_default_encoding));
 
39035
+            sizeof(unicode_default_encoding) - 1);
 
39036
     return 0;
 
39037
 
 
39038
   onError:
 
39039
@@ -1861,7 +1867,7 @@
38666
39040
        illegal prefix.  See RFC 3629 for details */
38667
39041
     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 00-0F */
38668
39042
     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
38671
39045
     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
38672
39046
     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
38673
39047
     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
38674
 
@@ -2217,7 +2217,7 @@
 
39048
@@ -2217,7 +2223,7 @@
38675
39049
 #endif
38676
39050
     PyObject *errorHandler = NULL;
38677
39051
     PyObject *exc = NULL;
38680
39054
     q = (unsigned char *)s;
38681
39055
     e = q + size;
38682
39056
 
38683
 
@@ -2272,7 +2272,7 @@
 
39057
@@ -2272,7 +2278,7 @@
38684
39058
     /* On narrow builds we split characters outside the BMP into two
38685
39059
        codepoints => count how much extra space we need. */
38686
39060
 #ifndef Py_UNICODE_WIDE
38689
39063
         if (qq[iorder[2]] != 0 || qq[iorder[3]] != 0)
38690
39064
             pairs++;
38691
39065
 #endif
38692
 
@@ -2564,9 +2564,12 @@
 
39066
@@ -2564,9 +2570,12 @@
38693
39067
         }
38694
39068
 
38695
39069
         /* UTF-16 code pair: */
38704
39078
             endinpos = ((const char *)e)-starts;
38705
39079
             goto utf16Error;
38706
39080
         }
38707
 
@@ -2896,7 +2899,8 @@
 
39081
@@ -2896,7 +2905,8 @@
38708
39082
                     /* found a name.  look it up in the unicode database */
38709
39083
                     message = "unknown Unicode character name";
38710
39084
                     s++;
38714
39088
                         goto store;
38715
39089
                 }
38716
39090
             }
38717
 
@@ -4118,46 +4122,60 @@
 
39091
@@ -4118,46 +4128,60 @@
38718
39092
                 if (PyErr_ExceptionMatches(PyExc_LookupError)) {
38719
39093
                     /* No mapping found means: mapping is undefined. */
38720
39094
                     PyErr_Clear();
38798
39172
                 else if (targetsize > 1) {
38799
39173
                     /* 1-n mapping */
38800
39174
                     if (targetsize > extrachars) {
38801
 
@@ -4191,6 +4209,20 @@
 
39175
@@ -4191,6 +4215,20 @@
38802
39176
             }
38803
39177
             Py_DECREF(x);
38804
39178
             ++s;
38819
39193
         }
38820
39194
     }
38821
39195
     if (p - PyUnicode_AS_UNICODE(v) < PyUnicode_GET_SIZE(v))
38822
 
@@ -7521,7 +7553,7 @@
 
39196
@@ -7521,7 +7559,7 @@
38823
39197
 }
38824
39198
 
38825
39199
 PyDoc_STRVAR(splitlines__doc__,
38828
39202
 \n\
38829
39203
 Return a list of the lines in S, breaking at line boundaries.\n\
38830
39204
 Line breaks are not included in the resulting list unless keepends\n\
38831
 
@@ -7797,10 +7829,6 @@
 
39205
@@ -7797,10 +7835,6 @@
38832
39206
 
38833
39207
 
38834
39208
 static PyMethodDef unicode_methods[] = {
38839
39213
     {"encode", (PyCFunction) unicode_encode, METH_VARARGS | METH_KEYWORDS, encode__doc__},
38840
39214
     {"replace", (PyCFunction) unicode_replace, METH_VARARGS, replace__doc__},
38841
39215
     {"split", (PyCFunction) unicode_split, METH_VARARGS, split__doc__},
38842
 
@@ -8279,7 +8307,7 @@
 
39216
@@ -8279,7 +8313,7 @@
38843
39217
         arglen = -1;
38844
39218
         argidx = -2;
38845
39219
     }
38848
39222
         !PyObject_TypeCheck(args, &PyBaseString_Type))
38849
39223
         dict = args;
38850
39224
 
38851
 
@@ -8384,7 +8412,9 @@
 
39225
@@ -8384,7 +8418,9 @@
38852
39226
                                     "* wants int");
38853
39227
                     goto onError;
38854
39228
                 }
38859
39233
                 if (width < 0) {
38860
39234
                     flags |= F_LJUST;
38861
39235
                     width = -width;
38862
 
@@ -8398,7 +8428,7 @@
 
39236
@@ -8398,7 +8434,7 @@
38863
39237
                     c = *fmt++;
38864
39238
                     if (c < '0' || c > '9')
38865
39239
                         break;
38868
39242
                         PyErr_SetString(PyExc_ValueError,
38869
39243
                                         "width too big");
38870
39244
                         goto onError;
38871
 
@@ -8419,7 +8449,9 @@
 
39245
@@ -8419,7 +8455,9 @@
38872
39246
                                         "* wants int");
38873
39247
                         goto onError;
38874
39248
                     }
38879
39253
                     if (prec < 0)
38880
39254
                         prec = 0;
38881
39255
                     if (--fmtcnt >= 0)
38882
 
@@ -8431,7 +8463,7 @@
 
39256
@@ -8431,7 +8469,7 @@
38883
39257
                         c = *fmt++;
38884
39258
                         if (c < '0' || c > '9')
38885
39259
                             break;
38888
39262
                             PyErr_SetString(PyExc_ValueError,
38889
39263
                                             "prec too big");
38890
39264
                             goto onError;
38891
 
@@ -8763,7 +8795,8 @@
 
39265
@@ -8763,7 +8801,8 @@
38892
39266
 }
38893
39267
 
38894
39268
 PyDoc_STRVAR(unicode_doc,
38898
39272
 \n\
38899
39273
 Create a new Unicode object from the given encoded string.\n\
38900
39274
 encoding defaults to the current default string encoding.\n\
38901
 
@@ -8850,6 +8883,12 @@
 
39275
@@ -8817,8 +8856,6 @@
 
39276
 
 
39277
 void _PyUnicode_Init(void)
 
39278
 {
 
39279
-    int i;
 
39280
-
 
39281
     /* XXX - move this array to unicodectype.c ? */
 
39282
     Py_UNICODE linebreak[] = {
 
39283
         0x000A, /* LINE FEED */
 
39284
@@ -8832,15 +8869,12 @@
 
39285
     };
 
39286
 
 
39287
     /* Init the implementation */
 
39288
-    free_list = NULL;
 
39289
-    numfree = 0;
 
39290
-    unicode_empty = _PyUnicode_New(0);
 
39291
-    if (!unicode_empty)
 
39292
-        return;
 
39293
-
 
39294
-    strcpy(unicode_default_encoding, "ascii");
 
39295
-    for (i = 0; i < 256; i++)
 
39296
-        unicode_latin1[i] = NULL;
 
39297
+    if (!unicode_empty) {
 
39298
+        unicode_empty = _PyUnicode_New(0);
 
39299
+        if (!unicode_empty)
 
39300
+            return;
 
39301
+    }
 
39302
+
 
39303
     if (PyType_Ready(&PyUnicode_Type) < 0)
 
39304
         Py_FatalError("Can't initialize 'unicode'");
 
39305
 
 
39306
@@ -8850,6 +8884,12 @@
38902
39307
         );
38903
39308
 
38904
39309
     PyType_Ready(&EncodingMapType);
38911
39316
 }
38912
39317
 
38913
39318
 /* Finalize the Unicode implementation */
 
39319
@@ -8879,15 +8919,11 @@
 
39320
 {
 
39321
     int i;
 
39322
 
 
39323
-    Py_XDECREF(unicode_empty);
 
39324
-    unicode_empty = NULL;
 
39325
-
 
39326
-    for (i = 0; i < 256; i++) {
 
39327
-        if (unicode_latin1[i]) {
 
39328
-            Py_DECREF(unicode_latin1[i]);
 
39329
-            unicode_latin1[i] = NULL;
 
39330
-        }
 
39331
-    }
 
39332
+    Py_CLEAR(unicode_empty);
 
39333
+
 
39334
+    for (i = 0; i < 256; i++)
 
39335
+        Py_CLEAR(unicode_latin1[i]);
 
39336
+
 
39337
     (void)PyUnicode_ClearFreeList();
 
39338
 }
 
39339
 
38914
39340
diff -r 70274d53c1dd Objects/weakrefobject.c
38915
39341
--- a/Objects/weakrefobject.c
38916
39342
+++ b/Objects/weakrefobject.c
41079
41505
 import os
41080
41506
 import sys
41081
41507
 
 
41508
diff -r 70274d53c1dd Tools/scripts/h2py.py
 
41509
--- a/Tools/scripts/h2py.py
 
41510
+++ b/Tools/scripts/h2py.py
 
41511
@@ -58,6 +58,12 @@
 
41512
                 raise KeyError
 
41513
         except KeyError:
 
41514
             searchdirs=['/usr/include']
 
41515
+            try:
 
41516
+                searchdirs.insert(0, os.path.join('/usr/include',
 
41517
+                                                  os.environ['MULTIARCH']))
 
41518
+            except KeyError:
 
41519
+                pass
 
41520
+
 
41521
 
 
41522
 def main():
 
41523
     global filedict
41082
41524
diff -r 70274d53c1dd Tools/scripts/patchcheck.py
41083
41525
--- a/Tools/scripts/patchcheck.py
41084
41526
+++ b/Tools/scripts/patchcheck.py
41495
41937
diff -r 70274d53c1dd configure.ac
41496
41938
--- /dev/null
41497
41939
+++ b/configure.ac
41498
 
@@ -0,0 +1,4435 @@
 
41940
@@ -0,0 +1,4438 @@
41499
41941
+dnl ***********************************************
41500
41942
+dnl * Please run autoreconf to test your changes! *
41501
41943
+dnl ***********************************************
42101
42543
+  ])
42102
42544
+fi
42103
42545
+
 
42546
+MULTIARCH=$($CC --print-multiarch 2>/dev/null)
 
42547
+AC_SUBST(MULTIARCH)
 
42548
+
42104
42549
+
42105
42550
+# checks for UNIX variants that set C preprocessor variables
42106
42551
+AC_USE_SYSTEM_EXTENSIONS
42860
43305
+# so we need to run a program to see whether it really made the
42861
43306
+# function available.
42862
43307
+AC_MSG_CHECKING(whether $CC accepts -pthread)
42863
 
+AC_CACHE_VAL(ac_cv_thread,
 
43308
+AC_CACHE_VAL(ac_cv_pthread,
42864
43309
+[ac_save_cc="$CC"
42865
43310
+CC="$CC -pthread"
42866
43311
+AC_RUN_IFELSE([AC_LANG_SOURCE([[