Subject | Hash | Author | Date (UTC) |
---|---|---|---|
bpo-29998: Pickling and copying ImportError now preserves name and path (#1010) | b785396ab451b0c9d6ae9ee5a9e56c810209a6cb | Serhiy Storchaka | 2017-04-08 06:55:07 |
Expand the PySlice_GetIndicesEx macro. (#1023) | b879fe82e7e5c3f7673c9a7fa4aad42bd05445d8 | Serhiy Storchaka | 2017-04-08 06:53:51 |
bpo-29914: Fix default implementations of __reduce__ and __reduce_ex__(). (#843) | 205e00c5cfd495a4dc6dae8e8fa0fb828fb3dca9 | Serhiy Storchaka | 2017-04-08 06:52:59 |
Fix a minor typo. (#1032) | dd9a0a14c89d57e43898d4b866b8c161e4ff8506 | Barry Warsaw | 2017-04-07 18:18:14 |
bpo-29958: Minor improvements to zipfile and tarfile CLI. (#944) | 150cd1916a59e750ce88c65325de9ef0c42c6cb5 | Serhiy Storchaka | 2017-04-07 15:56:12 |
Remove Invalid comment in test_urllib2.py (#1020) | fd0cd07a5a3c964c084f4efc5bbcb89dd2193ee6 | Senthil Kumaran | 2017-04-07 07:19:08 |
bpo-28837: Fix lib2to3 handling of map/zip/filter calls when followed with a 'trailer', e.g. zip()[x] (#24) | 93b4b47e3a720171d67f3b608de406aef462835c | Stuart Berg | 2017-04-06 05:19:40 |
Correct typo in configparser.rst (#1012) | 01fa9ae5460b00bf1ced500c797176ebd3fb060d | Alex Jordan | 2017-04-06 02:21:30 |
bpo-29962: add math.remainder (#950) | a0ce375e10b50f7606cb86b072fed7d8cd574fe7 | Mark Dickinson | 2017-04-05 17:34:27 |
Miscellaneous minor fixes of Misc/NEWS formatting. (#1002) | a0157b5f11e621f2196af4e918b9f07688a6cd1c | Serhiy Storchaka | 2017-04-05 09:07:22 |
Update Argument Clinic generated code for bpo-29878. (#1001) | bae6881b4215b2613ad08ef0dc7bed7743c2b8cc | Serhiy Storchaka | 2017-04-05 09:00:42 |
bpo-29762: More use "raise from None". (#569) | 5affd23e6f42125998724787025080a24839266e | Serhiy Storchaka | 2017-04-05 06:37:24 |
bpo-29549: Fixes docstring for str.index (#256) | 43ba8861e0ad044efafa46a7cc04e12ac5df640e | Lisa Roach | 2017-04-05 05:36:22 |
correct parse_qs and parse_qsl test case descriptions. (#968) | 257b980b316a5206ecf6c23b958e2b7c4df4f3de | Senthil Kumaran | 2017-04-05 04:19:43 |
bpo-29649: Improve struct.pack_into() boundary error messages (#424) | f78b119364b521307237a1484ba5f43f42300898 | Andrew Nester | 2017-04-04 10:46:25 |
bpo-29972: Skip tests known to fail on AIX (#979) | 5de85a17029356084b96db63e04d9eb150efd9c0 | Victor Stinner | 2017-04-04 08:35:15 |
bpo-29725: DOC: add text for arraysize in sqlite3.Cursor (#947) | 02e12138000da834f23719521a011fa93763384d | csabella | 2017-04-04 05:16:14 |
Remove obsolete declaration in tokenizer.h (#962) | cf1958af4c762c970d1f2fa0e92577f577774c22 | Jim Fasarakis-Hilliard | 2017-04-03 16:18:32 |
Correct typo (#976) | 8614b59910c0b3529891be164aee581eb729f1b3 | Angus Hollands | 2017-04-03 16:16:14 |
test_locale now ignores the DeprecationWarning (#977) | 9acc6a03f1fd684fce2755b3b22f7448ad4c1dd6 | Victor Stinner | 2017-04-03 16:09:55 |
File | Lines added | Lines deleted |
---|---|---|
Lib/test/test_exceptions.py | 20 | 0 |
Misc/NEWS | 3 | 0 |
Objects/exceptions.c | 48 | 0 |
File Lib/test/test_exceptions.py changed (mode: 100644) (index 2cac6c530a..e6fa34610d) | |||
1 | 1 | # Python test set -- part 5, built-in exceptions | # Python test set -- part 5, built-in exceptions |
2 | 2 | ||
3 | import copy | ||
3 | 4 | import os | import os |
4 | 5 | import sys | import sys |
5 | 6 | import unittest | import unittest |
... | ... | class ImportErrorTests(unittest.TestCase): | |
1126 | 1127 | exc = ImportError(arg) | exc = ImportError(arg) |
1127 | 1128 | self.assertEqual(str(arg), str(exc)) | self.assertEqual(str(arg), str(exc)) |
1128 | 1129 | ||
1130 | def test_copy_pickle(self): | ||
1131 | for kwargs in (dict(), | ||
1132 | dict(name='somename'), | ||
1133 | dict(path='somepath'), | ||
1134 | dict(name='somename', path='somepath')): | ||
1135 | orig = ImportError('test', **kwargs) | ||
1136 | for proto in range(pickle.HIGHEST_PROTOCOL + 1): | ||
1137 | exc = pickle.loads(pickle.dumps(orig, proto)) | ||
1138 | self.assertEqual(exc.args, ('test',)) | ||
1139 | self.assertEqual(exc.msg, 'test') | ||
1140 | self.assertEqual(exc.name, orig.name) | ||
1141 | self.assertEqual(exc.path, orig.path) | ||
1142 | for c in copy.copy, copy.deepcopy: | ||
1143 | exc = c(orig) | ||
1144 | self.assertEqual(exc.args, ('test',)) | ||
1145 | self.assertEqual(exc.msg, 'test') | ||
1146 | self.assertEqual(exc.name, orig.name) | ||
1147 | self.assertEqual(exc.path, orig.path) | ||
1148 | |||
1129 | 1149 | ||
1130 | 1150 | if __name__ == '__main__': | if __name__ == '__main__': |
1131 | 1151 | unittest.main() | unittest.main() |
File Misc/NEWS changed (mode: 100644) (index 3caa1eb6e0..910488af2c) | |||
... | ... | Extension Modules | |
307 | 307 | Library | Library |
308 | 308 | ------- | ------- |
309 | 309 | ||
310 | - bpo-29998: Pickling and copying ImportError now preserves name and path | ||
311 | attributes. | ||
312 | |||
310 | 313 | - bpo-29962: Add math.remainder operation, implementing remainder | - bpo-29962: Add math.remainder operation, implementing remainder |
311 | 314 | as specified in IEEE 754. | as specified in IEEE 754. |
312 | 315 |
File Objects/exceptions.c changed (mode: 100644) (index e5e59b4c8b..0c7b9b2686) | |||
... | ... | ImportError_str(PyImportErrorObject *self) | |
682 | 682 | } | } |
683 | 683 | } | } |
684 | 684 | ||
685 | static PyObject * | ||
686 | ImportError_getstate(PyImportErrorObject *self) | ||
687 | { | ||
688 | PyObject *dict = ((PyBaseExceptionObject *)self)->dict; | ||
689 | if (self->name || self->path) { | ||
690 | _Py_IDENTIFIER(name); | ||
691 | _Py_IDENTIFIER(path); | ||
692 | dict = dict ? PyDict_Copy(dict) : PyDict_New(); | ||
693 | if (dict == NULL) | ||
694 | return NULL; | ||
695 | if (self->name && _PyDict_SetItemId(dict, &PyId_name, self->name) < 0) { | ||
696 | Py_DECREF(dict); | ||
697 | return NULL; | ||
698 | } | ||
699 | if (self->path && _PyDict_SetItemId(dict, &PyId_path, self->path) < 0) { | ||
700 | Py_DECREF(dict); | ||
701 | return NULL; | ||
702 | } | ||
703 | return dict; | ||
704 | } | ||
705 | else if (dict) { | ||
706 | Py_INCREF(dict); | ||
707 | return dict; | ||
708 | } | ||
709 | else { | ||
710 | Py_RETURN_NONE; | ||
711 | } | ||
712 | } | ||
713 | |||
714 | /* Pickling support */ | ||
715 | static PyObject * | ||
716 | ImportError_reduce(PyImportErrorObject *self) | ||
717 | { | ||
718 | PyObject *res; | ||
719 | PyObject *args; | ||
720 | PyObject *state = ImportError_getstate(self); | ||
721 | if (state == NULL) | ||
722 | return NULL; | ||
723 | args = ((PyBaseExceptionObject *)self)->args; | ||
724 | if (state == Py_None) | ||
725 | res = PyTuple_Pack(2, Py_TYPE(self), args); | ||
726 | else | ||
727 | res = PyTuple_Pack(3, Py_TYPE(self), args, state); | ||
728 | Py_DECREF(state); | ||
729 | return res; | ||
730 | } | ||
731 | |||
685 | 732 | static PyMemberDef ImportError_members[] = { | static PyMemberDef ImportError_members[] = { |
686 | 733 | {"msg", T_OBJECT, offsetof(PyImportErrorObject, msg), 0, | {"msg", T_OBJECT, offsetof(PyImportErrorObject, msg), 0, |
687 | 734 | PyDoc_STR("exception message")}, | PyDoc_STR("exception message")}, |
... | ... | static PyMemberDef ImportError_members[] = { | |
693 | 740 | }; | }; |
694 | 741 | ||
695 | 742 | static PyMethodDef ImportError_methods[] = { | static PyMethodDef ImportError_methods[] = { |
743 | {"__reduce__", (PyCFunction)ImportError_reduce, METH_NOARGS}, | ||
696 | 744 | {NULL} | {NULL} |
697 | 745 | }; | }; |
698 | 746 |