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

Skip to content

Commit 403bb39

Browse files
committed
merge heads
2 parents dcb89f4 + d3af634 commit 403bb39

15 files changed

Lines changed: 187 additions & 96 deletions

File tree

Doc/library/subprocess.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ The p1.stdout.close() call after starting the p2 is important in order for p1
735735
to receive a SIGPIPE if p2 exits before p1.
736736

737737
Alternatively, for trusted input, the shell's own pipeline support may still
738-
be used directly:
738+
be used directly::
739739

740740
output=`dmesg | grep hda`
741741
# becomes

Doc/library/threading.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ All methods are executed atomically.
430430
are blocked waiting for the lock to become unlocked, allow exactly one of them
431431
to proceed.
432432

433-
Do not call this method when the lock is unlocked.
433+
When invoked on an unlocked lock, a :exc:`ThreadError` is raised.
434434

435435
There is no return value.
436436

Lib/idlelib/tabbedpages.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def add_tab(self, tab_name):
7878
def remove_tab(self, tab_name):
7979
"""Remove the tab named <tab_name>"""
8080
if not tab_name in self._tab_names:
81-
raise KeyError("No such Tab: '%s" % page_name)
81+
raise KeyError("No such Tab: '%s" % tab_name)
8282

8383
self._tab_names.remove(tab_name)
8484
self._arrange_tabs()
@@ -88,7 +88,7 @@ def set_selected_tab(self, tab_name):
8888
if tab_name == self._selected_tab:
8989
return
9090
if tab_name is not None and tab_name not in self._tabs:
91-
raise KeyError("No such Tab: '%s" % page_name)
91+
raise KeyError("No such Tab: '%s" % tab_name)
9292

9393
# deselect the current selected tab
9494
if self._selected_tab is not None:

Lib/multiprocessing/connection.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ def _validate_family(family):
101101
if sys.platform != 'win32' and family == 'AF_PIPE':
102102
raise ValueError('Family %s is not recognized.' % family)
103103

104+
if sys.platform == 'win32' and family == 'AF_UNIX':
105+
# double check
106+
if not hasattr(socket, family):
107+
raise ValueError('Family %s is not recognized.' % family)
104108

105109
def address_type(address):
106110
'''

Lib/test/test_multiprocessing.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2331,6 +2331,12 @@ def test_invalid_family(self):
23312331
with self.assertRaises(ValueError):
23322332
multiprocessing.connection.Listener(r'\\.\test')
23332333

2334+
@unittest.skipUnless(WIN32, "skipped on non-Windows platforms")
2335+
def test_invalid_family_win32(self):
2336+
with self.assertRaises(ValueError):
2337+
multiprocessing.connection.Listener('/var/test.pipe')
2338+
2339+
23342340
testcases_other = [OtherTest, TestInvalidHandle, TestInitializers,
23352341
TestStdinBadfiledescriptor, TestInvalidFamily]
23362342

Lib/test/test_tools.py

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
"""
66

77
import os
8+
import sys
9+
import imp
810
import unittest
911
import sysconfig
12+
import tempfile
1013
from test import support
1114
from test.script_helper import assert_python_ok
1215

@@ -17,10 +20,11 @@
1720

1821
srcdir = sysconfig.get_config_var('projectbase')
1922
basepath = os.path.join(os.getcwd(), srcdir, 'Tools')
23+
scriptsdir = os.path.join(basepath, 'scripts')
2024

2125

2226
class ReindentTests(unittest.TestCase):
23-
script = os.path.join(basepath, 'scripts', 'reindent.py')
27+
script = os.path.join(scriptsdir, 'reindent.py')
2428

2529
def test_noargs(self):
2630
assert_python_ok(self.script)
@@ -31,8 +35,73 @@ def test_help(self):
3135
self.assertGreater(err, b'')
3236

3337

38+
class TestSundryScripts(unittest.TestCase):
39+
# At least make sure the rest don't have syntax errors. When tests are
40+
# added for a script it should be added to the whitelist below.
41+
42+
# scripts that have independent tests.
43+
whitelist = ['reindent.py']
44+
# scripts that can't be imported without running
45+
blacklist = ['make_ctype.py']
46+
# scripts that use windows-only modules
47+
windows_only = ['win_add2path.py']
48+
# blacklisted for other reasons
49+
other = ['analyze_dxp.py']
50+
51+
skiplist = blacklist + whitelist + windows_only + other
52+
53+
def setUp(self):
54+
cm = support.DirsOnSysPath(scriptsdir)
55+
cm.__enter__()
56+
self.addCleanup(cm.__exit__)
57+
58+
def test_sundry(self):
59+
for fn in os.listdir(scriptsdir):
60+
if fn.endswith('.py') and fn not in self.skiplist:
61+
__import__(fn[:-3])
62+
63+
@unittest.skipIf(sys.platform != "win32", "Windows-only test")
64+
def test_sundry_windows(self):
65+
for fn in self.windows_only:
66+
__import__(fn[:-3])
67+
68+
@unittest.skipIf(not support.threading, "test requires _thread module")
69+
def test_analyze_dxp_import(self):
70+
if hasattr(sys, 'getdxp'):
71+
import analyze_dxp
72+
else:
73+
with self.assertRaises(RuntimeError):
74+
import analyze_dxp
75+
76+
77+
class PdepsTests(unittest.TestCase):
78+
79+
@classmethod
80+
def setUpClass(self):
81+
path = os.path.join(scriptsdir, 'pdeps.py')
82+
self.pdeps = imp.load_source('pdeps', path)
83+
84+
@classmethod
85+
def tearDownClass(self):
86+
if 'pdeps' in sys.modules:
87+
del sys.modules['pdeps']
88+
89+
def test_process_errors(self):
90+
# Issue #14492: m_import.match(line) can be None.
91+
with tempfile.TemporaryDirectory() as tmpdir:
92+
fn = os.path.join(tmpdir, 'foo')
93+
with open(fn, 'w') as stream:
94+
stream.write("#!/this/will/fail")
95+
self.pdeps.process(fn, {})
96+
97+
def test_inverse_attribute_error(self):
98+
# Issue #14492: this used to fail with an AttributeError.
99+
self.pdeps.inverse({'a': []})
100+
101+
34102
def test_main():
35-
support.run_unittest(ReindentTests)
103+
support.run_unittest(*[obj for obj in globals().values()
104+
if isinstance(obj, type)])
36105

37106

38107
if __name__ == '__main__':

Lib/tkinter/ttk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ def detach(self, *items):
12531253

12541254

12551255
def exists(self, item):
1256-
"""Returns True if the specified item is present in the three,
1256+
"""Returns True if the specified item is present in the tree,
12571257
False otherwise."""
12581258
return bool(self.tk.call(self._w, "exists", item))
12591259

Misc/NEWS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ Core and Builtins
3939
Library
4040
-------
4141

42+
- Issue #14496: Fix wrong name in idlelib/tabbedpages.py.
43+
Patch by Popa Claudiu.
44+
45+
- Issue #14482: Raise a ValueError, not a NameError, when trying to create
46+
a multiprocessing Client or Listener with an AF_UNIX type address under
47+
Windows. Patch by Popa Claudiu.
48+
4249
- Issue #14151: Raise a ValueError, not a NameError, when trying to create
4350
a multiprocessing Client or Listener with an AF_PIPE type address under
4451
non-Windows platforms. Patch by Popa Claudiu.

Tools/scripts/abitype.py

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,6 @@
33
# Usage: abitype.py < old_code > new_code
44
import re, sys
55

6-
############ Simplistic C scanner ##################################
7-
tokenizer = re.compile(
8-
r"(?P<preproc>#.*\n)"
9-
r"|(?P<comment>/\*.*?\*/)"
10-
r"|(?P<ident>[a-zA-Z_][a-zA-Z0-9_]*)"
11-
r"|(?P<ws>[ \t\n]+)"
12-
r"|(?P<other>.)",
13-
re.MULTILINE)
14-
15-
tokens = []
16-
source = sys.stdin.read()
17-
pos = 0
18-
while pos != len(source):
19-
m = tokenizer.match(source, pos)
20-
tokens.append([m.lastgroup, m.group()])
21-
pos += len(tokens[-1][1])
22-
if tokens[-1][0] == 'preproc':
23-
# continuation lines are considered
24-
# only in preprocess statements
25-
while tokens[-1][1].endswith('\\\n'):
26-
nl = source.find('\n', pos)
27-
if nl == -1:
28-
line = source[pos:]
29-
else:
30-
line = source[pos:nl+1]
31-
tokens[-1][1] += line
32-
pos += len(line)
33-
346
###### Replacement of PyTypeObject static instances ##############
357

368
# classify each token, giving it a one-letter code:
@@ -79,7 +51,7 @@ def get_fields(start, real_end):
7951
while tokens[pos][0] in ('ws', 'comment'):
8052
pos += 1
8153
if tokens[pos][1] != 'PyVarObject_HEAD_INIT':
82-
raise Exception, '%s has no PyVarObject_HEAD_INIT' % name
54+
raise Exception('%s has no PyVarObject_HEAD_INIT' % name)
8355
while tokens[pos][1] != ')':
8456
pos += 1
8557
pos += 1
@@ -183,18 +155,48 @@ def make_slots(name, fields):
183155
return '\n'.join(res)
184156

185157

186-
# Main loop: replace all static PyTypeObjects until
187-
# there are none left.
188-
while 1:
189-
c = classify()
190-
m = re.search('(SW)?TWIW?=W?{.*?};', c)
191-
if not m:
192-
break
193-
start = m.start()
194-
end = m.end()
195-
name, fields = get_fields(start, m)
196-
tokens[start:end] = [('',make_slots(name, fields))]
158+
if __name__ == '__main__':
159+
160+
############ Simplistic C scanner ##################################
161+
tokenizer = re.compile(
162+
r"(?P<preproc>#.*\n)"
163+
r"|(?P<comment>/\*.*?\*/)"
164+
r"|(?P<ident>[a-zA-Z_][a-zA-Z0-9_]*)"
165+
r"|(?P<ws>[ \t\n]+)"
166+
r"|(?P<other>.)",
167+
re.MULTILINE)
168+
169+
tokens = []
170+
source = sys.stdin.read()
171+
pos = 0
172+
while pos != len(source):
173+
m = tokenizer.match(source, pos)
174+
tokens.append([m.lastgroup, m.group()])
175+
pos += len(tokens[-1][1])
176+
if tokens[-1][0] == 'preproc':
177+
# continuation lines are considered
178+
# only in preprocess statements
179+
while tokens[-1][1].endswith('\\\n'):
180+
nl = source.find('\n', pos)
181+
if nl == -1:
182+
line = source[pos:]
183+
else:
184+
line = source[pos:nl+1]
185+
tokens[-1][1] += line
186+
pos += len(line)
187+
188+
# Main loop: replace all static PyTypeObjects until
189+
# there are none left.
190+
while 1:
191+
c = classify()
192+
m = re.search('(SW)?TWIW?=W?{.*?};', c)
193+
if not m:
194+
break
195+
start = m.start()
196+
end = m.end()
197+
name, fields = get_fields(start, m)
198+
tokens[start:end] = [('',make_slots(name, fields))]
197199

198-
# Output result to stdout
199-
for t, v in tokens:
200-
sys.stdout.write(v)
200+
# Output result to stdout
201+
for t, v in tokens:
202+
sys.stdout.write(v)

Tools/scripts/find_recursionlimit.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,16 @@ def check_limit(n, test_func_name):
106106
else:
107107
print("Yikes!")
108108

109-
limit = 1000
110-
while 1:
111-
check_limit(limit, "test_recurse")
112-
check_limit(limit, "test_add")
113-
check_limit(limit, "test_repr")
114-
check_limit(limit, "test_init")
115-
check_limit(limit, "test_getattr")
116-
check_limit(limit, "test_getitem")
117-
check_limit(limit, "test_cpickle")
118-
print("Limit of %d is fine" % limit)
119-
limit = limit + 100
109+
if __name__ == '__main__':
110+
111+
limit = 1000
112+
while 1:
113+
check_limit(limit, "test_recurse")
114+
check_limit(limit, "test_add")
115+
check_limit(limit, "test_repr")
116+
check_limit(limit, "test_init")
117+
check_limit(limit, "test_getattr")
118+
check_limit(limit, "test_getitem")
119+
check_limit(limit, "test_cpickle")
120+
print("Limit of %d is fine" % limit)
121+
limit = limit + 100

0 commit comments

Comments
 (0)