Skip to content

Commit ebaf468

Browse files
committed
remove test_backdoor_resistance
1 parent 6f4db2b commit ebaf468

File tree

1 file changed

+0
-36
lines changed

1 file changed

+0
-36
lines changed

Lib/test/datetimetester.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,32 +1958,6 @@ def test_pickling_subclass_date(self):
19581958
self.assertEqual(orig, derived)
19591959
self.assertTrue(isinstance(derived, SubclassDate))
19601960

1961-
def test_backdoor_resistance(self):
1962-
# For fast unpickling, the constructor accepts a pickle byte string.
1963-
# This is a low-overhead backdoor. A user can (by intent or
1964-
# mistake) pass a string directly, which (if it's the right length)
1965-
# will get treated like a pickle, and bypass the normal sanity
1966-
# checks in the constructor. This can create insane objects.
1967-
# The constructor doesn't want to burn the time to validate all
1968-
# fields, but does check the month field. This stops, e.g.,
1969-
# datetime.datetime('1995-03-25') from yielding an insane object.
1970-
base = b'1995-03-25'
1971-
if not issubclass(self.theclass, datetime):
1972-
base = base[:4]
1973-
for month_byte in b'9', b'\0', b'\r', b'\xff':
1974-
self.assertRaises(TypeError, self.theclass,
1975-
base[:2] + month_byte + base[3:])
1976-
if issubclass(self.theclass, datetime):
1977-
# Good bytes, but bad tzinfo:
1978-
with self.assertRaisesRegex(TypeError, '^bad tzinfo state arg$'):
1979-
self.theclass(bytes([1] * len(base)), 'EST')
1980-
1981-
for ord_byte in range(1, 13):
1982-
# This shouldn't blow up because of the month byte alone. If
1983-
# the implementation changes to do more-careful checking, it may
1984-
# blow up because other fields are insane.
1985-
self.theclass(base[:2] + bytes([ord_byte]) + base[3:])
1986-
19871961
def test_valuerror_messages(self):
19881962
pattern = re.compile(
19891963
r"(year|month|day) must be in \d+\.\.\d+, not \d+"
@@ -4164,16 +4138,6 @@ def newmeth(self, start):
41644138
self.assertEqual(dt1.isoformat(), dt2.isoformat())
41654139
self.assertEqual(dt2.newmeth(-7), dt1.hour + dt1.second - 7)
41664140

4167-
def test_backdoor_resistance(self):
4168-
# see TestDate.test_backdoor_resistance().
4169-
base = '2:59.0'
4170-
for hour_byte in ' ', '9', chr(24), '\xff':
4171-
self.assertRaises(TypeError, self.theclass,
4172-
hour_byte + base[1:])
4173-
# Good bytes, but bad tzinfo:
4174-
with self.assertRaisesRegex(TypeError, '^bad tzinfo state arg$'):
4175-
self.theclass(bytes([1] * len(base)), 'EST')
4176-
41774141
# A mixin for classes with a tzinfo= argument. Subclasses must define
41784142
# theclass as a class attribute, and theclass(1, 1, 1, tzinfo=whatever)
41794143
# must be legit (which is true for time and datetime).

0 commit comments

Comments
 (0)