self.assertIs(self.loads(b'I01\n.'), True)
self.assertIs(self.loads(b'I00\n.'), False)
+ def test_issue135241(self):
+ # C implementation should check for hardcoded values 00 and 01
+ # when getting booleans from the INT opcode. Doing a str comparison
+ # to bypass truthy/falsy comparisons. These payloads should return
+ # 0, not False.
+ out1 = self.loads(b'I+0\n.')
+ self.assertEqual(str(out1), '0')
+ out2 = self.loads(b'I 0\n.')
+ self.assertEqual(str(out2), '0')
+
def test_zero_padded_integers(self):
self.assertEqual(self.loads(b'I010\n.'), 10)
self.assertEqual(self.loads(b'I-010\n.'), -10)
--- /dev/null
+The :code:`INT` opcode of the C accelerator :mod:`!_pickle` module was updated
+to look only for "00" and "01" to push booleans onto the stack, aligning with
+the Python :mod:`pickle` module.
}
}
else {
- if (len == 3 && (x == 0 || x == 1)) {
+ if (len == 3 && s[0] == '0' && (s[1] == '0' || s[1] == '1')) {
if ((value = PyBool_FromLong(x)) == NULL)
return -1;
}