|
13 | 13 |
|
14 | 14 | from test.support import (
|
15 | 15 | TestFailed, TESTFN, run_with_locale, no_tracing,
|
16 |
| - _2G, _4G, bigmemtest, |
| 16 | + _2G, _4G, bigmemtest, stackless, |
17 | 17 | )
|
18 | 18 |
|
19 | 19 | from pickle import bytes_types
|
@@ -403,12 +403,9 @@ def create_dynamic_class(name, bases):
|
403 | 403 |
|
404 | 404 | # xrange(5) pickled from 2.x with protocol 2
|
405 | 405 | DATA4 = b'\x80\x02c__builtin__\nxrange\nq\x00K\x00K\x05K\x01\x87q\x01Rq\x02.'
|
406 |
| -try: |
407 |
| - import stackless |
408 |
| - has_stackless = True |
| 406 | +if stackless: |
409 | 407 | DATA4_SLP = b'\x80\x02cstackless._wrap\nrange\nq\x00K\x00K\x05K\x01\x87q\x01Rq\x02)b.'
|
410 |
| -except ImportError: |
411 |
| - has_stackless = False |
| 408 | +else: |
412 | 409 | DATA4_SLP = DATA4
|
413 | 410 |
|
414 | 411 |
|
@@ -1348,7 +1345,7 @@ def test_unpickle_from_2x(self):
|
1348 | 1345 | loaded = self.loads(DATA3)
|
1349 | 1346 | self.assertEqual(loaded, set([1, 2]))
|
1350 | 1347 | loaded = self.loads(DATA4_SLP)
|
1351 |
| - if not has_stackless: |
| 1348 | + if not stackless: |
1352 | 1349 | # stackless provides a fake range for unpickling
|
1353 | 1350 | self.assertEqual(type(loaded), type(range(0)))
|
1354 | 1351 | self.assertEqual(list(loaded), list(range(5)))
|
@@ -1774,7 +1771,7 @@ def test_compat_unpickle(self):
|
1774 | 1771 | def test_local_lookup_error(self):
|
1775 | 1772 | # Test that whichmodule() errors out cleanly when looking up
|
1776 | 1773 | # an assumed globally-reachable object fails.
|
1777 |
| - if has_stackless: |
| 1774 | + if stackless: |
1778 | 1775 | self.skipTest("Stackless can pickle functions by value")
|
1779 | 1776 | def f():
|
1780 | 1777 | pass
|
|
0 commit comments