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

Skip to content

Commit 5a5d6a1

Browse files
committed
Merge
2 parents 8923a4d + 718fbf0 commit 5a5d6a1

11 files changed

Lines changed: 238 additions & 138 deletions

File tree

Lib/importlib/_bootstrap.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
work. One should use importlib as the public-facing version of this module.
77
88
"""
9+
#
10+
# IMPORTANT: Whenever making changes to this module, be sure to run
11+
# a top-level make in order to get the frozen version of the module
12+
# update. Not doing so, will result in the Makefile to fail for
13+
# all others who don't have a ./python around to freeze the module
14+
# in the early stages of compilation.
15+
#
916

1017
# See importlib._setup() for what is injected into the global namespace.
1118

Lib/test/test_logging.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -593,28 +593,28 @@ def remove_loop(fname, tries):
593593
pass
594594
time.sleep(0.004 * random.randint(0, 4))
595595

596-
def cleanup(remover, fn, handler):
597-
handler.close()
598-
remover.join()
599-
if os.path.exists(fn):
600-
os.unlink(fn)
596+
del_count = 500
597+
log_count = 500
601598

602-
fd, fn = tempfile.mkstemp('.log', 'test_logging-3-')
603-
os.close(fd)
604-
del_count = 1000
605-
log_count = 1000
606-
remover = threading.Thread(target=remove_loop, args=(fn, del_count))
607-
remover.daemon = True
608-
remover.start()
609599
for delay in (False, True):
600+
fd, fn = tempfile.mkstemp('.log', 'test_logging-3-')
601+
os.close(fd)
602+
remover = threading.Thread(target=remove_loop, args=(fn, del_count))
603+
remover.daemon = True
604+
remover.start()
610605
h = logging.handlers.WatchedFileHandler(fn, delay=delay)
611-
self.addCleanup(cleanup, remover, fn, h)
612606
f = logging.Formatter('%(asctime)s: %(levelname)s: %(message)s')
613607
h.setFormatter(f)
614-
for _ in range(log_count):
615-
time.sleep(0.005)
616-
r = logging.makeLogRecord({'msg': 'testing' })
617-
h.handle(r)
608+
try:
609+
for _ in range(log_count):
610+
time.sleep(0.005)
611+
r = logging.makeLogRecord({'msg': 'testing' })
612+
h.handle(r)
613+
finally:
614+
h.close()
615+
remover.join()
616+
if os.path.exists(fn):
617+
os.unlink(fn)
618618

619619

620620
class BadStream(object):

Lib/unittest/case.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def skip(reason):
6161
Unconditionally skip a test.
6262
"""
6363
def decorator(test_item):
64-
if not (isinstance(test_item, type) and issubclass(test_item, TestCase)):
64+
if not isinstance(test_item, type):
6565
@functools.wraps(test_item)
6666
def skip_wrapper(*args, **kwargs):
6767
raise SkipTest(reason)

Lib/unittest/test/test_skipping.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,21 @@ def test_1(self):
6666
self.assertEqual(result.skipped, [(test, "testing")])
6767
self.assertEqual(record, [])
6868

69+
def test_skip_non_unittest_class(self):
70+
@unittest.skip("testing")
71+
class Mixin:
72+
def test_1(self):
73+
record.append(1)
74+
class Foo(Mixin, unittest.TestCase):
75+
pass
76+
record = []
77+
result = unittest.TestResult()
78+
test = Foo("test_1")
79+
suite = unittest.TestSuite([test])
80+
suite.run(result)
81+
self.assertEqual(result.skipped, [(test, "testing")])
82+
self.assertEqual(record, [])
83+
6984
def test_expected_failure(self):
7085
class Foo(unittest.TestCase):
7186
@unittest.expectedFailure

Makefile.pre.in

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,12 +573,23 @@ Modules/Setup: $(srcdir)/Modules/Setup.dist
573573

574574
Modules/_testembed: Modules/_testembed.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY)
575575
$(LINKCC) $(PY_LDFLAGS) $(LINKFORSHARED) -o $@ Modules/_testembed.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
576+
576577
############################################################################
577578
# Importlib
578579

579580
Python/importlib.h: $(srcdir)/Lib/importlib/_bootstrap.py $(srcdir)/Python/freeze_importlib.py
580-
./$(BUILDPYTHON) $(srcdir)/Python/freeze_importlib.py \
581-
$(srcdir)/Lib/importlib/_bootstrap.py Python/importlib.h
581+
@if test -f ./$(BUILDPYTHON); then \
582+
./$(BUILDPYTHON) $(srcdir)/Python/freeze_importlib.py \
583+
$(srcdir)/Lib/importlib/_bootstrap.py Python/importlib.h; \
584+
else \
585+
echo "----------------------------------------------------------"; \
586+
echo "Python/importlib.h needs to be rebuilt, but no interpreter"; \
587+
echo "is available to do so. Leaving the previous version in"; \
588+
echo "place. You may want to run ''make'' a second time after"; \
589+
echo "this build is complete."; \
590+
echo "----------------------------------------------------------"; \
591+
fi
592+
582593
############################################################################
583594
# Special rules for object files
584595

Misc/NEWS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ Core and Builtins
7171
Library
7272
-------
7373

74+
- Issue #14664: It is now possible to use @unittest.skip{If,Unless} on a
75+
test class that doesn't inherit from TestCase (i.e. a mixin).
76+
7477
- Issue #4892: multiprocessing Connections can now be transferred over
7578
multiprocessing Connections. Patch by Richard Oudkerk (sbt).
7679

@@ -186,6 +189,9 @@ Tests
186189
Tools / Demos
187190
-------------
188191

192+
- Issue #3561: The Windows installer now has an option, off by default, for
193+
placing the Python installation into the system "Path" environment variable.
194+
189195
- Issue #13165: stringbench is now available in the Tools/stringbench folder.
190196
It used to live in its own SVN project.
191197

Objects/longobject.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,6 +1657,7 @@ long_to_decimal_string(PyObject *aa)
16571657

16581658
/* check we've counted correctly */
16591659
assert(p == PyUnicode_1BYTE_DATA(str));
1660+
assert(_PyUnicode_CheckConsistency(str, 1));
16601661
Py_DECREF(scratch);
16611662
return (PyObject *)str;
16621663
}
@@ -1761,6 +1762,7 @@ _PyLong_Format(PyObject *aa, int base)
17611762
if (negative)
17621763
*--p = '-';
17631764
assert(p == PyUnicode_1BYTE_DATA(v));
1765+
assert(_PyUnicode_CheckConsistency(v, 1));
17641766
return v;
17651767
}
17661768

Objects/unicodeobject.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,13 @@ _PyUnicode_CheckConsistency(PyObject *op, int check_content)
375375
{
376376
Py_ssize_t i;
377377
Py_UCS4 maxchar = 0;
378-
void *data = PyUnicode_DATA(ascii);
378+
void *data;
379+
Py_UCS4 ch;
380+
381+
data = PyUnicode_DATA(ascii);
379382
for (i=0; i < ascii->length; i++)
380383
{
381-
Py_UCS4 ch = PyUnicode_READ(kind, data, i);
384+
ch = PyUnicode_READ(kind, data, i);
382385
if (ch > maxchar)
383386
maxchar = ch;
384387
}
@@ -398,6 +401,7 @@ _PyUnicode_CheckConsistency(PyObject *op, int check_content)
398401
assert(maxchar >= 0x10000);
399402
assert(maxchar <= MAX_UNICODE);
400403
}
404+
assert(PyUnicode_READ(kind, data, ascii->length) == 0);
401405
}
402406
return 1;
403407
}

0 commit comments

Comments
 (0)