Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 131beaf

Browse files
author
Anselm Kruis
committed
merge 3.3-slp (Stackless #126, fix C-Python tests)
2 parents 5b2c817 + afa7916 commit 131beaf

File tree

7 files changed

+20
-38
lines changed

7 files changed

+20
-38
lines changed

Lib/test/_test_multiprocessing.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@
2121
import test.support
2222
import test.script_helper
2323

24-
try:
25-
import stackless
26-
usingStackless = True
27-
except ImportError:
28-
usingStackless = False
29-
3024

3125
# Skip tests if _multiprocessing wasn't built.
3226
_multiprocessing = test.support.import_module('_multiprocessing')
@@ -1858,7 +1852,7 @@ def errback(exc):
18581852
p.close()
18591853
p.join()
18601854

1861-
@unittest.skipIf(usingStackless, "Stackless can pickle lambdas")
1855+
@unittest.skipIf(test.support.stackless, "Stackless can pickle lambdas")
18621856
def test_unpickleable_result(self):
18631857
from multiprocessing.pool import MaybeEncodingError
18641858
p = multiprocessing.Pool(2)

Lib/test/pickletester.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from test.support import (
1313
TestFailed, TESTFN, run_with_locale, no_tracing,
14-
_2G, _4G, bigmemtest,
14+
_2G, _4G, bigmemtest, stackless,
1515
)
1616

1717
from pickle import bytes_types
@@ -400,12 +400,11 @@ def create_dynamic_class(name, bases):
400400

401401
# xrange(5) pickled from 2.x with protocol 2
402402
DATA4 = b'\x80\x02c__builtin__\nxrange\nq\x00K\x00K\x05K\x01\x87q\x01Rq\x02.'
403-
try:
404-
import stackless
403+
if stackless:
405404
DATA4_SLP = b'\x80\x02cstackless._wrap\nrange\nq\x00K\x00K\x05K\x01\x87q\x01Rq\x02)b.'
406-
except:
405+
else:
407406
DATA4_SLP = DATA4
408-
407+
409408

410409
# a SimpleCookie() object pickled from 2.x with protocol 2
411410
DATA5 = (b'\x80\x02cCookie\nSimpleCookie\nq\x00)\x81q\x01U\x03key'
@@ -1285,9 +1284,7 @@ def test_unpickle_from_2x(self):
12851284
loaded = self.loads(DATA3)
12861285
self.assertEqual(loaded, set([1, 2]))
12871286
loaded = self.loads(DATA4_SLP)
1288-
try:
1289-
import stackless
1290-
except ImportError:
1287+
if not stackless:
12911288
self.assertEqual(type(loaded), type(range(0)))
12921289
else:
12931290
pass # stackless provides a fake range for unpickling

Lib/test/support/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
import urllib.error
2929
import warnings
3030

31+
try:
32+
import stackless
33+
except ImportError:
34+
stackless = None
35+
3136
try:
3237
import _thread, threading
3338
except ImportError:

Lib/test/test_pep352.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import warnings
44
import os
55
from platform import system as platform_system
6+
from test.support import stackless
67

78

89
class ExceptionClassTests(unittest.TestCase):
@@ -31,11 +32,6 @@ def test_inheritance(self):
3132

3233
inheritance_tree = open(os.path.join(os.path.split(__file__)[0],
3334
'exception_hierarchy.txt'))
34-
try:
35-
import stackless
36-
haveStackless = True
37-
except:
38-
haveStackless = False
3935
try:
4036
superclass_name = inheritance_tree.readline().rstrip()
4137
try:
@@ -61,7 +57,7 @@ def test_inheritance(self):
6157
if '[' in exc_name:
6258
left_bracket = exc_name.index('[')
6359
exc_name = exc_name[:left_bracket-1] # cover space
64-
if not haveStackless and exc_name == "TaskletExit":
60+
if stackless is None and exc_name == "TaskletExit":
6561
exc_set.discard(exc_name)
6662
continue
6763
try:

Lib/test/test_pickle.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@
2020
except ImportError:
2121
has_c_implementation = False
2222

23-
try:
24-
import stackless
25-
has_stackless = True
26-
except ImportError:
27-
has_stackless = False
28-
2923

3024
class PickleTests(AbstractPickleModuleTests):
3125
pass
@@ -153,7 +147,7 @@ class SizeofTests(unittest.TestCase):
153147

154148
def test_pickler(self):
155149
basesize = support.calcobjsize('5P2n3i2n3iP' +
156-
('P' if has_stackless else ''))
150+
('P' if support.stackless else ''))
157151
p = _pickle.Pickler(io.BytesIO())
158152
self.assertEqual(object.__sizeof__(p), basesize)
159153
MT_size = struct.calcsize('3nP0n')

Lib/test/test_sys.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -806,11 +806,7 @@ def inner():
806806
import collections
807807
check(collections.defaultdict.default_factory, size('3PP'))
808808
# wrapper_descriptor (descriptor object)
809-
try:
810-
import stackless
811-
slxtra = 'i'
812-
except:
813-
slxtra = ''
809+
slxtra = 'i' if test.support.stackless else ''
814810
check(int.__add__, size('3P2P' + slxtra))
815811
# method-wrapper (descriptor object)
816812
check({}.__iter__, size('2P'))
@@ -859,11 +855,7 @@ class C(object): pass
859855
nfrees = len(x.f_code.co_freevars)
860856
extras = x.f_code.co_stacksize + x.f_code.co_nlocals +\
861857
ncells + nfrees - 1
862-
try:
863-
import stackless
864-
slextra = 'P'
865-
except:
866-
slextra = ''
858+
slextra = 'P' if test.support.stackless else ''
867859
check(x, vsize('12P3ic' + CO_MAXBLOCKS*'3i' + slextra + 'P' + extras*'P'))
868860
# function
869861
def func(): pass

Stackless/changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ What's New in Stackless 3.X.X?
99

1010
*Release date: 20XX-XX-XX*
1111

12+
- https://bitbucket.org/stackless-dev/stackless/issues/126
13+
Load the module stackless early in all C-Python tests. This ensures a defined
14+
behaviour of the tests even, if the execution order gets randomised.
15+
1216
- https://bitbucket.org/stackless-dev/stackless/issues/125
1317
This document (changelog.txt) is included in the documentation as
1418
"What’s New in Stackless-Python ..."

0 commit comments

Comments
 (0)