Skip to content

Commit

Permalink
merge 3.3-slp (Stackless python#126, fix C-Python tests)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anselm Kruis committed Apr 12, 2017
2 parents 5b2c817 + afa7916 commit 131beaf
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 38 deletions.
8 changes: 1 addition & 7 deletions Lib/test/_test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@
import test.support
import test.script_helper

try:
import stackless
usingStackless = True
except ImportError:
usingStackless = False


# Skip tests if _multiprocessing wasn't built.
_multiprocessing = test.support.import_module('_multiprocessing')
Expand Down Expand Up @@ -1858,7 +1852,7 @@ def errback(exc):
p.close()
p.join()

@unittest.skipIf(usingStackless, "Stackless can pickle lambdas")
@unittest.skipIf(test.support.stackless, "Stackless can pickle lambdas")
def test_unpickleable_result(self):
from multiprocessing.pool import MaybeEncodingError
p = multiprocessing.Pool(2)
Expand Down
13 changes: 5 additions & 8 deletions Lib/test/pickletester.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from test.support import (
TestFailed, TESTFN, run_with_locale, no_tracing,
_2G, _4G, bigmemtest,
_2G, _4G, bigmemtest, stackless,
)

from pickle import bytes_types
Expand Down Expand Up @@ -400,12 +400,11 @@ def create_dynamic_class(name, bases):

# xrange(5) pickled from 2.x with protocol 2
DATA4 = b'\x80\x02c__builtin__\nxrange\nq\x00K\x00K\x05K\x01\x87q\x01Rq\x02.'
try:
import stackless
if stackless:
DATA4_SLP = b'\x80\x02cstackless._wrap\nrange\nq\x00K\x00K\x05K\x01\x87q\x01Rq\x02)b.'
except:
else:
DATA4_SLP = DATA4


# a SimpleCookie() object pickled from 2.x with protocol 2
DATA5 = (b'\x80\x02cCookie\nSimpleCookie\nq\x00)\x81q\x01U\x03key'
Expand Down Expand Up @@ -1285,9 +1284,7 @@ def test_unpickle_from_2x(self):
loaded = self.loads(DATA3)
self.assertEqual(loaded, set([1, 2]))
loaded = self.loads(DATA4_SLP)
try:
import stackless
except ImportError:
if not stackless:
self.assertEqual(type(loaded), type(range(0)))
else:
pass # stackless provides a fake range for unpickling
Expand Down
5 changes: 5 additions & 0 deletions Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
import urllib.error
import warnings

try:
import stackless
except ImportError:
stackless = None

try:
import _thread, threading
except ImportError:
Expand Down
8 changes: 2 additions & 6 deletions Lib/test/test_pep352.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import warnings
import os
from platform import system as platform_system
from test.support import stackless


class ExceptionClassTests(unittest.TestCase):
Expand Down Expand Up @@ -31,11 +32,6 @@ def test_inheritance(self):

inheritance_tree = open(os.path.join(os.path.split(__file__)[0],
'exception_hierarchy.txt'))
try:
import stackless
haveStackless = True
except:
haveStackless = False
try:
superclass_name = inheritance_tree.readline().rstrip()
try:
Expand All @@ -61,7 +57,7 @@ def test_inheritance(self):
if '[' in exc_name:
left_bracket = exc_name.index('[')
exc_name = exc_name[:left_bracket-1] # cover space
if not haveStackless and exc_name == "TaskletExit":
if stackless is None and exc_name == "TaskletExit":
exc_set.discard(exc_name)
continue
try:
Expand Down
8 changes: 1 addition & 7 deletions Lib/test/test_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@
except ImportError:
has_c_implementation = False

try:
import stackless
has_stackless = True
except ImportError:
has_stackless = False


class PickleTests(AbstractPickleModuleTests):
pass
Expand Down Expand Up @@ -153,7 +147,7 @@ class SizeofTests(unittest.TestCase):

def test_pickler(self):
basesize = support.calcobjsize('5P2n3i2n3iP' +
('P' if has_stackless else ''))
('P' if support.stackless else ''))
p = _pickle.Pickler(io.BytesIO())
self.assertEqual(object.__sizeof__(p), basesize)
MT_size = struct.calcsize('3nP0n')
Expand Down
12 changes: 2 additions & 10 deletions Lib/test/test_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,11 +806,7 @@ def inner():
import collections
check(collections.defaultdict.default_factory, size('3PP'))
# wrapper_descriptor (descriptor object)
try:
import stackless
slxtra = 'i'
except:
slxtra = ''
slxtra = 'i' if test.support.stackless else ''
check(int.__add__, size('3P2P' + slxtra))
# method-wrapper (descriptor object)
check({}.__iter__, size('2P'))
Expand Down Expand Up @@ -859,11 +855,7 @@ class C(object): pass
nfrees = len(x.f_code.co_freevars)
extras = x.f_code.co_stacksize + x.f_code.co_nlocals +\
ncells + nfrees - 1
try:
import stackless
slextra = 'P'
except:
slextra = ''
slextra = 'P' if test.support.stackless else ''
check(x, vsize('12P3ic' + CO_MAXBLOCKS*'3i' + slextra + 'P' + extras*'P'))
# function
def func(): pass
Expand Down
4 changes: 4 additions & 0 deletions Stackless/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ What's New in Stackless 3.X.X?

*Release date: 20XX-XX-XX*

- https://bitbucket.org/stackless-dev/stackless/issues/126
Load the module stackless early in all C-Python tests. This ensures a defined
behaviour of the tests even, if the execution order gets randomised.

- https://bitbucket.org/stackless-dev/stackless/issues/125
This document (changelog.txt) is included in the documentation as
"What’s New in Stackless-Python ..."
Expand Down

0 comments on commit 131beaf

Please sign in to comment.