summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/distutils/command/build_scripts.py3
-rw-r--r--Lib/sre_compile.py2
-rw-r--r--Lib/test/test_math.py23
-rw-r--r--Lib/test/test_re.py30
4 files changed, 56 insertions, 2 deletions
diff --git a/Lib/distutils/command/build_scripts.py b/Lib/distutils/command/build_scripts.py
index 227bb9c..7b44264 100644
--- a/Lib/distutils/command/build_scripts.py
+++ b/Lib/distutils/command/build_scripts.py
@@ -110,7 +110,8 @@ class build_scripts(Command):
if f:
f.close()
else:
- f.close()
+ if f:
+ f.close()
self.copy_file(script, outfile)
if os.name == 'posix':
diff --git a/Lib/sre_compile.py b/Lib/sre_compile.py
index f9f0736..f3b415d 100644
--- a/Lib/sre_compile.py
+++ b/Lib/sre_compile.py
@@ -516,7 +516,7 @@ def compile(p, flags=0):
indexgroup[i] = k
return _sre.compile(
- pattern, flags, code,
+ pattern, flags | p.pattern.flags, code,
p.pattern.groups-1,
groupindex, indexgroup
)
diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py
index 2d15f3a..8449794 100644
--- a/Lib/test/test_math.py
+++ b/Lib/test/test_math.py
@@ -231,6 +231,29 @@ class MathTests(unittest.TestCase):
self.ftest('tanh(0)', math.tanh(0), 0)
self.ftest('tanh(1)+tanh(-1)', math.tanh(1)+math.tanh(-1), 0)
+ def testCopysign(self):
+ self.assertEqual(math.copysign(1, 42), 1.0)
+ self.assertEqual(math.copysign(0., 42), 0.0)
+ self.assertEqual(math.copysign(1., -42), -1.0)
+ self.assertEqual(math.copysign(3, 0.), 3.0)
+ self.assertEqual(math.copysign(4., -0.), -4.0)
+
+ def testIsnan(self):
+ self.assert_(math.isnan(float("nan")))
+ self.assert_(math.isnan(float("inf")* 0.))
+ self.failIf(math.isnan(float("inf")))
+ self.failIf(math.isnan(0.))
+ self.failIf(math.isnan(1.))
+
+ def testIsinf(self):
+ self.assert_(math.isinf(float("inf")))
+ self.assert_(math.isinf(float("-inf")))
+ self.assert_(math.isinf(1E400))
+ self.assert_(math.isinf(-1E400))
+ self.failIf(math.isinf(float("nan")))
+ self.failIf(math.isinf(0.))
+ self.failIf(math.isinf(1.))
+
# RED_FLAG 16-Oct-2000 Tim
# While 2.0 is more consistent about exceptions than previous releases, it
# still fails this part of the test on some platforms. For now, we only
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index 88fecbf..75c016e 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -632,6 +632,36 @@ class ReTests(unittest.TestCase):
self.assertEqual(re.compile("bla").match(a), None)
self.assertEqual(re.compile("").match(a).groups(), ())
+ def test_inline_flags(self):
+ # Bug #1700
+ upper_char = unichr(0x1ea0) # Latin Capital Letter A with Dot Bellow
+ lower_char = unichr(0x1ea1) # Latin Small Letter A with Dot Bellow
+
+ p = re.compile(upper_char, re.I | re.U)
+ q = p.match(lower_char)
+ self.assertNotEqual(q, None)
+
+ p = re.compile(lower_char, re.I | re.U)
+ q = p.match(upper_char)
+ self.assertNotEqual(q, None)
+
+ p = re.compile('(?i)' + upper_char, re.U)
+ q = p.match(lower_char)
+ self.assertNotEqual(q, None)
+
+ p = re.compile('(?i)' + lower_char, re.U)
+ q = p.match(upper_char)
+ self.assertNotEqual(q, None)
+
+ p = re.compile('(?iu)' + upper_char)
+ q = p.match(lower_char)
+ self.assertNotEqual(q, None)
+
+ p = re.compile('(?iu)' + lower_char)
+ q = p.match(upper_char)
+ self.assertNotEqual(q, None)
+
+
def run_re_tests():
from test.re_tests import benchmarks, tests, SUCCEED, FAIL, SYNTAX_ERROR
if verbose: