| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -734,6 +734,13 @@ def test_resize_past_pos(self): | |||
| 734 | 734 | self.assertRaises(ValueError, m.write_byte, 42) | |
| 735 | 735 | self.assertRaises(ValueError, m.write, b'abc') | |
| 736 | 736 | ||
| 737 | + def test_concat_repeat_exception(self): | ||
| 738 | + m = mmap.mmap(-1, 16) | ||
| 739 | + with self.assertRaises(TypeError): | ||
| 740 | + m + m | ||
| 741 | + with self.assertRaises(TypeError): | ||
| 742 | + m * 2 | ||
| 743 | + | ||
| 737 | 744 | ||
| 738 | 745 | class LargeMmapTests(unittest.TestCase): | |
| 739 | 746 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + The concatenation (``+``) and repetition (``*``) sequence operations now | ||
| 2 | + raise :exc:`TypeError` instead of :exc:`SystemError` when performed on | ||
| 3 | + :class:`mmap.mmap` objects. Patch by Zackery Spytz. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -812,24 +812,6 @@ mmap_subscript(mmap_object *self, PyObject *item) | |||
| 812 | 812 | } | |
| 813 | 813 | } | |
| 814 | 814 | ||
| 815 | - static PyObject * | ||
| 816 | - mmap_concat(mmap_object *self, PyObject *bb) | ||
| 817 | - { | ||
| 818 | - CHECK_VALID(NULL); | ||
| 819 | - PyErr_SetString(PyExc_SystemError, | ||
| 820 | - "mmaps don't support concatenation"); | ||
| 821 | - return NULL; | ||
| 822 | - } | ||
| 823 | - | ||
| 824 | - static PyObject * | ||
| 825 | - mmap_repeat(mmap_object *self, Py_ssize_t n) | ||
| 826 | - { | ||
| 827 | - CHECK_VALID(NULL); | ||
| 828 | - PyErr_SetString(PyExc_SystemError, | ||
| 829 | - "mmaps don't support repeat operation"); | ||
| 830 | - return NULL; | ||
| 831 | - } | ||
| 832 | - | ||
| 833 | 815 | static int | |
| 834 | 816 | mmap_ass_item(mmap_object *self, Py_ssize_t i, PyObject *v) | |
| 835 | 817 | { | |
@@ -949,8 +931,8 @@ mmap_ass_subscript(mmap_object *self, PyObject *item, PyObject *value) | |||
| 949 | 931 | ||
| 950 | 932 | static PySequenceMethods mmap_as_sequence = { | |
| 951 | 933 | (lenfunc)mmap_length, /*sq_length*/ | |
| 952 | - (binaryfunc)mmap_concat, /*sq_concat*/ | ||
| 953 | - (ssizeargfunc)mmap_repeat, /*sq_repeat*/ | ||
| 934 | + 0, /*sq_concat*/ | ||
| 935 | + 0, /*sq_repeat*/ | ||
| 954 | 936 | (ssizeargfunc)mmap_item, /*sq_item*/ | |
| 955 | 937 | 0, /*sq_slice*/ | |
| 956 | 938 | (ssizeobjargproc)mmap_ass_item, /*sq_ass_item*/ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments