Index: Objects/longobject.c =================================================================== --- Objects/longobject.c (revision 68320) +++ Objects/longobject.c (working copy) @@ -1990,8 +1990,6 @@ goto onError; if (sign < 0) Py_SIZE(z) = -(Py_SIZE(z)); - if (*str == 'L' || *str == 'l') - str++; while (*str && isspace(Py_CHARMASK(*str))) str++; if (*str != '\0') Index: Misc/NEWS =================================================================== --- Misc/NEWS (revision 68321) +++ Misc/NEWS (working copy) @@ -12,6 +12,9 @@ Core and Builtins ----------------- +- Issue #4842: Don't allow trailing L in construction of an integer + from a string. + - Issue #4580: Fix slicing of memoryviews when the item size is greater than one byte. Also fixes the meaning of len() so that it returns the number of items, rather than the size in bytes. Index: Lib/test/test_long.py =================================================================== --- Lib/test/test_long.py (revision 68320) +++ Lib/test/test_long.py (working copy) @@ -284,6 +284,16 @@ self.assertRaises(ValueError, int, '123\0') self.assertRaises(ValueError, int, '53', 40) + # trailing L should no longer be accepted... + self.assertRaises(ValueError, int, '123L') + self.assertRaises(ValueError, int, '123l') + self.assertRaises(ValueError, int, '0L') + self.assertRaises(ValueError, int, '-37L') + self.assertRaises(ValueError, int, '0x32L', 16) + self.assertRaises(ValueError, int, '1L', 21) + # ... but it's just a normal digit if base >= 22 + self.assertEqual(int('1L', 22), 43) + self.assertRaises(TypeError, int, 1, 12) # SF patch #1638879: embedded NULs were not detected with