summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2007-12-03 21:02:03 (GMT)
committerChristian Heimes <christian@cheimes.de>2007-12-03 21:02:03 (GMT)
commitcbf3b5cb76906fba15dbf59a1e83c540a447b907 (patch)
tree191de62298cf0af90595802cd47cff23d8f39d80 /Lib
parentf9290773fc026c5064fa96e1d06c3924e49fa89b (diff)
downloadcpython-cbf3b5cb76906fba15dbf59a1e83c540a447b907.zip
cpython-cbf3b5cb76906fba15dbf59a1e83c540a447b907.tar.gz
cpython-cbf3b5cb76906fba15dbf59a1e83c540a447b907.tar.bz2
Merged revisions 59275-59303 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! NOTE: The merge does NOT contain the modified file Python/import.c from r59288. I can't get it running. Nick, please check in the PEP 366 manually. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ........ r59279 | georg.brandl | 2007-12-02 19:17:50 +0100 (Sun, 02 Dec 2007) | 2 lines Fix a sentence I missed before. Do not merge to 3k. ........ r59281 | georg.brandl | 2007-12-02 22:58:54 +0100 (Sun, 02 Dec 2007) | 3 lines Add documentation for PySys_* functions. Written by Charlie Shepherd for GHOP. Also fixes #1245. ........ r59288 | nick.coghlan | 2007-12-03 13:55:17 +0100 (Mon, 03 Dec 2007) | 1 line Implement PEP 366 ........ r59290 | christian.heimes | 2007-12-03 14:47:29 +0100 (Mon, 03 Dec 2007) | 3 lines Applied my patch #1455 with some extra fixes for VS 2005 The new msvc9compiler module supports VS 2005 and VS 2008. I've also fixed build_ext to support PCbuild8 and PCbuild9 and backported my fix for xxmodule.c from py3k. The old code msvccompiler is still in place in case somebody likes to build an extension with VS 2003 or earlier. I've also updated the cygwin compiler module for VS 2005 and VS 2008. It works with VS 2005 but I'm unable to test it with VS 2008. We have to wait for a new version of cygwin. ........ r59291 | christian.heimes | 2007-12-03 14:55:16 +0100 (Mon, 03 Dec 2007) | 1 line Added comment to Misc/NEWS for r59290 ........ r59292 | christian.heimes | 2007-12-03 15:28:04 +0100 (Mon, 03 Dec 2007) | 1 line I followed MA Lemberg's suggestion and added comments to the late initialization of the type slots. ........ r59293 | facundo.batista | 2007-12-03 17:29:52 +0100 (Mon, 03 Dec 2007) | 3 lines Speedup and cleaning of __str__. Thanks Mark Dickinson. ........ r59294 | facundo.batista | 2007-12-03 18:55:00 +0100 (Mon, 03 Dec 2007) | 4 lines Faster _fix function, and some reordering for a more elegant coding. Thanks Mark Dickinson. ........ r59295 | martin.v.loewis | 2007-12-03 20:20:02 +0100 (Mon, 03 Dec 2007) | 5 lines Issue #1727780: Support loading pickles of random.Random objects created on 32-bit systems on 64-bit systems, and vice versa. As a consequence of the change, Random pickles created by Python 2.6 cannot be loaded in Python 2.5. ........ r59297 | facundo.batista | 2007-12-03 20:49:54 +0100 (Mon, 03 Dec 2007) | 3 lines Two small fixes. Issue 1547. ........ r59299 | georg.brandl | 2007-12-03 20:57:02 +0100 (Mon, 03 Dec 2007) | 2 lines #1548: fix apostroph placement. ........ r59300 | christian.heimes | 2007-12-03 21:01:02 +0100 (Mon, 03 Dec 2007) | 3 lines Patch #1537 from Chad Austin Change GeneratorExit's base class from Exception to BaseException (This time I'm applying the patch to the correct sandbox.) ........ r59302 | georg.brandl | 2007-12-03 21:03:46 +0100 (Mon, 03 Dec 2007) | 3 lines Add examples to the xmlrpclib docs. Written for GHOP by Josip Dzolonga. ........
Diffstat (limited to 'Lib')
-rw-r--r--Lib/decimal.py211
-rw-r--r--Lib/distutils/command/build_ext.py14
-rw-r--r--Lib/distutils/cygwinccompiler.py48
-rw-r--r--Lib/distutils/msvc9compiler.py658
-rw-r--r--Lib/distutils/msvccompiler.py8
-rw-r--r--Lib/random.py15
-rwxr-xr-xLib/runpy.py20
-rw-r--r--Lib/test/exception_hierarchy.txt2
-rw-r--r--Lib/test/randv2_32.pck633
-rw-r--r--Lib/test/randv2_64.pck633
-rw-r--r--Lib/test/randv3.pck633
-rw-r--r--Lib/test/test_cmd_line_script.py94
-rw-r--r--Lib/test/test_frozen.py10
-rw-r--r--Lib/test/test_generators.py15
-rw-r--r--Lib/test/test_pkg.py24
-rw-r--r--Lib/test/test_random.py13
-rw-r--r--Lib/test/test_runpy.py33
17 files changed, 2858 insertions, 206 deletions
diff --git a/Lib/decimal.py b/Lib/decimal.py
index 2c97dbd..39ce582 100644
--- a/Lib/decimal.py
+++ b/Lib/decimal.py
@@ -857,81 +857,51 @@ class Decimal(object):
Captures all of the information in the underlying representation.
"""
+ sign = ['', '-'][self._sign]
if self._is_special:
- if self._isnan():
- minus = '-'*self._sign
- if self._int == '0':
- info = ''
- else:
- info = self._int
- if self._isnan() == 2:
- return minus + 'sNaN' + info
- return minus + 'NaN' + info
- if self._isinfinity():
- minus = '-'*self._sign
- return minus + 'Infinity'
-
- if context is None:
- context = getcontext()
-
- tmp = list(self._int)
- numdigits = len(self._int)
- leftdigits = self._exp + numdigits
- if eng and not self: # self = 0eX wants 0[.0[0]]eY, not [[0]0]0eY
- if self._exp < 0 and self._exp >= -6: # short, no need for e/E
- s = '-'*self._sign + '0.' + '0'*(abs(self._exp))
- return s
- # exp is closest mult. of 3 >= self._exp
- exp = ((self._exp - 1)// 3 + 1) * 3
- if exp != self._exp:
- s = '0.'+'0'*(exp - self._exp)
- else:
- s = '0'
- if exp != 0:
- if context.capitals:
- s += 'E'
- else:
- s += 'e'
- if exp > 0:
- s += '+' # 0.0e+3, not 0.0e3
- s += str(exp)
- s = '-'*self._sign + s
- return s
- if eng:
- dotplace = (leftdigits-1)%3+1
- adjexp = leftdigits -1 - (leftdigits-1)%3
- else:
- adjexp = leftdigits-1
+ if self._exp == 'F':
+ return sign + 'Infinity'
+ elif self._exp == 'n':
+ return sign + 'NaN' + self._int
+ else: # self._exp == 'N'
+ return sign + 'sNaN' + self._int
+
+ # number of digits of self._int to left of decimal point
+ leftdigits = self._exp + len(self._int)
+
+ # dotplace is number of digits of self._int to the left of the
+ # decimal point in the mantissa of the output string (that is,
+ # after adjusting the exponent)
+ if self._exp <= 0 and leftdigits > -6:
+ # no exponent required
+ dotplace = leftdigits
+ elif not eng:
+ # usual scientific notation: 1 digit on left of the point
dotplace = 1
- if self._exp == 0:
- pass
- elif self._exp < 0 and adjexp >= 0:
- tmp.insert(leftdigits, '.')
- elif self._exp < 0 and adjexp >= -6:
- tmp[0:0] = ['0'] * int(-leftdigits)
- tmp.insert(0, '0.')
+ elif self._int == '0':
+ # engineering notation, zero
+ dotplace = (leftdigits + 1) % 3 - 1
else:
- if numdigits > dotplace:
- tmp.insert(dotplace, '.')
- elif numdigits < dotplace:
- tmp.extend(['0']*(dotplace-numdigits))
- if adjexp:
- if not context.capitals:
- tmp.append('e')
- else:
- tmp.append('E')
- if adjexp > 0:
- tmp.append('+')
- tmp.append(str(adjexp))
- if eng:
- while tmp[0:1] == ['0']:
- tmp[0:1] = []
- if len(tmp) == 0 or tmp[0] == '.' or tmp[0].lower() == 'e':
- tmp[0:0] = ['0']
- if self._sign:
- tmp.insert(0, '-')
+ # engineering notation, nonzero
+ dotplace = (leftdigits - 1) % 3 + 1
+
+ if dotplace <= 0:
+ intpart = '0'
+ fracpart = '.' + '0'*(-dotplace) + self._int
+ elif dotplace >= len(self._int):
+ intpart = self._int+'0'*(dotplace-len(self._int))
+ fracpart = ''
+ else:
+ intpart = self._int[:dotplace]
+ fracpart = '.' + self._int[dotplace:]
+ if leftdigits == dotplace:
+ exp = ''
+ else:
+ if context is None:
+ context = getcontext()
+ exp = ['e', 'E'][context.capitals] + "%+d" % (leftdigits-dotplace)
- return ''.join(tmp)
+ return sign + intpart + fracpart + exp
def to_eng_string(self, context=None):
"""Convert to engineering-type string.
@@ -1127,29 +1097,6 @@ class Decimal(object):
return other.__sub__(self, context=context)
- def _increment(self):
- """Special case of add, adding 1eExponent
-
- Since it is common, (rounding, for example) this adds
- (sign)*one E self._exp to the number more efficiently than add.
-
- Assumes that self is nonspecial.
-
- For example:
- Decimal('5.624e10')._increment() == Decimal('5.625e10')
- """
- L = list(map(int, self._int))
- L[-1] += 1
- spot = len(L)-1
- while L[spot] == 10:
- L[spot] = 0
- if spot == 0:
- L[0:0] = [1]
- break
- L[spot-1] += 1
- spot -= 1
- return _dec_from_triple(self._sign, "".join(map(str, L)), self._exp)
-
def __mul__(self, other, context=None):
"""Return self * other.
@@ -1580,8 +1527,18 @@ class Decimal(object):
# round if self has too many digits
if self._exp < exp_min:
context._raise_error(Rounded)
- ans = self._rescale(exp_min, context.rounding)
- if ans != self:
+ digits = len(self._int) + self._exp - exp_min
+ if digits < 0:
+ self = _dec_from_triple(self._sign, '1', exp_min-1)
+ digits = 0
+ this_function = getattr(self, self._pick_rounding_function[context.rounding])
+ changed = this_function(digits)
+ coeff = self._int[:digits] or '0'
+ if changed == 1:
+ coeff = str(int(coeff)+1)
+ ans = _dec_from_triple(self._sign, coeff, exp_min)
+
+ if changed:
context._raise_error(Inexact)
if self_is_subnormal:
context._raise_error(Underflow)
@@ -1614,66 +1571,68 @@ class Decimal(object):
# for each of the rounding functions below:
# self is a finite, nonzero Decimal
# prec is an integer satisfying 0 <= prec < len(self._int)
- # the rounded result will have exponent self._exp + len(self._int) - prec;
+ #
+ # each function returns either -1, 0, or 1, as follows:
+ # 1 indicates that self should be rounded up (away from zero)
+ # 0 indicates that self should be truncated, and that all the
+ # digits to be truncated are zeros (so the value is unchanged)
+ # -1 indicates that there are nonzero digits to be truncated
def _round_down(self, prec):
"""Also known as round-towards-0, truncate."""
- newexp = self._exp + len(self._int) - prec
- return _dec_from_triple(self._sign, self._int[:prec] or '0', newexp)
+ if _all_zeros(self._int, prec):
+ return 0
+ else:
+ return -1
def _round_up(self, prec):
"""Rounds away from 0."""
- newexp = self._exp + len(self._int) - prec
- tmp = _dec_from_triple(self._sign, self._int[:prec] or '0', newexp)
- for digit in self._int[prec:]:
- if digit != '0':
- return tmp._increment()
- return tmp
+ return -self._round_down(prec)
def _round_half_up(self, prec):
"""Rounds 5 up (away from 0)"""
if self._int[prec] in '56789':
- return self._round_up(prec)
+ return 1
+ elif _all_zeros(self._int, prec):
+ return 0
else:
- return self._round_down(prec)
+ return -1
def _round_half_down(self, prec):
"""Round 5 down"""
- if self._int[prec] == '5':
- for digit in self._int[prec+1:]:
- if digit != '0':
- break
- else:
- return self._round_down(prec)
- return self._round_half_up(prec)
+ if _exact_half(self._int, prec):
+ return -1
+ else:
+ return self._round_half_up(prec)
def _round_half_even(self, prec):
"""Round 5 to even, rest to nearest."""
- if prec and self._int[prec-1] in '13579':
- return self._round_half_up(prec)
+ if _exact_half(self._int, prec) and \
+ (prec == 0 or self._int[prec-1] in '02468'):
+ return -1
else:
- return self._round_half_down(prec)
+ return self._round_half_up(prec)
def _round_ceiling(self, prec):
"""Rounds up (not away from 0 if negative.)"""
if self._sign:
return self._round_down(prec)
else:
- return self._round_up(prec)
+ return -self._round_down(prec)
def _round_floor(self, prec):
"""Rounds down (not towards 0 if negative)"""
if not self._sign:
return self._round_down(prec)
else:
- return self._round_up(prec)
+ return -self._round_down(prec)
def _round_05up(self, prec):
"""Round down unless digit prec-1 is 0 or 5."""
- if prec == 0 or self._int[prec-1] in '05':
- return self._round_up(prec)
- else:
+ if prec and self._int[prec-1] not in '05':
return self._round_down(prec)
+ else:
+ return -self._round_down(prec)
def fma(self, other, third, context=None):
"""Fused multiply-add.
@@ -2330,7 +2289,11 @@ class Decimal(object):
self = _dec_from_triple(self._sign, '1', exp-1)
digits = 0
this_function = getattr(self, self._pick_rounding_function[rounding])
- return this_function(digits)
+ changed = this_function(digits)
+ coeff = self._int[:digits] or '0'
+ if changed == 1:
+ coeff = str(int(coeff)+1)
+ return _dec_from_triple(self._sign, coeff, exp)
def to_integral_exact(self, rounding=None, context=None):
"""Rounds to a nearby integer.
@@ -5236,6 +5199,8 @@ _parser = re.compile(r""" # A numeric string consists of:
$
""", re.VERBOSE | re.IGNORECASE).match
+_all_zeros = re.compile('0*$').match
+_exact_half = re.compile('50*$').match
del re
diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py
index ddf8f72..6d42278 100644
--- a/Lib/distutils/command/build_ext.py
+++ b/Lib/distutils/command/build_ext.py
@@ -14,6 +14,10 @@ from distutils.dep_util import newer_group
from distutils.extension import Extension
from distutils import log
+if os.name == 'nt':
+ from distutils.msvccompiler import get_build_version
+ MSVC_VERSION = int(get_build_version())
+
# An extension name is just a dot-separated list of Python NAMEs (ie.
# the same as a fully-qualified module name).
extension_name_re = re.compile \
@@ -172,7 +176,15 @@ class build_ext(Command):
# Append the source distribution include and library directories,
# this allows distutils on windows to work in the source tree
self.include_dirs.append(os.path.join(sys.exec_prefix, 'PC'))
- self.library_dirs.append(os.path.join(sys.exec_prefix, 'PCBuild'))
+ if MSVC_VERSION == 9:
+ self.library_dirs.append(os.path.join(sys.exec_prefix,
+ 'PCBuild9'))
+ elif MSVC_VERSION == 8:
+ self.library_dirs.append(os.path.join(sys.exec_prefix,
+ 'PCBuild8', 'win32release'))
+ else:
+ self.library_dirs.append(os.path.join(sys.exec_prefix,
+ 'PCBuild'))
# OS/2 (EMX) doesn't support Debug vs Release builds, but has the
# import libraries in its "Config" subdirectory
diff --git a/Lib/distutils/cygwinccompiler.py b/Lib/distutils/cygwinccompiler.py
index bec72ca..48875230 100644
--- a/Lib/distutils/cygwinccompiler.py
+++ b/Lib/distutils/cygwinccompiler.py
@@ -54,6 +54,29 @@ from distutils.file_util import write_file
from distutils.errors import DistutilsExecError, CompileError, UnknownFileError
from distutils import log
+def get_msvcr():
+ """Include the appropriate MSVC runtime library if Python was built
+ with MSVC 7.0 or later.
+ """
+ msc_pos = sys.version.find('MSC v.')
+ if msc_pos != -1:
+ msc_ver = sys.version[msc_pos+6:msc_pos+10]
+ if msc_ver == '1300':
+ # MSVC 7.0
+ return ['msvcr70']
+ elif msc_ver == '1310':
+ # MSVC 7.1
+ return ['msvcr71']
+ elif msc_ver == '1400':
+ # VS2005 / MSVC 8.0
+ return ['msvcr80']
+ elif msc_ver == '1500':
+ # VS2008 / MSVC 9.0
+ return ['msvcr90']
+ else:
+ raise ValueError("Unknown MS Compiler version %i " % msc_Ver)
+
+
class CygwinCCompiler (UnixCCompiler):
compiler_type = 'cygwin'
@@ -119,18 +142,9 @@ class CygwinCCompiler (UnixCCompiler):
self.warn(
"Consider upgrading to a newer version of gcc")
else:
- self.dll_libraries=[]
# Include the appropriate MSVC runtime library if Python was built
- # with MSVC 7.0 or 7.1.
- msc_pos = sys.version.find('MSC v.')
- if msc_pos != -1:
- msc_ver = sys.version[msc_pos+6:msc_pos+10]
- if msc_ver == '1300':
- # MSVC 7.0
- self.dll_libraries = ['msvcr70']
- elif msc_ver == '1310':
- # MSVC 7.1
- self.dll_libraries = ['msvcr71']
+ # with MSVC 7.0 or later.
+ self.dll_libraries = get_msvcr()
# __init__ ()
@@ -317,16 +331,8 @@ class Mingw32CCompiler (CygwinCCompiler):
self.dll_libraries=[]
# Include the appropriate MSVC runtime library if Python was built
- # with MSVC 7.0 or 7.1.
- msc_pos = sys.version.find('MSC v.')
- if msc_pos != -1:
- msc_ver = sys.version[msc_pos+6:msc_pos+10]
- if msc_ver == '1300':
- # MSVC 7.0
- self.dll_libraries = ['msvcr70']
- elif msc_ver == '1310':
- # MSVC 7.1
- self.dll_libraries = ['msvcr71']
+ # with MSVC 7.0 or later.
+ self.dll_libraries = get_msvcr()
# __init__ ()
diff --git a/Lib/distutils/msvc9compiler.py b/Lib/distutils/msvc9compiler.py
new file mode 100644
index 0000000..a6cff2c
--- /dev/null
+++ b/Lib/distutils/msvc9compiler.py
@@ -0,0 +1,658 @@
+"""distutils.msvc9compiler
+
+Contains MSVCCompiler, an implementation of the abstract CCompiler class
+for the Microsoft Visual Studio 2008.
+
+The module is compatible with VS 2005 and VS 2008. You can find legacy support
+for older versions of VS in distutils.msvccompiler.
+"""
+
+# Written by Perry Stoll
+# hacked by Robin Becker and Thomas Heller to do a better job of
+# finding DevStudio (through the registry)
+# ported to VS2005 and VS 2008 by Christian Heimes
+
+__revision__ = "$Id$"
+
+import os
+import subprocess
+import sys
+from distutils.errors import (DistutilsExecError, DistutilsPlatformError,
+ CompileError, LibError, LinkError)
+from distutils.ccompiler import (CCompiler, gen_preprocess_options,
+ gen_lib_options)
+from distutils import log
+
+import _winreg
+
+RegOpenKeyEx = _winreg.OpenKeyEx
+RegEnumKey = _winreg.EnumKey
+RegEnumValue = _winreg.EnumValue
+RegError = _winreg.error
+
+HKEYS = (_winreg.HKEY_USERS,
+ _winreg.HKEY_CURRENT_USER,
+ _winreg.HKEY_LOCAL_MACHINE,
+ _winreg.HKEY_CLASSES_ROOT)
+
+VS_BASE = r"Software\Microsoft\VisualStudio\%0.1f"
+WINSDK_BASE = r"Software\Microsoft\Microsoft SDKs\Windows"
+NET_BASE = r"Software\Microsoft\.NETFramework"
+ARCHS = {'DEFAULT' : 'x86',
+ 'intel' : 'x86', 'x86' : 'x86',
+ 'amd64' : 'x64', 'x64' : 'x64',
+ 'itanium' : 'ia64', 'ia64' : 'ia64',
+ }
+
+# The globals VERSION, ARCH, MACROS and VC_ENV are defined later
+
+class Reg:
+ """Helper class to read values from the registry
+ """
+
+ @classmethod
+ def get_value(cls, path, key):
+ for base in HKEYS:
+ d = cls.read_values(base, path)
+ if d and key in d:
+ return d[key]
+ raise KeyError(key)
+
+ @classmethod
+ def read_keys(cls, base, key):
+ """Return list of registry keys."""
+ try:
+ handle = RegOpenKeyEx(base, key)
+ except RegError:
+ return None
+ L = []
+ i = 0
+ while True:
+ try:
+ k = RegEnumKey(handle, i)
+ except RegError:
+ break
+ L.append(k)
+ i += 1
+ return L
+
+ @classmethod
+ def read_values(cls, base, key):
+ """Return dict of registry keys and values.
+
+ All names are converted to lowercase.
+ """
+ try:
+ handle = RegOpenKeyEx(base, key)
+ except RegError:
+ return None
+ d = {}
+ i = 0
+ while True:
+ try:
+ name, value, type = RegEnumValue(handle, i)
+ except RegError:
+ break
+ name = name.lower()
+ d[cls.convert_mbcs(name)] = cls.convert_mbcs(value)
+ i += 1
+ return d
+
+ @staticmethod
+ def convert_mbcs(s):
+ dec = getattr(s, "decode", None)
+ if dec is not None:
+ try:
+ s = dec("mbcs")
+ except UnicodeError:
+ pass
+ return s
+
+class MacroExpander:
+
+ def __init__(self, version):
+ self.macros = {}
+ self.vsbase = VS_BASE % version
+ self.load_macros(version)
+
+ def set_macro(self, macro, path, key):
+ self.macros["$(%s)" % macro] = Reg.get_value(path, key)
+
+ def load_macros(self, version):
+ self.set_macro("VCInstallDir", self.vsbase + r"\Setup\VC", "productdir")
+ self.set_macro("VSInstallDir", self.vsbase + r"\Setup\VS", "productdir")
+ self.set_macro("FrameworkDir", NET_BASE, "installroot")
+ try:
+ if version >= 8.0:
+ self.set_macro("FrameworkSDKDir", NET_BASE,
+ "sdkinstallrootv2.0")
+ else:
+ raise KeyError("sdkinstallrootv2.0")
+ except KeyError as exc: #
+ raise DistutilsPlatformError(
+ """Python was built with Visual Studio 2008;
+extensions must be built with a compiler than can generate compatible binaries.
+Visual Studio 2008 was not found on this system. If you have Cygwin installed,
+you can try compiling with MingW32, by passing "-c mingw32" to setup.py.""")
+
+ if version >= 9.0:
+ self.set_macro("FrameworkVersion", self.vsbase, "clr version")
+ self.set_macro("WindowsSdkDir", WINSDK_BASE, "currentinstallfolder")
+ else:
+ p = r"Software\Microsoft\NET Framework Setup\Product"
+ for base in HKEYS:
+ try:
+ h = RegOpenKeyEx(base, p)
+ except RegError:
+ continue
+ key = RegEnumKey(h, 0)
+ d = Reg.get_value(base, r"%s\%s" % (p, key))
+ self.macros["$(FrameworkVersion)"] = d["version"]
+
+ def sub(self, s):
+ for k, v in self.macros.items():
+ s = s.replace(k, v)
+ return s
+
+def get_build_version():
+ """Return the version of MSVC that was used to build Python.
+
+ For Python 2.3 and up, the version number is included in
+ sys.version. For earlier versions, assume the compiler is MSVC 6.
+ """
+ prefix = "MSC v."
+ i = sys.version.find(prefix)
+ if i == -1:
+ return 6
+ i = i + len(prefix)
+ s, rest = sys.version[i:].split(" ", 1)
+ majorVersion = int(s[:-2]) - 6
+ minorVersion = int(s[2:3]) / 10.0
+ # I don't think paths are affected by minor version in version 6
+ if majorVersion == 6:
+ minorVersion = 0
+ if majorVersion >= 6:
+ return majorVersion + minorVersion
+ # else we don't know what version of the compiler this is
+ return None
+
+def get_build_architecture():
+ """Return the processor architecture.
+
+ Possible results are "x86" or "amd64".
+ """
+ prefix = " bit ("
+ i = sys.version.find(prefix)
+ if i == -1:
+ return "x86"
+ j = sys.version.find(")", i)
+ sysarch = sys.version[i+len(prefix):j].lower()
+ arch = ARCHS.get(sysarch, None)
+ if arch is None:
+ return ARCHS['DEFAULT']
+ else:
+ return arch
+
+def normalize_and_reduce_paths(paths):
+ """Return a list of normalized paths with duplicates removed.
+
+ The current order of paths is maintained.
+ """
+ # Paths are normalized so things like: /a and /a/ aren't both preserved.
+ reduced_paths = []
+ for p in paths:
+ np = os.path.normpath(p)
+ # XXX(nnorwitz): O(n**2), if reduced_paths gets long perhaps use a set.
+ if np not in reduced_paths:
+ reduced_paths.append(np)
+ return reduced_paths
+
+def find_vcvarsall(version):
+ """Find the vcvarsall.bat file
+
+ At first it tries to find the productdir of VS 2008 in the registry. If
+ that fails it falls back to the VS90COMNTOOLS env var.
+ """
+ vsbase = VS_BASE % version
+ try:
+ productdir = Reg.get_value(r"%s\Setup\VC" % vsbase,
+ "productdir")
+ except KeyError:
+ log.debug("Unable to find productdir in registry")
+ productdir = None
+
+ if not productdir or not os.path.isdir(productdir):
+ toolskey = "VS%0.f0COMNTOOLS" % version
+ toolsdir = os.environ.get(toolskey, None)
+
+ if toolsdir and os.path.isdir(toolsdir):
+ productdir = os.path.join(toolsdir, os.pardir, os.pardir, "VC")
+ productdir = os.path.abspath(productdir)
+ if not os.path.isdir(productdir):
+ log.debug("%s is not a valid directory" % productdir)
+ return None
+ else:
+ log.debug("Env var %s is not set or invalid" % toolskey)
+ if not productdir:
+ log.debug("No productdir found")
+ return None
+ vcvarsall = os.path.join(productdir, "vcvarsall.bat")
+ if os.path.isfile(vcvarsall):
+ return vcvarsall
+ log.debug("Unable to find vcvarsall.bat")
+ return None
+
+def query_vcvarsall(version, arch="x86"):
+ """Launch vcvarsall.bat and read the settings from its environment
+ """
+ vcvarsall = find_vcvarsall(version)
+ interesting = set(("include", "lib", "libpath", "path"))
+ result = {}
+
+ if vcvarsall is None:
+ raise IOError("Unable to find vcvarsall.bat")
+ popen = subprocess.Popen('"%s" %s & set' % (vcvarsall, arch),
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ if popen.wait() != 0:
+ raise IOError(popen.stderr.read())
+
+ for line in popen.stdout:
+ line = Reg.convert_mbcs(line)
+ if '=' not in line:
+ continue
+ line = line.strip()
+ key, value = line.split('=')
+ key = key.lower()
+ if key in interesting:
+ if value.endswith(os.pathsep):
+ value = value[:-1]
+ result[key] = value
+
+ if len(result) != len(interesting):
+ raise ValueError(str(list(result.keys())))
+
+ return result
+
+# More globals
+VERSION = get_build_version()
+if VERSION < 8.0:
+ raise DistutilsPlatformError("VC %0.1f is not supported by this module" % VERSION)
+ARCH = get_build_architecture()
+# MACROS = MacroExpander(VERSION)
+VC_ENV = query_vcvarsall(VERSION, ARCH)
+
+class MSVCCompiler(CCompiler) :
+ """Concrete class that implements an interface to Microsoft Visual C++,
+ as defined by the CCompiler abstract class."""
+
+ compiler_type = 'msvc'
+
+ # Just set this so CCompiler's constructor doesn't barf. We currently
+ # don't use the 'set_executables()' bureaucracy provided by CCompiler,
+ # as it really isn't necessary for this sort of single-compiler class.
+ # Would be nice to have a consistent interface with UnixCCompiler,
+ # though, so it's worth thinking about.
+ executables = {}
+
+ # Private class data (need to distinguish C from C++ source for compiler)
+ _c_extensions = ['.c']
+ _cpp_extensions = ['.cc', '.cpp', '.cxx']
+ _rc_extensions = ['.rc']
+ _mc_extensions = ['.mc']
+
+ # Needed for the filename generation methods provided by the
+ # base class, CCompiler.
+ src_extensions = (_c_extensions + _cpp_extensions +
+ _rc_extensions + _mc_extensions)
+ res_extension = '.res'
+ obj_extension = '.obj'
+ static_lib_extension = '.lib'
+ shared_lib_extension = '.dll'
+ static_lib_format = shared_lib_format = '%s%s'
+ exe_extension = '.exe'
+
+ def __init__(self, verbose=0, dry_run=0, force=0):
+ CCompiler.__init__ (self, verbose, dry_run, force)
+ self.__version = VERSION
+ self.__arch = ARCH
+ self.__root = r"Software\Microsoft\VisualStudio"
+ # self.__macros = MACROS
+ self.__path = []
+ self.initialized = False
+
+ def initialize(self):
+ if "DISTUTILS_USE_SDK" in os.environ and "MSSdk" in os.environ and self.find_exe("cl.exe"):
+ # Assume that the SDK set up everything alright; don't try to be
+ # smarter
+ self.cc = "cl.exe"
+ self.linker = "link.exe"
+ self.lib = "lib.exe"
+ self.rc = "rc.exe"
+ self.mc = "mc.exe"
+ else:
+ self.__paths = VC_ENV['path'].split(os.pathsep)
+ os.environ['lib'] = VC_ENV['lib']
+ os.environ['include'] = VC_ENV['include']
+
+ if len(self.__paths) == 0:
+ raise DistutilsPlatformError("Python was built with %s, "
+ "and extensions need to be built with the same "
+ "version of the compiler, but it isn't installed."
+ % self.__product)
+
+ self.cc = self.find_exe("cl.exe")
+ self.linker = self.find_exe("link.exe")
+ self.lib = self.find_exe("lib.exe")
+ self.rc = self.find_exe("rc.exe") # resource compiler
+ self.mc = self.find_exe("mc.exe") # message compiler
+ #self.set_path_env_var('lib')
+ #self.set_path_env_var('include')
+
+ # extend the MSVC path with the current path
+ try:
+ for p in os.environ['path'].split(';'):
+ self.__paths.append(p)
+ except KeyError:
+ pass
+ self.__paths = normalize_and_reduce_paths(self.__paths)
+ os.environ['path'] = ";".join(self.__paths)
+
+ self.preprocess_options = None
+ if self.__arch == "x86":
+ self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3',
+ '/DNDEBUG']
+ self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3',
+ '/Z7', '/D_DEBUG']
+ else:
+ # Win64
+ self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3', '/GS-' ,
+ '/DNDEBUG']
+ self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3', '/GS-',
+ '/Z7', '/D_DEBUG']
+
+ self.ldflags_shared = ['/DLL', '/nologo', '/INCREMENTAL:NO']
+ if self.__version >= 7:
+ self.ldflags_shared_debug = [
+ '/DLL', '/nologo', '/INCREMENTAL:no', '/DEBUG', '/pdb:None'
+ ]
+ self.ldflags_static = [ '/nologo']
+
+ self.initialized = True
+
+ # -- Worker methods ------------------------------------------------
+
+ def object_filenames(self,
+ source_filenames,
+ strip_dir=0,
+ output_dir=''):
+ # Copied from ccompiler.py, extended to return .res as 'object'-file
+ # for .rc input file
+ if output_dir is None: output_dir = ''
+ obj_names = []
+ for src_name in source_filenames:
+ (base, ext) = os.path.splitext (src_name)
+ base = os.path.splitdrive(base)[1] # Chop off the drive
+ base = base[os.path.isabs(base):] # If abs, chop off leading /
+ if ext not in self.src_extensions:
+ # Better to raise an exception instead of silently continuing
+ # and later complain about sources and targets having
+ # different lengths
+ raise CompileError ("Don't know how to compile %s" % src_name)
+ if strip_dir:
+ base = os.path.basename (base)
+ if ext in self._rc_extensions:
+ obj_names.append (os.path.join (output_dir,
+ base + self.res_extension))
+ elif ext in self._mc_extensions:
+ obj_names.append (os.path.join (output_dir,
+ base + self.res_extension))
+ else:
+ obj_names.append (os.path.join (output_dir,
+ base + self.obj_extension))
+ return obj_names
+
+
+ def compile(self, sources,
+ output_dir=None, macros=None, include_dirs=None, debug=0,
+ extra_preargs=None, extra_postargs=None, depends=None):
+
+ if not self.initialized:
+ self.initialize()
+ compile_info = self._setup_compile(output_dir, macros, include_dirs,
+ sources, depends, extra_postargs)
+ macros, objects, extra_postargs, pp_opts, build = compile_info
+
+ compile_opts = extra_preargs or []
+ compile_opts.append ('/c')
+ if debug:
+ compile_opts.extend(self.compile_options_debug)
+ else:
+ compile_opts.extend(self.compile_options)
+
+ for obj in objects:
+ try:
+ src, ext = build[obj]
+ except KeyError:
+ continue
+ if debug:
+ # pass the full pathname to MSVC in debug mode,
+ # this allows the debugger to find the source file
+ # without asking the user to browse for it
+ src = os.path.abspath(src)
+
+ if ext in self._c_extensions:
+ input_opt = "/Tc" + src
+ elif ext in self._cpp_extensions:
+ input_opt = "/Tp" + src
+ elif ext in self._rc_extensions:
+ # compile .RC to .RES file
+ input_opt = src
+ output_opt = "/fo" + obj
+ try:
+ self.spawn([self.rc] + pp_opts +
+ [output_opt] + [input_opt])
+ except DistutilsExecError as msg:
+ raise CompileError(msg)
+ continue
+ elif ext in self._mc_extensions:
+ # Compile .MC to .RC file to .RES file.
+ # * '-h dir' specifies the directory for the
+ # generated include file
+ # * '-r dir' specifies the target directory of the
+ # generated RC file and the binary message resource
+ # it includes
+ #
+ # For now (since there are no options to change this),
+ # we use the source-directory for the include file and
+ # the build directory for the RC file and message
+ # resources. This works at least for win32all.
+ h_dir = os.path.dirname(src)
+ rc_dir = os.path.dirname(obj)
+ try:
+ # first compile .MC to .RC and .H file
+ self.spawn([self.mc] +
+ ['-h', h_dir, '-r', rc_dir] + [src])
+ base, _ = os.path.splitext (os.path.basename (src))
+ rc_file = os.path.join (rc_dir, base + '.rc')
+ # then compile .RC to .RES file
+ self.spawn([self.rc] +
+ ["/fo" + obj] + [rc_file])
+
+ except DistutilsExecError as msg:
+ raise CompileError(msg)
+ continue
+ else:
+ # how to handle this file?
+ raise CompileError("Don't know how to compile %s to %s"
+ % (src, obj))
+
+ output_opt = "/Fo" + obj
+ try:
+ self.spawn([self.cc] + compile_opts + pp_opts +
+ [input_opt, output_opt] +
+ extra_postargs)
+ except DistutilsExecError as msg:
+ raise CompileError(msg)
+
+ return objects
+
+
+ def create_static_lib(self,
+ objects,
+ output_libname,
+ output_dir=None,
+ debug=0,
+ target_lang=None):
+
+ if not self.initialized:
+ self.initialize()
+ (objects, output_dir) = self._fix_object_args(objects, output_dir)
+ output_filename = self.library_filename(output_libname,
+ output_dir=output_dir)
+
+ if self._need_link(objects, output_filename):
+ lib_args = objects + ['/OUT:' + output_filename]
+ if debug:
+ pass # XXX what goes here?
+ try:
+ self.spawn([self.lib] + lib_args)
+ except DistutilsExecError as msg:
+ raise LibError(msg)
+ else:
+ log.debug("skipping %s (up-to-date)", output_filename)
+
+
+ def link(self,
+ target_desc,
+ objects,
+ output_filename,
+ output_dir=None,
+ libraries=None,
+ library_dirs=None,
+ runtime_library_dirs=None,
+ export_symbols=None,
+ debug=0,
+ extra_preargs=None,
+ extra_postargs=None,
+ build_temp=None,
+ target_lang=None):
+
+ if not self.initialized:
+ self.initialize()
+ (objects, output_dir) = self._fix_object_args(objects, output_dir)
+ fixed_args = self._fix_lib_args(libraries, library_dirs,
+ runtime_library_dirs)
+ (libraries, library_dirs, runtime_library_dirs) = fixed_args
+
+ if runtime_library_dirs:
+ self.warn ("I don't know what to do with 'runtime_library_dirs': "
+ + str (runtime_library_dirs))
+
+ lib_opts = gen_lib_options(self,
+ library_dirs, runtime_library_dirs,
+ libraries)
+ if output_dir is not None:
+ output_filename = os.path.join(output_dir, output_filename)
+
+ if self._need_link(objects, output_filename):
+ if target_desc == CCompiler.EXECUTABLE:
+ if debug:
+ ldflags = self.ldflags_shared_debug[1:]
+ else:
+ ldflags = self.ldflags_shared[1:]
+ else:
+ if debug:
+ ldflags = self.ldflags_shared_debug
+ else:
+ ldflags = self.ldflags_shared
+
+ export_opts = []
+ for sym in (export_symbols or []):
+ export_opts.append("/EXPORT:" + sym)
+
+ ld_args = (ldflags + lib_opts + export_opts +
+ objects + ['/OUT:' + output_filename])
+
+ # The MSVC linker generates .lib and .exp files, which cannot be
+ # suppressed by any linker switches. The .lib files may even be
+ # needed! Make sure they are generated in the temporary build
+ # directory. Since they have different names for debug and release
+ # builds, they can go into the same directory.
+ if export_symbols is not None:
+ (dll_name, dll_ext) = os.path.splitext(
+ os.path.basename(output_filename))
+ implib_file = os.path.join(
+ os.path.dirname(objects[0]),
+ self.library_filename(dll_name))
+ ld_args.append ('/IMPLIB:' + implib_file)
+
+ if extra_preargs:
+ ld_args[:0] = extra_preargs
+ if extra_postargs:
+ ld_args.extend(extra_postargs)
+
+ self.mkpath(os.path.dirname(output_filename))
+ try:
+ self.spawn([self.linker] + ld_args)
+ except DistutilsExecError as msg:
+ raise LinkError(msg)
+
+ else:
+ log.debug("skipping %s (up-to-date)", output_filename)
+
+
+ # -- Miscellaneous methods -----------------------------------------
+ # These are all used by the 'gen_lib_options() function, in
+ # ccompiler.py.
+
+ def library_dir_option(self, dir):
+ return "/LIBPATH:" + dir
+
+ def runtime_library_dir_option(self, dir):
+ raise DistutilsPlatformError(
+ "don't know how to set runtime library search path for MSVC++")
+
+ def library_option(self, lib):
+ return self.library_filename(lib)
+
+
+ def find_library_file(self, dirs, lib, debug=0):
+ # Prefer a debugging library if found (and requested), but deal
+ # with it if we don't have one.
+ if debug:
+ try_names = [lib + "_d", lib]
+ else:
+ try_names = [lib]
+ for dir in dirs:
+ for name in try_names:
+ libfile = os.path.join(dir, self.library_filename (name))
+ if os.path.exists(libfile):
+ return libfile
+ else:
+ # Oops, didn't find it in *any* of 'dirs'
+ return None
+
+ # Helper methods for using the MSVC registry settings
+
+ def find_exe(self, exe):
+ """Return path to an MSVC executable program.
+
+ Tries to find the program in several places: first, one of the
+ MSVC program search paths from the registry; next, the directories
+ in the PATH environment variable. If any of those work, return an
+ absolute path that is known to exist. If none of them work, just
+ return the original program name, 'exe'.
+ """
+ for p in self.__paths:
+ fn = os.path.join(os.path.abspath(p), exe)
+ if os.path.isfile(fn):
+ return fn
+
+ # didn't find it; try existing path
+ for p in os.environ['Path'].split(';'):
+ fn = os.path.join(os.path.abspath(p),exe)
+ if os.path.isfile(fn):
+ return fn
+
+ return exe
diff --git a/Lib/distutils/msvccompiler.py b/Lib/distutils/msvccompiler.py
index 6bf969f..3b4e9c9 100644
--- a/Lib/distutils/msvccompiler.py
+++ b/Lib/distutils/msvccompiler.py
@@ -632,3 +632,11 @@ class MSVCCompiler(CCompiler) :
p = self.get_msvc_paths(name)
if p:
os.environ[name] = ';'.join(p)
+
+
+if get_build_version() >= 8.0:
+ log.debug("Importing new compiler from distutils.msvc9compiler")
+ OldMSVCCompiler = MSVCCompiler
+ from distutils.msvc9compiler import MSVCCompiler
+ from distutils.msvc9compiler import get_build_architecture
+ from distutils.msvc9compiler import MacroExpander
diff --git a/Lib/random.py b/Lib/random.py
index e2bfcfd..d8d2c1e 100644
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -83,7 +83,7 @@ class Random(_random.Random):
"""
- VERSION = 2 # used by getstate/setstate
+ VERSION = 3 # used by getstate/setstate
def __init__(self, x=None):
"""Initialize an instance.
@@ -120,9 +120,20 @@ class Random(_random.Random):
def setstate(self, state):
"""Restore internal state from object returned by getstate()."""
version = state[0]
- if version == 2:
+ if version == 3:
version, internalstate, self.gauss_next = state
super().setstate(internalstate)
+ elif version == 2:
+ version, internalstate, self.gauss_next = state
+ # In version 2, the state was saved as signed ints, which causes
+ # inconsistencies between 32/64-bit systems. The state is
+ # really unsigned 32-bit ints, so we convert negative ints from
+ # version 2 to positive longs for version 3.
+ try:
+ internalstate = tuple( x % (2**32) for x in internalstate )
+ except ValueError as e:
+ raise TypeError from e
+ super(Random, self).setstate(internalstate)
else:
raise ValueError("state with version %s passed to "
"Random.setstate() of version %s" %
diff --git a/Lib/runpy.py b/Lib/runpy.py
index 406e081..49ce34b 100755
--- a/Lib/runpy.py
+++ b/Lib/runpy.py
@@ -23,19 +23,20 @@ __all__ = [
def _run_code(code, run_globals, init_globals=None,
mod_name=None, mod_fname=None,
- mod_loader=None):
+ mod_loader=None, pkg_name=None):
"""Helper for _run_module_code"""
if init_globals is not None:
run_globals.update(init_globals)
run_globals.update(__name__ = mod_name,
__file__ = mod_fname,
- __loader__ = mod_loader)
+ __loader__ = mod_loader,
+ __package__ = pkg_name)
exec(code, run_globals)
return run_globals
def _run_module_code(code, init_globals=None,
mod_name=None, mod_fname=None,
- mod_loader=None):
+ mod_loader=None, pkg_name=None):
"""Helper for run_module"""
# Set up the top level namespace dictionary
temp_module = imp.new_module(mod_name)
@@ -49,7 +50,8 @@ def _run_module_code(code, init_globals=None,
sys.modules[mod_name] = temp_module
try:
_run_code(code, mod_globals, init_globals,
- mod_name, mod_fname, mod_loader)
+ mod_name, mod_fname,
+ mod_loader, pkg_name)
finally:
sys.argv[0] = saved_argv0
if restore_module:
@@ -95,11 +97,12 @@ def _run_module_as_main(mod_name, set_argv0=True):
__loader__
"""
loader, code, fname = _get_module_details(mod_name)
+ pkg_name = mod_name.rpartition('.')[0]
main_globals = sys.modules["__main__"].__dict__
if set_argv0:
sys.argv[0] = fname
return _run_code(code, main_globals, None,
- "__main__", fname, loader)
+ "__main__", fname, loader, pkg_name)
def run_module(mod_name, init_globals=None,
run_name=None, alter_sys=False):
@@ -110,13 +113,14 @@ def run_module(mod_name, init_globals=None,
loader, code, fname = _get_module_details(mod_name)
if run_name is None:
run_name = mod_name
+ pkg_name = mod_name.rpartition('.')[0]
if alter_sys:
return _run_module_code(code, init_globals, run_name,
- fname, loader)
+ fname, loader, pkg_name)
else:
# Leave the sys module alone
- return _run_code(code, {}, init_globals,
- run_name, fname, loader)
+ return _run_code(code, {}, init_globals, run_name,
+ fname, loader, pkg_name)
if __name__ == "__main__":
diff --git a/Lib/test/exception_hierarchy.txt b/Lib/test/exception_hierarchy.txt
index 965252c..73ccb66 100644
--- a/Lib/test/exception_hierarchy.txt
+++ b/Lib/test/exception_hierarchy.txt
@@ -1,8 +1,8 @@
BaseException
+-- SystemExit
+-- KeyboardInterrupt
+ +-- GeneratorExit
+-- Exception
- +-- GeneratorExit
+-- StopIteration
+-- ArithmeticError
| +-- FloatingPointError
diff --git a/Lib/test/randv2_32.pck b/Lib/test/randv2_32.pck
new file mode 100644
index 0000000..587ab24
--- /dev/null
+++ b/Lib/test/randv2_32.pck
@@ -0,0 +1,633 @@
+crandom
+Random
+p0
+(tRp1
+(I2
+(I-2147483648
+I-845974985
+I-1294090086
+I1193659239
+I-1849481736
+I-946579732
+I-34406770
+I1749049471
+I1997774682
+I1432026457
+I1288127073
+I-943175655
+I-1718073964
+I339993548
+I-1045260575
+I582505037
+I-1555108250
+I-1114765620
+I1578648750
+I-350384412
+I-20845848
+I-288255314
+I738790953
+I1901249641
+I1999324672
+I-277361068
+I-1515885839
+I2061761596
+I-809068089
+I1287981136
+I258129492
+I-6303745
+I-765148337
+I1090344911
+I1653434703
+I-1242923628
+I1639171313
+I-1870042660
+I-1655014050
+I345609048
+I2093410138
+I1963263374
+I-2122098342
+I1336859961
+I-810942729
+I945857753
+I2103049942
+I623922684
+I1418349549
+I690877342
+I754973107
+I-1605111847
+I1607137813
+I-1704917131
+I1317536428
+I1714882872
+I-1665385120
+I1823694397
+I-1790836866
+I-1696724812
+I-603979847
+I-498599394
+I-341265291
+I927388804
+I1778562135
+I1716895781
+I1023198122
+I1726145967
+I941955525
+I1240148950
+I-1929634545
+I-1288147083
+I-519318335
+I754559777
+I-707571958
+I374604022
+I420424061
+I-1095443486
+I1621934944
+I-1220502522
+I-140049608
+I-918917122
+I304341024
+I-1637446057
+I-353934485
+I1973436235
+I433380241
+I-686759465
+I-2111563154
+I-573422032
+I804304541
+I1513063483
+I1417381689
+I-804778729
+I211756408
+I544537322
+I890881641
+I150378374
+I1765739392
+I1011604116
+I584889095
+I1400520554
+I413747808
+I-1741992587
+I-1882421574
+I-1373001903
+I-1885348538
+I903819480
+I1083220038
+I-1318105424
+I1740421404
+I1693089625
+I775965557
+I1319608037
+I-2127475785
+I-367562895
+I-1416273451
+I1693000327
+I-1217438421
+I834405522
+I-128287275
+I864057548
+I-973917356
+I7304111
+I1712253182
+I1353897741
+I672982288
+I1778575559
+I-403058377
+I-38540378
+I-1393713496
+I13193171
+I1127196200
+I205176472
+I-2104790506
+I299985416
+I1403541685
+I-1018270667
+I-1980677490
+I-1182625797
+I1637015181
+I-1795357414
+I1514413405
+I-924516237
+I-1841873650
+I-1014591269
+I1576616065
+I-1319103135
+I-120847840
+I2062259778
+I-9285070
+I1160890300
+I-575137313
+I-1509108275
+I46701926
+I-287560914
+I-256824960
+I577558250
+I900598310
+I944607867
+I2121154920
+I-1170505192
+I-1347170575
+I77247778
+I-1899015765
+I1234103327
+I1027053658
+I1934632322
+I-792031234
+I1147322536
+I1290655117
+I1002059715
+I1325898538
+I896029793
+I-790940694
+I-980470721
+I-1922648255
+I-951672814
+I291543943
+I1158740218
+I-1959023736
+I-1977185236
+I1527900076
+I514104195
+I-814154113
+I-593157883
+I-1023704660
+I1285688377
+I-2117525386
+I768954360
+I-38676846
+I-799848659
+I-1305517259
+I-1938213641
+I-462146758
+I-1663302892
+I1899591069
+I-22935388
+I-275856976
+I-443736893
+I-739441156
+I93862068
+I-838105669
+I1735629845
+I-817484206
+I280814555
+I1753547179
+I1811123479
+I1974543632
+I-48447465
+I-642694345
+I-531149613
+I518698953
+I-221642627
+I-686519187
+I776644303
+I257774400
+I-1499134857
+I-1055273455
+I-237023943
+I1981752330
+I-917671662
+I-372905983
+I1588058420
+I1171936660
+I-1730977121
+I1360028989
+I1769469287
+I1910709542
+I-852692959
+I1396944667
+I-1723999155
+I-310975435
+I-1965453954
+I-1636858570
+I2005650794
+I680293715
+I1355629386
+I844514684
+I-1909152807
+I-808646074
+I1936510018
+I1134413810
+I-143411047
+I-1478436304
+I1394969244
+I-1170110660
+I1963112086
+I-1518351049
+I-1506287443
+I-455023090
+I-855366028
+I-1746785568
+I933990882
+I-703625141
+I-285036872
+I188277905
+I1471578620
+I-981382835
+I-586974220
+I945619758
+I1608778444
+I-1708548066
+I-1897629320
+I-42617810
+I-836840790
+I539154487
+I-235706962
+I332074418
+I-575700589
+I1534608003
+I632116560
+I-1819760653
+I642052958
+I-722391771
+I-1104719475
+I-1196847084
+I582413973
+I1563394876
+I642007944
+I108989456
+I361625014
+I677308625
+I-1806529496
+I-959050708
+I-1858251070
+I-216069832
+I701624579
+I501238033
+I12287030
+I1895107107
+I2089098638
+I-874806230
+I1236279203
+I563718890
+I-544352489
+I-1879707498
+I1767583393
+I-1776604656
+I-693294301
+I-88882831
+I169303357
+I1299196152
+I-1122791089
+I-379157172
+I1934671851
+I1575736961
+I-19573174
+I-1401511009
+I9305167
+I-1115174467
+I1670735537
+I1226436501
+I-2004524535
+I1767463878
+I-1722855079
+I-559413926
+I1529810851
+I1201272087
+I-1297130971
+I-1188149982
+I1396557188
+I-370358342
+I-1006619702
+I1600942463
+I906087130
+I-76991909
+I2069580179
+I-1674195181
+I-2098404729
+I-940972459
+I-573399187
+I-1930386277
+I-721311199
+I-647834744
+I1452181671
+I688681916
+I1812793731
+I1704380620
+I-1389615179
+I866287837
+I-1435265007
+I388400782
+I-147986600
+I-1613598851
+I-1040347408
+I782063323
+I-239282031
+I-575966722
+I-1865208174
+I-481365146
+I579572803
+I-1239481494
+I335361280
+I-429722947
+I1881772789
+I1908103808
+I1653690013
+I-1668588344
+I1933787953
+I-2033480609
+I22162797
+I-1516527040
+I-461232482
+I-16201372
+I-2043092030
+I114990337
+I-1524090084
+I1456374020
+I458606440
+I-1928083218
+I227773125
+I-1129028159
+I1678689
+I1575896907
+I-1792935220
+I-151387575
+I64084088
+I-95737215
+I1337335688
+I-1963466345
+I1243315130
+I-1798518411
+I-546013212
+I-607065396
+I1219824160
+I1715218469
+I-1368163783
+I1701552913
+I-381114888
+I1068821717
+I266062971
+I-2066513172
+I1767407229
+I-780936414
+I-705413443
+I-1256268847
+I1646874149
+I1107690353
+I839133072
+I67001749
+I860763503
+I884880613
+I91977084
+I755371933
+I420745153
+I-578480690
+I-1520193551
+I1011369331
+I-99754575
+I-733141064
+I-500598588
+I1081124271
+I-1341266575
+I921002612
+I-848852487
+I-1904467341
+I-1294256973
+I-94074714
+I-1778758498
+I-1401188547
+I2101830578
+I2058864877
+I-272875991
+I-1375854779
+I-1332937870
+I619425525
+I-1034529639
+I-36454393
+I-2030499985
+I-1637127500
+I-1408110287
+I-2108625749
+I-961007436
+I1475654951
+I-791946251
+I1667792115
+I1818978830
+I1897980514
+I1959546477
+I-74478911
+I-508643347
+I461594399
+I538802715
+I-2094970071
+I-2076660253
+I1091358944
+I1944029246
+I-343957436
+I-1915845022
+I1237620188
+I1144125174
+I1522190520
+I-670252952
+I-19469226
+I675626510
+I758750096
+I909724354
+I-1846259652
+I544669343
+I445182495
+I-821519930
+I-1124279685
+I-1668995122
+I1653284793
+I-678555151
+I-687513207
+I1558259445
+I-1978866839
+I1558835601
+I1732138472
+I-1904793363
+I620020296
+I1562597874
+I1942617227
+I-549632552
+I721603795
+I417978456
+I-1355281522
+I-538065208
+I-1079523196
+I187375699
+I449064972
+I1018083947
+I1632388882
+I-493269866
+I92769041
+I1477146750
+I1782708404
+I444873376
+I1085851104
+I-6823272
+I-1302251853
+I1602050688
+I-1042187824
+I287161745
+I-1972094479
+I103271491
+I2131619773
+I-2064115870
+I766815498
+I990861458
+I-1664407378
+I1083746756
+I-1018331904
+I-677315687
+I-951670647
+I-952356874
+I451460609
+I-818615564
+I851439508
+I656362634
+I-1351240485
+I823378078
+I1985597385
+I597757740
+I-1512303057
+I1590872798
+I1108424213
+I818850898
+I-1368594306
+I-201107761
+I1793370378
+I1247597611
+I-1594326264
+I-601653890
+I427642759
+I248322113
+I-292545338
+I1708985870
+I1917042771
+I429354503
+I-478470329
+I793960014
+I369939133
+I1728189157
+I-518963626
+I-278523974
+I-1877289696
+I-2088617658
+I-1367940049
+I-62295925
+I197975119
+I-252900777
+I803430539
+I485759441
+I-528283480
+I-1287443963
+I-478617444
+I-861906946
+I-649095555
+I-893184337
+I2050571322
+I803433133
+I1629574571
+I1649720417
+I-2050225209
+I1208598977
+I720314344
+I-615166251
+I-835077127
+I-1405372429
+I995698064
+I148123240
+I-943016676
+I-594609622
+I-1381596711
+I1017195301
+I-1268893013
+I-1815985179
+I-1393570351
+I-870027364
+I-476064472
+I185582645
+I569863326
+I1098584267
+I-1599147006
+I-485054391
+I-852098365
+I1477320135
+I222316762
+I-1515583064
+I-935051367
+I393383063
+I819617226
+I722921837
+I-1241806499
+I-1358566385
+I1666813591
+I1333875114
+I-1663688317
+I-47254623
+I-885800726
+I307388991
+I-1219459496
+I1374870300
+I2132047877
+I-1385624198
+I-245139206
+I1015139214
+I-926198559
+I1969798868
+I-1950480619
+I-559193432
+I-1256446518
+I-1983476981
+I790179655
+I1004289659
+I1541827617
+I1555805575
+I501127333
+I-1123446797
+I-453230915
+I2035104883
+I1296122398
+I-1843698604
+I-715464588
+I337143971
+I-1972119192
+I606777909
+I726977302
+I-1149501872
+I-1963733522
+I-1797504644
+I624
+tp2
+Ntp3
+b. \ No newline at end of file
diff --git a/Lib/test/randv2_64.pck b/Lib/test/randv2_64.pck
new file mode 100644
index 0000000..090dd6f
--- /dev/null
+++ b/Lib/test/randv2_64.pck
@@ -0,0 +1,633 @@
+crandom
+Random
+p0
+(tRp1
+(I2
+(I2147483648
+I1812115682
+I2741755497
+I1028055730
+I809166036
+I2773628650
+I62321950
+I535290043
+I349877800
+I976167039
+I2490696940
+I3631326955
+I2107991114
+I2941205793
+I3199611605
+I1871971556
+I1456108540
+I2984591044
+I140836801
+I4203227310
+I3652722980
+I4031971234
+I555769760
+I697301296
+I2347638880
+I3302335858
+I320255162
+I2553586608
+I1570224361
+I2838780912
+I2315834918
+I2351348158
+I3545433015
+I2292018579
+I1177569331
+I758497559
+I2913311175
+I1014948880
+I1793619243
+I3982451053
+I3850988342
+I2393984324
+I1583100093
+I3144742543
+I3655047493
+I3507532385
+I3094515442
+I350042434
+I2455294844
+I1038739312
+I313809152
+I189433072
+I1653165452
+I4186650593
+I19281455
+I2589680619
+I4145931590
+I4283266118
+I636283172
+I943618337
+I3170184633
+I2308766231
+I634615159
+I538152647
+I2079576891
+I1029442616
+I3410689412
+I1370292761
+I1071718978
+I2139496322
+I1876699543
+I3485866187
+I3157490130
+I1633105386
+I1453253160
+I3841322080
+I3789608924
+I4110770792
+I95083673
+I931354627
+I2065389591
+I3448339827
+I3348204577
+I3263528560
+I2411324590
+I4003055026
+I1869670093
+I2737231843
+I4150701155
+I2689667621
+I2993263224
+I3239890140
+I1191430483
+I1214399779
+I3623428533
+I1817058866
+I3052274451
+I326030082
+I1505129312
+I2306812262
+I1349150363
+I1099127895
+I2543465574
+I2396380193
+I503926466
+I1607109730
+I3451716817
+I58037114
+I4290081119
+I947517597
+I3083440186
+I520522630
+I2948962496
+I4184319574
+I2957636335
+I668374201
+I2325446473
+I472785314
+I3791932366
+I573017189
+I2185725379
+I1262251492
+I3525089379
+I2951262653
+I1305347305
+I940958122
+I3343754566
+I359371744
+I3874044973
+I396897232
+I147188248
+I716683703
+I4013880315
+I1133359586
+I1794612249
+I3480815192
+I3988787804
+I1729355809
+I573408542
+I1419310934
+I1770030447
+I3552845567
+I1693976502
+I1271189893
+I2298236738
+I2049219027
+I3464198070
+I1233574082
+I1007451781
+I1838253750
+I687096593
+I1131375603
+I1223013895
+I1490478435
+I339265439
+I4232792659
+I491538536
+I2816256769
+I1044097522
+I2566227049
+I748762793
+I1511830494
+I3593259822
+I4121279213
+I3735541309
+I3609794797
+I1939942331
+I377570434
+I1437957554
+I1831285696
+I55062811
+I2046783110
+I1303902283
+I1838349877
+I420993556
+I1256392560
+I2795216506
+I2783687924
+I3322303169
+I512794749
+I308405826
+I517164429
+I3320436022
+I1328403632
+I2269184746
+I3729522810
+I3304314450
+I2238756124
+I1690581361
+I3813277532
+I4119706879
+I2659447875
+I388818978
+I2064580814
+I1586227676
+I2627522685
+I2017792269
+I547928109
+I859107450
+I1062238929
+I858886237
+I3795783146
+I4173914756
+I3835915965
+I3329504821
+I3494579904
+I838863205
+I3399734724
+I4247387481
+I3618414834
+I2984433798
+I2165205561
+I4260685684
+I3045904244
+I3450093836
+I3597307595
+I3215851166
+I3162801328
+I2558283799
+I950068105
+I1829664117
+I3108542987
+I2378860527
+I790023460
+I280087750
+I1171478018
+I2333653728
+I3976932140
+I896746152
+I1802494195
+I1232873794
+I2749440836
+I2032037296
+I2012091682
+I1296131034
+I3892133385
+I908161334
+I2296791795
+I548169794
+I696265
+I893156828
+I426904709
+I3565374535
+I2655906825
+I2792178515
+I2406814632
+I4038847579
+I3123934642
+I2197503004
+I3535032597
+I2266216689
+I2117613462
+I1787448518
+I1875089416
+I2037165384
+I1140676321
+I3606296464
+I3229138231
+I2458267132
+I1874651171
+I3331900867
+I1000557654
+I1432861701
+I473636323
+I2691783927
+I1871437447
+I1328016401
+I4118690062
+I449467602
+I681789035
+I864889442
+I1200888928
+I75769445
+I4008690037
+I2464577667
+I4167795823
+I3070097648
+I2579174882
+I1216886568
+I3810116343
+I2249507485
+I3266903480
+I3671233480
+I100191658
+I3087121334
+I365063087
+I3821275176
+I2165052848
+I1282465245
+I3601570637
+I3132413236
+I2780570459
+I3222142917
+I3129794692
+I2611590811
+I947031677
+I2991908938
+I750997949
+I3632575131
+I1632014461
+I2846484755
+I2347261779
+I2903959448
+I1397316686
+I1904578392
+I774649578
+I3164598558
+I2429587609
+I738244516
+I1563304975
+I1399317414
+I1021316297
+I3187933234
+I2126780757
+I4011907847
+I4095169219
+I3358010054
+I2729978247
+I3736811646
+I3009656410
+I2893043637
+I4027447385
+I1239610110
+I1488806900
+I2674866844
+I442876374
+I2853687260
+I2785921005
+I3151378528
+I1180567
+I2803146964
+I982221759
+I2192919417
+I3087026181
+I2480838002
+I738452921
+I687986185
+I3049371676
+I3636492954
+I3468311299
+I2379621102
+I788988633
+I1643210601
+I2983998168
+I2492730801
+I2586048705
+I604073029
+I4121082815
+I1496476928
+I2972357110
+I2663116968
+I2642628592
+I2116052039
+I487186279
+I2577680328
+I3974766614
+I730776636
+I3842528855
+I1929093695
+I44626622
+I3989908833
+I1695426222
+I3675479382
+I3051784964
+I1514876613
+I1254036595
+I2420450649
+I3034377361
+I2332990590
+I1535175126
+I185834384
+I1107372900
+I1707278185
+I1286285295
+I3332574225
+I2785672437
+I883170645
+I2005666473
+I3403131327
+I4122021352
+I1464032858
+I3702576112
+I260554598
+I1837731650
+I2594435345
+I75771049
+I2012484289
+I3058649775
+I29979703
+I3861335335
+I2506495152
+I3786448704
+I442947790
+I2582724774
+I4291336243
+I2568189843
+I1923072690
+I1121589611
+I837696302
+I3284631720
+I3865021324
+I3576453165
+I2559531629
+I1459231762
+I3506550036
+I3754420159
+I2622000757
+I124228596
+I1084328605
+I1692830753
+I547273558
+I674282621
+I655259103
+I3188629610
+I490502174
+I2081001293
+I3191330704
+I4109943593
+I1859948504
+I3163806460
+I508833168
+I1256371033
+I2709253790
+I2068956572
+I3092842814
+I3913926529
+I2039638759
+I981982529
+I536094190
+I368855295
+I51993975
+I1597480732
+I4058175522
+I2155896702
+I3196251991
+I1081913893
+I3952353788
+I3545548108
+I2370669647
+I2206572308
+I2576392991
+I1732303374
+I1153136290
+I537641955
+I1738691747
+I3232854186
+I2539632206
+I2829760278
+I3058187853
+I1202425792
+I3762361970
+I2863949342
+I2640635867
+I376638744
+I1857679757
+I330798087
+I1457400505
+I1135610046
+I606400715
+I1859536026
+I509811335
+I529772308
+I2579273244
+I1890382004
+I3959908876
+I2612335971
+I2834052227
+I1434475986
+I3684202717
+I4015011345
+I582567852
+I3689969571
+I3934753460
+I3034960691
+I208573292
+I4004113742
+I3992904842
+I2587153719
+I3529179079
+I1565424987
+I779130678
+I1048582935
+I3213591622
+I3607793434
+I3951254937
+I2047811901
+I7508850
+I248544605
+I4210090324
+I2331490884
+I70057213
+I776474945
+I1345528889
+I3290403612
+I1664955269
+I1533143116
+I545003424
+I4141564478
+I1257326139
+I868843601
+I2337603029
+I1918131449
+I1843439523
+I1125519035
+I673340118
+I421408852
+I1520454906
+I1804722630
+I3621254196
+I2329968000
+I39464672
+I430583134
+I294026512
+I53978525
+I2892276105
+I1418863764
+I3419054451
+I1391595797
+I3544981798
+I4191780858
+I825672357
+I2972000844
+I1571305069
+I4231982845
+I3611916419
+I3045163168
+I2982349733
+I278572141
+I4215338078
+I839860504
+I1819151779
+I1412347479
+I1386770353
+I3914589491
+I3783104977
+I4124296733
+I830546258
+I89825624
+I4110601328
+I2545483429
+I300600527
+I516641158
+I3693021034
+I2852912854
+I3240039868
+I4167407959
+I1479557946
+I3621188804
+I1391590944
+I3578441128
+I1227055556
+I406898396
+I3064054983
+I25835338
+I402664165
+I4097682779
+I2106728012
+I203613622
+I3045467686
+I1381726438
+I3798670110
+I1342314961
+I3552497361
+I535913619
+I2625787583
+I1606574307
+I1101269630
+I1950513752
+I1121355862
+I3586816903
+I438529984
+I2473182121
+I1229997203
+I405445940
+I1695535315
+I427014336
+I3916768430
+I392298359
+I1884642868
+I1244730821
+I741058080
+I567479957
+I3527621168
+I3191971011
+I3267069104
+I4108668146
+I1520795587
+I166581006
+I473794477
+I1562126550
+I929843010
+I889533294
+I1266556608
+I874518650
+I3520162092
+I3013765049
+I4220231414
+I547246449
+I3998093769
+I3737193746
+I3872944207
+I793651876
+I2606384318
+I875991012
+I1394836334
+I4102011644
+I854380426
+I2618666767
+I2568302000
+I1995512132
+I229491093
+I2673500286
+I3364550739
+I3836923416
+I243656987
+I3944388983
+I4064949677
+I1416956378
+I1703244487
+I3990798829
+I2023425781
+I3926702214
+I1229015501
+I3174247824
+I624
+tp2
+Ntp3
+b. \ No newline at end of file
diff --git a/Lib/test/randv3.pck b/Lib/test/randv3.pck
new file mode 100644
index 0000000..09fc38b
--- /dev/null
+++ b/Lib/test/randv3.pck
@@ -0,0 +1,633 @@
+crandom
+Random
+p0
+(tRp1
+(I3
+(L2147483648L
+L994081831L
+L2806287265L
+L2228999830L
+L3396498069L
+L2956805457L
+L3273927761L
+L920726507L
+L1862624492L
+L2921292485L
+L1779526843L
+L2469105503L
+L251696293L
+L1254390717L
+L779197080L
+L3165356830L
+L2007365218L
+L1870028812L
+L2896519363L
+L1855578438L
+L979518416L
+L3481710246L
+L3191861507L
+L3993006593L
+L2967971479L
+L3353342753L
+L3576782572L
+L339685558L
+L2367675732L
+L116208555L
+L1220054437L
+L486597056L
+L1912115141L
+L1037044792L
+L4096904723L
+L3409146175L
+L3701651227L
+L315824610L
+L4138604583L
+L1385764892L
+L191878900L
+L2320582219L
+L3420677494L
+L2776503169L
+L1148247403L
+L829555069L
+L902064012L
+L2934642741L
+L2477108577L
+L2583928217L
+L1658612579L
+L2865447913L
+L129147346L
+L3691171887L
+L1569328110L
+L1372860143L
+L1054139183L
+L1617707080L
+L69020592L
+L3810271603L
+L1853953416L
+L3499803073L
+L1027545027L
+L3229043605L
+L250848720L
+L3324932626L
+L3537002962L
+L2494323345L
+L3238103962L
+L4147541579L
+L3636348186L
+L3025455083L
+L2678771977L
+L584700256L
+L3461826909L
+L854511420L
+L943463552L
+L3609239025L
+L3977577989L
+L253070090L
+L777394544L
+L2144086567L
+L1092947992L
+L854327284L
+L2222750082L
+L360183510L
+L1312466483L
+L3227531091L
+L2235022500L
+L3013060530L
+L2541091298L
+L3480126342L
+L1839762775L
+L2632608190L
+L1108889403L
+L3045050923L
+L731513126L
+L3505436788L
+L3062762017L
+L1667392680L
+L1354126500L
+L1143573930L
+L2816645702L
+L2100356873L
+L2817679106L
+L1210746010L
+L2409915248L
+L2910119964L
+L2309001420L
+L220351824L
+L3667352871L
+L3993148590L
+L2886160232L
+L4239393701L
+L1189270581L
+L3067985541L
+L147374573L
+L2355164869L
+L3696013550L
+L4227037846L
+L1905112743L
+L3312843689L
+L2930678266L
+L1828795355L
+L76933594L
+L3987100796L
+L1288361435L
+L3464529151L
+L965498079L
+L1444623093L
+L1372893415L
+L1536235597L
+L1341994850L
+L963594758L
+L2115295754L
+L982098685L
+L1053433904L
+L2078469844L
+L3059765792L
+L1753606181L
+L2130171254L
+L567588194L
+L529629426L
+L3621523534L
+L3027576564L
+L1176438083L
+L4096287858L
+L1168574683L
+L1425058962L
+L1429631655L
+L2902106759L
+L761900641L
+L1329183956L
+L1947050932L
+L447490289L
+L3282516276L
+L200037389L
+L921868197L
+L3331403999L
+L4088760249L
+L2188326318L
+L288401961L
+L1360802675L
+L314302808L
+L3314639210L
+L3749821203L
+L2286081570L
+L2768939062L
+L3200541016L
+L2133495482L
+L385029880L
+L4217232202L
+L3171617231L
+L1660846653L
+L2459987621L
+L2691776124L
+L4225030408L
+L3595396773L
+L1103680661L
+L539064057L
+L1492841101L
+L166195394L
+L757973658L
+L533893054L
+L2784879594L
+L1021821883L
+L2350548162L
+L176852116L
+L3503166025L
+L148079914L
+L1633466236L
+L2773090165L
+L1162846701L
+L3575737795L
+L1624178239L
+L2454894710L
+L3014691938L
+L526355679L
+L1870824081L
+L3362425857L
+L3907566665L
+L3462563184L
+L2229112004L
+L4203735748L
+L1557442481L
+L924133999L
+L1906634214L
+L880459727L
+L4065895870L
+L141426254L
+L1258450159L
+L3243115027L
+L1574958840L
+L313939294L
+L3055664260L
+L3459714255L
+L531778790L
+L509505506L
+L1620227491L
+L2675554942L
+L2516509560L
+L3797299887L
+L237135890L
+L3203142213L
+L1087745310L
+L1897151854L
+L3936590041L
+L132765167L
+L2385908063L
+L1360600289L
+L3574567769L
+L2752788114L
+L2644228966L
+L2377705183L
+L601277909L
+L4046480498L
+L324401408L
+L3279931760L
+L2227059377L
+L1538827493L
+L4220532064L
+L478044564L
+L2917117761L
+L635492832L
+L2319763261L
+L795944206L
+L1820473234L
+L1673151409L
+L1404095402L
+L1661067505L
+L3217106938L
+L2406310683L
+L1931309248L
+L2458622868L
+L3323670524L
+L3266852755L
+L240083943L
+L3168387397L
+L607722198L
+L1256837690L
+L3608124913L
+L4244969357L
+L1289959293L
+L519750328L
+L3229482463L
+L1105196988L
+L1832684479L
+L3761037224L
+L2363631822L
+L3297957711L
+L572766355L
+L1195822137L
+L2239207981L
+L2034241203L
+L163540514L
+L288160255L
+L716403680L
+L4019439143L
+L1536281935L
+L2345100458L
+L2786059178L
+L2822232109L
+L987025395L
+L3061166559L
+L490422513L
+L2551030115L
+L2638707620L
+L1344728502L
+L714108911L
+L2831719700L
+L2188615369L
+L373509061L
+L1351077504L
+L3136217056L
+L783521095L
+L2554949468L
+L2662499550L
+L1203826951L
+L1379632388L
+L1918858985L
+L607465976L
+L1980450237L
+L3540079211L
+L3397813410L
+L2913309266L
+L2289572621L
+L4133935327L
+L4166227663L
+L3371801704L
+L3065474909L
+L3580562343L
+L3832172378L
+L2556130719L
+L310473705L
+L3734014346L
+L2490413810L
+L347233056L
+L526668037L
+L1158393656L
+L544329703L
+L2150085419L
+L3914038146L
+L1060237586L
+L4159394837L
+L113205121L
+L309966775L
+L4098784465L
+L3635222960L
+L2417516569L
+L2089579233L
+L1725807541L
+L2728122526L
+L2365836523L
+L2504078522L
+L1443946869L
+L2384171411L
+L997046534L
+L3249131657L
+L1699875986L
+L3618097146L
+L1716038224L
+L2629818607L
+L2929217876L
+L1367250314L
+L1726434951L
+L1388496325L
+L2107602181L
+L2822366842L
+L3052979190L
+L3796798633L
+L1543813381L
+L959000121L
+L1363845999L
+L2952528150L
+L874184932L
+L1888387194L
+L2328695295L
+L3442959855L
+L841805947L
+L1087739275L
+L3230005434L
+L3045399265L
+L1161817318L
+L2898673139L
+L860011094L
+L940539782L
+L1297818080L
+L4243941623L
+L1577613033L
+L4204131887L
+L3819057225L
+L1969439558L
+L3297963932L
+L241874069L
+L3517033453L
+L2295345664L
+L1098911422L
+L886955008L
+L1477397621L
+L4279347332L
+L3616558791L
+L2384411957L
+L742537731L
+L764221540L
+L2871698900L
+L3530636393L
+L691256644L
+L758730966L
+L1717773090L
+L2751856377L
+L3188484000L
+L3767469670L
+L1623863053L
+L3533236793L
+L4099284176L
+L723921107L
+L310594036L
+L223978745L
+L2266565776L
+L201843303L
+L2969968546L
+L3351170888L
+L3465113624L
+L2712246712L
+L1521383057L
+L2384461798L
+L216357551L
+L2167301975L
+L3144653194L
+L2781220155L
+L3620747666L
+L95971265L
+L4255400243L
+L59999757L
+L4174273472L
+L3974511524L
+L1007123950L
+L3112477628L
+L806461512L
+L3148074008L
+L528352882L
+L2545979588L
+L2562281969L
+L3010249477L
+L1886331611L
+L3210656433L
+L1034099976L
+L2906893579L
+L1197048779L
+L1870004401L
+L3898300490L
+L2686856402L
+L3975723478L
+L613043532L
+L2565674353L
+L3760045310L
+L3468984376L
+L4126258L
+L303855424L
+L3988963552L
+L276256796L
+L544071807L
+L1023872062L
+L1747461519L
+L1975571260L
+L4033766958L
+L2946555557L
+L1492957796L
+L958271685L
+L46480515L
+L907760635L
+L1306626357L
+L819652378L
+L1172300279L
+L1116851319L
+L495601075L
+L1157715330L
+L534220108L
+L377320028L
+L1672286106L
+L2066219284L
+L1842386355L
+L2546059464L
+L1839457336L
+L3476194446L
+L3050550028L
+L594705582L
+L1905813535L
+L1813033412L
+L2700858157L
+L169067972L
+L4252889045L
+L1921944555L
+L497671474L
+L210143935L
+L2688398489L
+L325158375L
+L3450846447L
+L891760597L
+L712802536L
+L1132557436L
+L1417044075L
+L1639889660L
+L1746379970L
+L1478741647L
+L2817563486L
+L2573612532L
+L4266444457L
+L2911601615L
+L804745411L
+L2207254652L
+L1189140646L
+L3829725111L
+L3637367348L
+L1944731747L
+L2193440343L
+L1430195413L
+L1173515229L
+L1582618217L
+L2070767037L
+L247908936L
+L1460675439L
+L556001596L
+L327629335L
+L1036133876L
+L4228129605L
+L999174048L
+L3635804039L
+L1416550481L
+L1270540269L
+L4280743815L
+L39607659L
+L1552540623L
+L2762294062L
+L504137289L
+L4117044239L
+L1417130225L
+L1342970056L
+L1755716449L
+L1169447322L
+L2731401356L
+L2319976745L
+L2869221479L
+L23972655L
+L2251495389L
+L1429860878L
+L3728135992L
+L4241432973L
+L3698275076L
+L216416432L
+L4040046960L
+L246077176L
+L894675685L
+L3932282259L
+L3097205100L
+L2128818650L
+L1319010656L
+L1601974009L
+L2552960957L
+L3554016055L
+L4209395641L
+L2013340102L
+L3370447801L
+L2307272002L
+L1795091354L
+L202109401L
+L988345070L
+L2514870758L
+L1132726850L
+L582746224L
+L3112305421L
+L1843020683L
+L3600189223L
+L1101349165L
+L4211905855L
+L2866677581L
+L2881621130L
+L4165324109L
+L4238773191L
+L3635649550L
+L2670481044L
+L2996248219L
+L1676992480L
+L3473067050L
+L4205793699L
+L4019490897L
+L1579990481L
+L1899617990L
+L1136347713L
+L1802842268L
+L3591752960L
+L1197308739L
+L433629786L
+L4032142790L
+L3148041979L
+L3312138845L
+L3896860449L
+L3298182567L
+L907605170L
+L1658664067L
+L2682980313L
+L2523523173L
+L1208722103L
+L3808530363L
+L1079003946L
+L4282402864L
+L2041010073L
+L2667555071L
+L688018180L
+L1405121012L
+L4167994076L
+L3504695336L
+L1923944749L
+L1143598790L
+L3936268898L
+L3606243846L
+L1017420080L
+L4026211169L
+L596529763L
+L1844259624L
+L2840216282L
+L2673807759L
+L3407202575L
+L2737971083L
+L4075423068L
+L3684057432L
+L3146627241L
+L599650513L
+L69773114L
+L1257035919L
+L807485291L
+L2376230687L
+L3036593147L
+L2642411658L
+L106080044L
+L2199622729L
+L291834511L
+L2697611361L
+L11689733L
+L625123952L
+L3226023062L
+L3229663265L
+L753059444L
+L2843610189L
+L624L
+tp2
+Ntp3
+b. \ No newline at end of file
diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py
index dcb768f..e211916 100644
--- a/Lib/test/test_cmd_line_script.py
+++ b/Lib/test/test_cmd_line_script.py
@@ -35,15 +35,15 @@ def temp_dir():
finally:
shutil.rmtree(dirname)
-test_source = ("""\
+test_source = """\
# Script may be run with optimisation enabled, so don't rely on assert
# statements being executed
def assertEqual(lhs, rhs):
if lhs != rhs:
- raise AssertionError("%r != %r" % (lhs, rhs))
+ raise AssertionError('%r != %r' % (lhs, rhs))
def assertIdentical(lhs, rhs):
if lhs is not rhs:
- raise AssertionError("%r is not %r" % (lhs, rhs))
+ raise AssertionError('%r is not %r' % (lhs, rhs))
# Check basic code execution
result = ['Top level assignment']
def f():
@@ -53,17 +53,18 @@ assertEqual(result, ['Top level assignment', 'Lower level reference'])
# Check population of magic variables
assertEqual(__name__, '__main__')
print('__file__==%r' % __file__)
+print('__package__==%r' % __package__)
# Check the sys module
import sys
assertIdentical(globals(), sys.modules[__name__].__dict__)
print('sys.argv[0]==%r' % sys.argv[0])
-""")
+"""
-def _make_test_script(script_dir, script_basename):
- script_filename = script_basename+os.path.extsep+"py"
+def _make_test_script(script_dir, script_basename, source=test_source):
+ script_filename = script_basename+os.path.extsep+'py'
script_name = os.path.join(script_dir, script_filename)
- script_file = open(script_name, "w")
- script_file.write(test_source)
+ script_file = open(script_name, 'w')
+ script_file.write(source)
script_file.close()
return script_name
@@ -88,59 +89,96 @@ def _make_test_zip(zip_dir, zip_basename, script_name):
# zip_file.close()
return zip_name
+def _make_test_pkg(pkg_dir):
+ os.mkdir(pkg_dir)
+ _make_test_script(pkg_dir, '__init__', '')
+
+# There's no easy way to pass the script directory in to get
+# -m to work (avoiding that is the whole point of making
+# directories and zipfiles executable!)
+# So we fake it for testing purposes with a custom launch script
+launch_source = """\
+import sys, os.path, runpy
+sys.path[0:0] = os.path.dirname(__file__)
+runpy._run_module_as_main(%r)
+"""
+
+def _make_launch_script(script_dir, script_basename, module_name):
+ return _make_test_script(script_dir, script_basename,
+ launch_source % module_name)
+
class CmdLineTest(unittest.TestCase):
- def _check_script(self, script_name, expected_file, expected_argv0):
- exit_code, data = _run_python(script_name)
+ def _check_script(self, script_name, expected_file,
+ expected_argv0, expected_package,
+ *cmd_line_switches):
+ run_args = cmd_line_switches + (script_name,)
+ exit_code, data = _run_python(*run_args)
if verbose:
print("Output from test script %r:" % script_name)
print(data)
- self.assertEqual(exit_code, 0, data)
+ self.assertEqual(exit_code, 0)
printed_file = '__file__==%r' % expected_file
printed_argv0 = 'sys.argv[0]==%r' % expected_argv0
- self.assert_(printed_file in data, (printed_file, data))
- self.assert_(printed_argv0 in data, (printed_argv0, data))
+ printed_package = '__package__==%r' % expected_package
+ if verbose:
+ print('Expected output:')
+ print(printed_file)
+ print(printed_package)
+ print(printed_argv0)
+ self.assert_(printed_file in data)
+ self.assert_(printed_package in data)
+ self.assert_(printed_argv0 in data)
def test_basic_script(self):
with temp_dir() as script_dir:
- script_name = _make_test_script(script_dir, "script")
- self._check_script(script_name, script_name, script_name)
+ script_name = _make_test_script(script_dir, 'script')
+ self._check_script(script_name, script_name, script_name, None)
def test_script_compiled(self):
with temp_dir() as script_dir:
- script_name = _make_test_script(script_dir, "script")
+ script_name = _make_test_script(script_dir, 'script')
compiled_name = _compile_test_script(script_name)
os.remove(script_name)
- self._check_script(compiled_name, compiled_name, compiled_name)
+ self._check_script(compiled_name, compiled_name, compiled_name, None)
def test_directory(self):
with temp_dir() as script_dir:
- script_name = _make_test_script(script_dir, "__main__")
- self._check_script(script_dir, script_name, script_dir)
+ script_name = _make_test_script(script_dir, '__main__')
+ self._check_script(script_dir, script_name, script_dir, '')
def test_directory_compiled(self):
with temp_dir() as script_dir:
- script_name = _make_test_script(script_dir, "__main__")
+ script_name = _make_test_script(script_dir, '__main__')
compiled_name = _compile_test_script(script_name)
os.remove(script_name)
- self._check_script(script_dir, compiled_name, script_dir)
+ self._check_script(script_dir, compiled_name, script_dir, '')
def test_zipfile(self):
with temp_dir() as script_dir:
- script_name = _make_test_script(script_dir, "__main__")
- zip_name = _make_test_zip(script_dir, "test_zip", script_name)
- self._check_script(zip_name, None, zip_name)
+ script_name = _make_test_script(script_dir, '__main__')
+ zip_name = _make_test_zip(script_dir, 'test_zip', script_name)
+ self._check_script(zip_name, None, zip_name, '')
def test_zipfile_compiled(self):
with temp_dir() as script_dir:
- script_name = _make_test_script(script_dir, "__main__")
+ script_name = _make_test_script(script_dir, '__main__')
compiled_name = _compile_test_script(script_name)
- zip_name = _make_test_zip(script_dir, "test_zip", compiled_name)
- self._check_script(zip_name, None, zip_name)
+ zip_name = _make_test_zip(script_dir, 'test_zip', compiled_name)
+ self._check_script(zip_name, None, zip_name, '')
+
+ def test_module_in_package(self):
+ with temp_dir() as script_dir:
+ pkg_dir = os.path.join(script_dir, 'test_pkg')
+ _make_test_pkg(pkg_dir)
+ script_name = _make_test_script(pkg_dir, 'script')
+ launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg.script')
+ self._check_script(launch_name, script_name,
+ script_name, 'test_pkg')
def test_main():
test.test_support.run_unittest(CmdLineTest)
test.test_support.reap_children()
-if __name__ == "__main__":
+if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_frozen.py b/Lib/test/test_frozen.py
index 05e8e8c..99f499d 100644
--- a/Lib/test/test_frozen.py
+++ b/Lib/test/test_frozen.py
@@ -12,7 +12,7 @@ class FrozenTests(unittest.TestCase):
except ImportError as x:
self.fail("import __hello__ failed:" + str(x))
self.assertEqual(__hello__.initialized, True)
- self.assertEqual(len(dir(__hello__)), 5)
+ self.assertEqual(len(dir(__hello__)), 6, dir(__hello__))
try:
import __phello__
@@ -20,17 +20,17 @@ class FrozenTests(unittest.TestCase):
self.fail("import __phello__ failed:" + str(x))
self.assertEqual(__phello__.initialized, True)
if not "__phello__.spam" in sys.modules:
- self.assertEqual(len(dir(__phello__)), 6, dir(__phello__))
- else:
self.assertEqual(len(dir(__phello__)), 7, dir(__phello__))
+ else:
+ self.assertEqual(len(dir(__phello__)), 8, dir(__phello__))
try:
import __phello__.spam
except ImportError as x:
self.fail("import __phello__.spam failed:" + str(x))
self.assertEqual(__phello__.spam.initialized, True)
- self.assertEqual(len(dir(__phello__.spam)), 5)
- self.assertEqual(len(dir(__phello__)), 7)
+ self.assertEqual(len(dir(__phello__.spam)), 6)
+ self.assertEqual(len(dir(__phello__)), 8)
try:
import __phello__.foo
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
index 4710c8c..b6d2ec0 100644
--- a/Lib/test/test_generators.py
+++ b/Lib/test/test_generators.py
@@ -1668,6 +1668,21 @@ And finalization:
exiting
+GeneratorExit is not caught by except Exception:
+
+>>> def f():
+... try: yield
+... except Exception:
+... print('except')
+... finally:
+... print('finally')
+
+>>> g = f()
+>>> next(g)
+>>> del g
+finally
+
+
Now let's try some ill-behaved generators:
>>> def f():
diff --git a/Lib/test/test_pkg.py b/Lib/test/test_pkg.py
index fde99dc..630956d 100644
--- a/Lib/test/test_pkg.py
+++ b/Lib/test/test_pkg.py
@@ -192,11 +192,13 @@ class TestPkg(unittest.TestCase):
import t5
self.assertEqual(fixdir(dir(t5)),
['__doc__', '__file__', '__name__',
- '__path__', 'foo', 'string', 't5'])
+ '__package__', '__path__', 'foo', 'string', 't5'])
self.assertEqual(fixdir(dir(t5.foo)),
- ['__doc__', '__file__', '__name__', 'string'])
+ ['__doc__', '__file__', '__name__', '__package__',
+ 'string'])
self.assertEqual(fixdir(dir(t5.string)),
- ['__doc__', '__file__', '__name__', 'spam'])
+ ['__doc__', '__file__', '__name__','__package__',
+ 'spam'])
def test_6(self):
hier = [
@@ -212,14 +214,14 @@ class TestPkg(unittest.TestCase):
import t6
self.assertEqual(fixdir(dir(t6)),
['__all__', '__doc__', '__file__',
- '__name__', '__path__'])
+ '__name__', '__package__', '__path__'])
s = """
import t6
from t6 import *
self.assertEqual(fixdir(dir(t6)),
['__all__', '__doc__', '__file__',
- '__name__', '__path__', 'eggs',
- 'ham', 'spam'])
+ '__name__', '__package__', '__path__',
+ 'eggs', 'ham', 'spam'])
self.assertEqual(dir(), ['eggs', 'ham', 'self', 'spam', 't6'])
"""
self.run_code(s)
@@ -245,17 +247,19 @@ class TestPkg(unittest.TestCase):
t7, sub, subsub = None, None, None
import t7 as tas
self.assertEqual(fixdir(dir(tas)),
- ['__doc__', '__file__', '__name__', '__path__'])
+ ['__doc__', '__file__', '__name__',
+ '__package__', '__path__'])
self.failIf(t7)
from t7 import sub as subpar
self.assertEqual(fixdir(dir(subpar)),
- ['__doc__', '__file__', '__name__', '__path__'])
+ ['__doc__', '__file__', '__name__',
+ '__package__', '__path__'])
self.failIf(t7)
self.failIf(sub)
from t7.sub import subsub as subsubsub
self.assertEqual(fixdir(dir(subsubsub)),
- ['__doc__', '__file__', '__name__', '__path__',
- 'spam'])
+ ['__doc__', '__file__', '__name__',
+ '__package__', '__path__', 'spam'])
self.failIf(t7)
self.failIf(sub)
self.failIf(subsub)
diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py
index 3023d08..6adcd06 100644
--- a/Lib/test/test_random.py
+++ b/Lib/test/test_random.py
@@ -144,6 +144,19 @@ class TestBasicOps(unittest.TestCase):
restoredseq = [newgen.random() for i in range(10)]
self.assertEqual(origseq, restoredseq)
+ def test_bug_1727780(self):
+ # verify that version-2-pickles can be loaded
+ # fine, whether they are created on 32-bit or 64-bit
+ # platforms, and that version-3-pickles load fine.
+ files = [("randv2_32.pck", 780),
+ ("randv2_64.pck", 866),
+ ("randv3.pck", 343)]
+ for file, value in files:
+ f = open(test_support.findfile(file),"rb")
+ r = pickle.load(f)
+ f.close()
+ self.assertEqual(r.randrange(1000), value)
+
class WichmannHill_TestBasicOps(TestBasicOps):
gen = random.WichmannHill()
diff --git a/Lib/test/test_runpy.py b/Lib/test/test_runpy.py
index b003f17..ffa36dc 100644
--- a/Lib/test/test_runpy.py
+++ b/Lib/test/test_runpy.py
@@ -5,7 +5,12 @@ import os.path
import sys
import tempfile
from test.test_support import verbose, run_unittest, forget
-from runpy import _run_code, _run_module_code, _run_module_as_main, run_module
+from runpy import _run_code, _run_module_code, run_module
+
+# Note: This module can't safely test _run_module_as_main as it
+# runs its tests in the current process, which would mess with the
+# real __main__ module (usually test.regrtest)
+# See test_cmd_line_script for a test that executes that code path
# Set up the test code and expected results
@@ -36,6 +41,7 @@ class RunModuleCodeTest(unittest.TestCase):
self.failUnless(d["__name__"] is None)
self.failUnless(d["__file__"] is None)
self.failUnless(d["__loader__"] is None)
+ self.failUnless(d["__package__"] is None)
self.failUnless(d["run_argv0"] is saved_argv0)
self.failUnless("run_name" not in d)
self.failUnless(sys.argv[0] is saved_argv0)
@@ -45,13 +51,15 @@ class RunModuleCodeTest(unittest.TestCase):
name = "<Nonsense>"
file = "Some other nonsense"
loader = "Now you're just being silly"
+ package = '' # Treat as a top level module
d1 = dict(initial=initial)
saved_argv0 = sys.argv[0]
d2 = _run_module_code(self.test_source,
d1,
name,
file,
- loader)
+ loader,
+ package)
self.failUnless("result" not in d1)
self.failUnless(d2["initial"] is initial)
self.assertEqual(d2["result"], self.expected_result)
@@ -62,6 +70,7 @@ class RunModuleCodeTest(unittest.TestCase):
self.failUnless(d2["__file__"] is file)
self.failUnless(d2["run_argv0"] is file)
self.failUnless(d2["__loader__"] is loader)
+ self.failUnless(d2["__package__"] is package)
self.failUnless(sys.argv[0] is saved_argv0)
self.failUnless(name not in sys.modules)
@@ -164,7 +173,7 @@ class RunModuleTest(unittest.TestCase):
self._del_pkg(pkg_dir, depth, mod_name)
if verbose: print("Module executed successfully")
- def _add_relative_modules(self, base_dir, depth):
+ def _add_relative_modules(self, base_dir, source, depth):
if depth <= 1:
raise ValueError("Relative module test needs depth > 1")
pkg_name = "__runpy_pkg__"
@@ -190,7 +199,7 @@ class RunModuleTest(unittest.TestCase):
if verbose: print(" Added nephew module:", nephew_fname)
def _check_relative_imports(self, depth, run_name=None):
- contents = """\
+ contents = r"""\
from __future__ import absolute_import
from . import sibling
from ..uncle.cousin import nephew
@@ -198,16 +207,21 @@ from ..uncle.cousin import nephew
pkg_dir, mod_fname, mod_name = (
self._make_pkg(contents, depth))
try:
- self._add_relative_modules(pkg_dir, depth)
+ self._add_relative_modules(pkg_dir, contents, depth)
+ pkg_name = mod_name.rpartition('.')[0]
if verbose: print("Running from source:", mod_name)
- d1 = run_module(mod_name) # Read from source
+ d1 = run_module(mod_name, run_name=run_name) # Read from source
+ self.failUnless("__package__" in d1)
+ self.failUnless(d1["__package__"] == pkg_name)
self.failUnless("sibling" in d1)
self.failUnless("nephew" in d1)
del d1 # Ensure __loader__ entry doesn't keep file open
__import__(mod_name)
os.remove(mod_fname)
if verbose: print("Running from compiled:", mod_name)
- d2 = run_module(mod_name) # Read from bytecode
+ d2 = run_module(mod_name, run_name=run_name) # Read from bytecode
+ self.failUnless("__package__" in d2)
+ self.failUnless(d2["__package__"] == pkg_name)
self.failUnless("sibling" in d2)
self.failUnless("nephew" in d2)
del d2 # Ensure __loader__ entry doesn't keep file open
@@ -225,6 +239,11 @@ from ..uncle.cousin import nephew
if verbose: print("Testing relative imports at depth:", depth)
self._check_relative_imports(depth)
+ def test_main_relative_import(self):
+ for depth in range(2, 5):
+ if verbose: print("Testing main relative imports at depth:", depth)
+ self._check_relative_imports(depth, "__main__")
+
def test_main():
run_unittest(RunModuleCodeTest)