Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextIOWrapper: bad error reporting when write() is forbidden #50110

Closed
pitrou opened this issue Apr 27, 2009 · 2 comments
Closed

TextIOWrapper: bad error reporting when write() is forbidden #50110

pitrou opened this issue Apr 27, 2009 · 2 comments
Labels
topic-IO type-bug An unexpected behavior, bug, or error

Comments

@pitrou
Copy link
Member

pitrou commented Apr 27, 2009

BPO 5860
Nosy @pitrou

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2009-04-27.22:27:25.768>
created_at = <Date 2009-04-27.21:36:54.711>
labels = ['type-bug', 'expert-IO']
title = 'TextIOWrapper: bad error reporting when write() is forbidden'
updated_at = <Date 2009-04-27.22:27:25.767>
user = 'https://github.com/pitrou'

bugs.python.org fields:

activity = <Date 2009-04-27.22:27:25.767>
actor = 'benjamin.peterson'
assignee = 'none'
closed = True
closed_date = <Date 2009-04-27.22:27:25.768>
closer = 'benjamin.peterson'
components = ['IO']
creation = <Date 2009-04-27.21:36:54.711>
creator = 'pitrou'
dependencies = []
files = []
hgrepos = []
issue_num = 5860
keywords = []
message_count = 2.0
messages = ['86700', '86704']
nosy_count = 2.0
nosy_names = ['pitrou', 'dsm001']
pr_nums = []
priority = 'critical'
resolution = 'duplicate'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue5860'
versions = ['Python 3.1']

@pitrou
Copy link
Member Author

pitrou commented Apr 27, 2009

Opening an existing file in read-only text mode and trying to write to it:

>>> f = open("LICENSE")
>>> f.write("")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: null argument to internal routine

Binary files get it right though:

>>> f = open("LICENSE", "rb")
>>> f.write("")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
io.UnsupportedOperation: write

@pitrou pitrou added topic-IO type-bug An unexpected behavior, bug, or error labels Apr 27, 2009
@dsm001
Copy link
Mannequin

dsm001 mannequin commented Apr 27, 2009

See also http://bugs.python.org/issue5844 , which contains a patch to test.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-IO type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants