Commit 40dbeb02 authored by Marius Wachtler's avatar Marius Wachtler

_getattrEntry(): fix an error where we would fail to raise a CAPI exception sometimes inside an IC.

The cpython decimal test triggered this bug and works now. (But I had to add the correct version of the test)
parent 93114e32
...@@ -316,7 +316,7 @@ add_pyston_test(force_llvm tests -a=-n -a=-X -t50) ...@@ -316,7 +316,7 @@ add_pyston_test(force_llvm tests -a=-n -a=-X -t50)
if(${CMAKE_BUILD_TYPE} STREQUAL "Release") if(${CMAKE_BUILD_TYPE} STREQUAL "Release")
add_pyston_test(max_compilation_tier tests -a=-O -a=-X -t50) add_pyston_test(max_compilation_tier tests -a=-O -a=-X -t50)
endif() endif()
add_pyston_test(defaults cpython --exit-code-only --skip-failing -t50) add_pyston_test(defaults cpython --exit-code-only --skip-failing -t100)
add_pyston_test(defaults integration --exit-code-only --skip-failing -t600) add_pyston_test(defaults integration --exit-code-only --skip-failing -t600)
if(ENABLE_EXTRA_TESTS) if(ENABLE_EXTRA_TESTS)
add_pyston_test(defaults extra -t600 --exit-code-only) add_pyston_test(defaults extra -t600 --exit-code-only)
......
# expected: fail
# Copyright (c) 2004 Python Software Foundation. # Copyright (c) 2004 Python Software Foundation.
# All rights reserved. # All rights reserved.
...@@ -32,9 +31,8 @@ import pickle, copy ...@@ -32,9 +31,8 @@ import pickle, copy
import unittest import unittest
from decimal import * from decimal import *
import numbers import numbers
from test.test_support import (run_unittest, run_doctest, requires_unicode, u, from test.test_support import (run_unittest, run_doctest,
is_resource_enabled, check_py3k_warnings, is_resource_enabled, check_py3k_warnings)
run_with_locale)
import random import random
try: try:
import threading import threading
...@@ -597,12 +595,11 @@ class DecimalExplicitConstructionTest(unittest.TestCase): ...@@ -597,12 +595,11 @@ class DecimalExplicitConstructionTest(unittest.TestCase):
d = nc.create_decimal(prevdec) d = nc.create_decimal(prevdec)
self.assertEqual(str(d), '5.00E+8') self.assertEqual(str(d), '5.00E+8')
@requires_unicode
def test_unicode_digits(self): def test_unicode_digits(self):
test_values = { test_values = {
u(r'\uff11'): '1', u'\uff11': '1',
u(r'\u0660.\u0660\u0663\u0667\u0662e-\u0663') : '0.0000372', u'\u0660.\u0660\u0663\u0667\u0662e-\u0663' : '0.0000372',
u(r'-nan\u0c68\u0c6a\u0c66\u0c66') : '-NaN2400', u'-nan\u0c68\u0c6a\u0c66\u0c66' : '-NaN2400',
} }
for input, expected in test_values.items(): for input, expected in test_values.items():
self.assertEqual(str(Decimal(input)), expected) self.assertEqual(str(Decimal(input)), expected)
...@@ -826,11 +823,6 @@ class DecimalFormatTest(unittest.TestCase): ...@@ -826,11 +823,6 @@ class DecimalFormatTest(unittest.TestCase):
# issue 6850 # issue 6850
('a=-7.0', '0.12345', 'aaaa0.1'), ('a=-7.0', '0.12345', 'aaaa0.1'),
# issue 22090
('<^+15.20%', 'inf', '<<+Infinity%<<<'),
('\x07>,%', 'sNaN1234567', 'sNaN1234567%'),
('=10.10%', 'NaN123', ' NaN123%'),
] ]
for fmt, d, result in test_values: for fmt, d, result in test_values:
self.assertEqual(format(Decimal(d), fmt), result) self.assertEqual(format(Decimal(d), fmt), result)
...@@ -907,23 +899,6 @@ class DecimalFormatTest(unittest.TestCase): ...@@ -907,23 +899,6 @@ class DecimalFormatTest(unittest.TestCase):
self.assertEqual(get_fmt(123456, crazy, '012n'), '00-01-2345-6') self.assertEqual(get_fmt(123456, crazy, '012n'), '00-01-2345-6')
self.assertEqual(get_fmt(123456, crazy, '013n'), '000-01-2345-6') self.assertEqual(get_fmt(123456, crazy, '013n'), '000-01-2345-6')
@run_with_locale('LC_ALL', 'ps_AF.UTF-8')
def test_wide_char_separator_decimal_point(self):
# locale with wide char separator and decimal point
import locale
decimal_point = locale.localeconv()['decimal_point']
thousands_sep = locale.localeconv()['thousands_sep']
if decimal_point != '\xd9\xab':
self.skipTest('inappropriate decimal point separator'
'({!r} not {!r})'.format(decimal_point, '\xd9\xab'))
if thousands_sep != '\xd9\xac':
self.skipTest('inappropriate thousands separator'
'({!r} not {!r})'.format(thousands_sep, '\xd9\xac'))
self.assertEqual(format(Decimal('100000000.123'), 'n'),
'100\xd9\xac000\xd9\xac000\xd9\xab123')
class DecimalArithmeticOperatorsTest(unittest.TestCase): class DecimalArithmeticOperatorsTest(unittest.TestCase):
'''Unit tests for all arithmetic operators, binary and unary.''' '''Unit tests for all arithmetic operators, binary and unary.'''
...@@ -1683,10 +1658,9 @@ class DecimalPythonAPItests(unittest.TestCase): ...@@ -1683,10 +1658,9 @@ class DecimalPythonAPItests(unittest.TestCase):
def test_pickle(self): def test_pickle(self):
d = Decimal('-3.141590000') d = Decimal('-3.141590000')
for proto in range(pickle.HIGHEST_PROTOCOL + 1): p = pickle.dumps(d)
p = pickle.dumps(d, proto) e = pickle.loads(p)
e = pickle.loads(p) self.assertEqual(d, e)
self.assertEqual(d, e)
def test_int(self): def test_int(self):
for x in range(-250, 250): for x in range(-250, 250):
...@@ -1770,13 +1744,12 @@ class DecimalPythonAPItests(unittest.TestCase): ...@@ -1770,13 +1744,12 @@ class DecimalPythonAPItests(unittest.TestCase):
class ContextAPItests(unittest.TestCase): class ContextAPItests(unittest.TestCase):
def test_pickle(self): def test_pickle(self):
for proto in range(pickle.HIGHEST_PROTOCOL + 1): c = Context()
c = Context() e = pickle.loads(pickle.dumps(c))
e = pickle.loads(pickle.dumps(c, proto)) for k in vars(c):
for k in vars(c): v1 = vars(c)[k]
v1 = vars(c)[k] v2 = vars(e)[k]
v2 = vars(e)[k] self.assertEqual(v1, v2)
self.assertEqual(v1, v2)
def test_equality_with_other_types(self): def test_equality_with_other_types(self):
self.assertIn(Decimal(10), ['a', 1.0, Decimal(10), (1,2), {}]) self.assertIn(Decimal(10), ['a', 1.0, Decimal(10), (1,2), {}])
...@@ -2298,7 +2271,7 @@ class ContextFlags(unittest.TestCase): ...@@ -2298,7 +2271,7 @@ class ContextFlags(unittest.TestCase):
"operation raises different flags depending on flags set: " + "operation raises different flags depending on flags set: " +
"expected %s, got %s" % (expected_flags, new_flags)) "expected %s, got %s" % (expected_flags, new_flags))
def test_main(arith=None, verbose=None, todo_tests=None, debug=None): def test_main(arith=False, verbose=None, todo_tests=None, debug=None):
""" Execute the tests. """ Execute the tests.
Runs all arithmetic tests if arith is True or if the "decimal" resource Runs all arithmetic tests if arith is True or if the "decimal" resource
...@@ -2307,7 +2280,7 @@ def test_main(arith=None, verbose=None, todo_tests=None, debug=None): ...@@ -2307,7 +2280,7 @@ def test_main(arith=None, verbose=None, todo_tests=None, debug=None):
init() init()
global TEST_ALL, DEBUG global TEST_ALL, DEBUG
TEST_ALL = arith if arith is not None else is_resource_enabled('decimal') TEST_ALL = arith or is_resource_enabled('decimal')
DEBUG = debug DEBUG = debug
if todo_tests is None: if todo_tests is None:
......
...@@ -2190,9 +2190,14 @@ template <ExceptionStyle S> Box* _getattrEntry(Box* obj, BoxedString* attr, void ...@@ -2190,9 +2190,14 @@ template <ExceptionStyle S> Box* _getattrEntry(Box* obj, BoxedString* attr, void
assert(!rtn); assert(!rtn);
rtn = rewriter->loadConst(0, Location::forArg(1)); rtn = rewriter->loadConst(0, Location::forArg(1));
} }
rewriter->call(true, (void*)NoexcHelper::call, rtn, rewriter->getArg(0), if (S == CXX && return_convention == ReturnConvention::CAPI_RETURN) {
rewriter->loadConst((intptr_t)attr, Location::forArg(2))); rewriter->checkAndThrowCAPIException(rtn);
return_convention = (S == CXX) ? ReturnConvention::HAS_RETURN : ReturnConvention::CAPI_RETURN; return_convention = ReturnConvention::HAS_RETURN;
} else {
rewriter->call(true, (void*)NoexcHelper::call, rtn, rewriter->getArg(0),
rewriter->loadConst((intptr_t)attr, Location::forArg(2)));
return_convention = (S == CXX) ? ReturnConvention::HAS_RETURN : ReturnConvention::CAPI_RETURN;
}
} }
} }
......
...@@ -73,7 +73,6 @@ test_ctypes [unknown] ...@@ -73,7 +73,6 @@ test_ctypes [unknown]
test_curses [unknown] test_curses [unknown]
test_datetime needs _PyObject_GetDictPtr test_datetime needs _PyObject_GetDictPtr
test_dbm [unknown] test_dbm [unknown]
test_decimal I think we need to copy decimaltestdata from cpython
test_decorators decorator bug -- we evaluate decorator obj and its args in wrong order test_decorators decorator bug -- we evaluate decorator obj and its args in wrong order
test_deque couple unknown issues test_deque couple unknown issues
test_descrtut `exec in DefaultDict()` test_descrtut `exec in DefaultDict()`
......
../../from_cpython/Lib/test/decimaltestdata
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment