Author: Amaury Forgeot d'Arc <amaur...@gmail.com> Branch: py3.3 Changeset: r75268:2ba2a9841686 Date: 2015-01-09 09:53 +0100 http://bitbucket.org/pypy/pypy/changeset/2ba2a9841686/
Log: Kill time.accept2dyear diff --git a/pypy/module/time/__init__.py b/pypy/module/time/__init__.py --- a/pypy/module/time/__init__.py +++ b/pypy/module/time/__init__.py @@ -39,5 +39,4 @@ from pypy.module.time import interp_time interp_time._init_timezone(space) - interp_time._init_accept2dyear(space) diff --git a/pypy/module/time/interp_time.py b/pypy/module/time/interp_time.py --- a/pypy/module/time/interp_time.py +++ b/pypy/module/time/interp_time.py @@ -202,13 +202,6 @@ c_strftime = external('strftime', [rffi.CCHARP, rffi.SIZE_T, rffi.CCHARP, TM_P], rffi.SIZE_T) -def _init_accept2dyear(space): - if os.environ.get("PYTHONY2K"): - accept2dyear = 0 - else: - accept2dyear = 1 - _set_module_object(space, "accept2dyear", space.wrap(accept2dyear)) - def _init_timezone(space): timezone = daylight = altzone = 0 tzname = ["", ""] @@ -439,21 +432,6 @@ glob_buf.c_tm_zone = lltype.nullptr(rffi.CCHARP.TO) rffi.setintfield(glob_buf, 'c_tm_gmtoff', 0) - if y < 1000: - w_accept2dyear = _get_module_object(space, "accept2dyear") - accept2dyear = space.is_true(w_accept2dyear) - - if accept2dyear: - if 69 <= y <= 99: - y += 1900 - elif 0 <= y <= 68: - y += 2000 - else: - raise OperationError(space.w_ValueError, - space.wrap("year out of range")) - space.warn(space.wrap("Century info guessed for a 2-digit year."), - space.w_DeprecationWarning) - # tm_wday does not need checking of its upper-bound since taking "% # 7" in _gettmarg() automatically restricts the range. if rffi.getintfield(glob_buf, 'c_tm_wday') < -1: diff --git a/pypy/module/time/test/test_time.py b/pypy/module/time/test/test_time.py --- a/pypy/module/time/test/test_time.py +++ b/pypy/module/time/test/test_time.py @@ -5,7 +5,6 @@ def test_attributes(self): import time - assert isinstance(time.accept2dyear, int) assert isinstance(time.altzone, int) assert isinstance(time.daylight, int) assert isinstance(time.timezone, int) @@ -102,21 +101,11 @@ assert isinstance(res, float) ltime = time.localtime() - time.accept2dyear == 0 ltime = list(ltime) ltime[0] = -1 - raises(ValueError, time.mktime, tuple(ltime)) - time.accept2dyear == 1 - - ltime = list(ltime) - ltime[0] = 67 - ltime = tuple(ltime) - if os.name != "nt" and sys.maxsize < 1<<32: # time_t may be 64bit - raises(OverflowError, time.mktime, ltime) - - ltime = list(ltime) + time.mktime(tuple(ltime)) # Does not crash anymore ltime[0] = 100 - raises(ValueError, time.mktime, tuple(ltime)) + time.mktime(tuple(ltime)) # Does not crash anymore t = time.time() assert int(time.mktime(time.localtime(t))) == int(t) @@ -169,28 +158,6 @@ assert asc[-len(str(bigyear)):] == str(bigyear) raises(OverflowError, time.asctime, (bigyear + 1,) + (0,)*8) - def test_accept2dyear_access(self): - import time - - accept2dyear = time.accept2dyear - del time.accept2dyear - try: - # with year >= 1900 this shouldn't need to access accept2dyear - assert time.asctime((2000,) + (0,) * 8).split()[-1] == '2000' - finally: - time.accept2dyear = accept2dyear - - def test_accept2dyear_bad(self): - import time - class X: - def __bool__(self): - raise RuntimeError('boo') - orig, time.accept2dyear = time.accept2dyear, X() - try: - raises(RuntimeError, time.asctime, (200,) + (0,) * 8) - finally: - time.accept2dyear = orig - def test_struct_time(self): import time raises(TypeError, time.struct_time) @@ -281,7 +248,7 @@ raises(TypeError, time.strftime, ()) raises(TypeError, time.strftime, (1,)) raises(TypeError, time.strftime, range(8)) - exp = '2000 01 01 00 00 00 1 001' + exp = '0 01 01 00 00 00 1 001' assert time.strftime("%Y %m %d %H %M %S %w %j", (0,)*9) == exp # Guard against invalid/non-supported format string @@ -314,9 +281,6 @@ # of the time tuple. # check year - if time.accept2dyear: - raises(ValueError, time.strftime, '', (-1, 1, 1, 0, 0, 0, 0, 1, -1)) - raises(ValueError, time.strftime, '', (100, 1, 1, 0, 0, 0, 0, 1, -1)) time.strftime('', (1899, 1, 1, 0, 0, 0, 0, 1, -1)) time.strftime('', (0, 1, 1, 0, 0, 0, 0, 1, -1)) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit