Created on 2018-10-13 19:18 by serhiy.storchaka, last changed 2022-04-11 14:59 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 9852 | merged | serhiy.storchaka, 2018-10-13 19:28 | |
| PR 9878 | merged | miss-islington, 2018-10-14 21:03 | |
| PR 9879 | merged | miss-islington, 2018-10-14 21:03 | |
| PR 9885 | merged | serhiy.storchaka, 2018-10-15 05:12 | |
| Messages (5) | |||
|---|---|---|---|
| msg327661 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * | Date: 2018-10-13 19:18 | |
bytes() and bytearray() replace some unexpected exceptions (including MemoryError and KeyboardInterrupt) with TypeError.
1) Exception in __index__.
class X:
def __index__(self):
raise MemoryError
`bytes(X())` results in:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: cannot convert 'X' object to bytes
`bytearray(X())` results in:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'X' object is not iterable
This is related to issue29159.
2) Exception in __iter__.
class X:
def __iter__(self):
raise MemoryError
`bytes(X())` results in:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: cannot convert 'X' object to bytes
`bytearray(X())` works correctly (raises a MemoryError).
The proper solution is to replace just a TypeError and allow other exceptions to emerge.
|
|||
| msg327721 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * | Date: 2018-10-14 21:03 | |
New changeset e890421e334ccf0c000c6b29c4a521d86cd12f47 by Serhiy Storchaka in branch 'master': bpo-34974: Do not replace unexpected errors in bytes() and bytearray(). (GH-9852) https://github.com/python/cpython/commit/e890421e334ccf0c000c6b29c4a521d86cd12f47 |
|||
| msg327722 - (view) | Author: miss-islington (miss-islington) | Date: 2018-10-14 21:26 | |
New changeset 1370832af24cc6f0f464354b9ec3ecdb343d35ce by Miss Islington (bot) in branch '3.7': bpo-34974: Do not replace unexpected errors in bytes() and bytearray(). (GH-9852) https://github.com/python/cpython/commit/1370832af24cc6f0f464354b9ec3ecdb343d35ce |
|||
| msg327723 - (view) | Author: miss-islington (miss-islington) | Date: 2018-10-14 21:32 | |
New changeset 08ba7eb89d5353af31ef9e66a5337abea1b676ef by Miss Islington (bot) in branch '3.6': bpo-34974: Do not replace unexpected errors in bytes() and bytearray(). (GH-9852) https://github.com/python/cpython/commit/08ba7eb89d5353af31ef9e66a5337abea1b676ef |
|||
| msg327730 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * | Date: 2018-10-15 05:46 | |
New changeset 43308dfc3335906cfefe9f14a44e468935f3c321 by Serhiy Storchaka in branch '2.7': [2.7] bpo-34974: Do not replace unexpected errors in bytearray(). (GH-9852) (GH-9885) https://github.com/python/cpython/commit/43308dfc3335906cfefe9f14a44e468935f3c321 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:07 | admin | set | github: 79155 |
| 2018-10-15 05:46:54 | serhiy.storchaka | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2018-10-15 05:46:22 | serhiy.storchaka | set | messages: + msg327730 |
| 2018-10-15 05:14:59 | serhiy.storchaka | set | versions: + Python 2.7 |
| 2018-10-15 05:12:17 | serhiy.storchaka | set | pull_requests: + pull_request9248 |
| 2018-10-14 21:32:07 | miss-islington | set | messages: + msg327723 |
| 2018-10-14 21:26:32 | miss-islington | set | nosy:
+ miss-islington messages: + msg327722 |
| 2018-10-14 21:03:24 | miss-islington | set | pull_requests: + pull_request9242 |
| 2018-10-14 21:03:17 | miss-islington | set | pull_requests: + pull_request9241 |
| 2018-10-14 21:03:01 | serhiy.storchaka | set | messages: + msg327721 |
| 2018-10-13 19:28:24 | serhiy.storchaka | set | keywords:
+ patch stage: patch review pull_requests: + pull_request9222 |
| 2018-10-13 19:18:56 | serhiy.storchaka | create | |