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

file.encoding doesn't apply to file.write #40358

Closed
donut mannequin opened this issue Jun 7, 2004 · 3 comments
Closed

file.encoding doesn't apply to file.write #40358

donut mannequin opened this issue Jun 7, 2004 · 3 comments
Assignees

Comments

@donut
Copy link
Mannequin

donut mannequin commented Jun 7, 2004

BPO 967986
Nosy @malemburg

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 = 'https://github.com/malemburg'
closed_at = <Date 2007-01-13.19:26:46.000>
created_at = <Date 2004-06-07.07:00:09.000>
labels = ['expert-unicode']
title = "file.encoding doesn't apply to file.write"
updated_at = <Date 2007-01-13.19:26:46.000>
user = 'https://bugs.python.org/donut'

bugs.python.org fields:

activity = <Date 2007-01-13.19:26:46.000>
actor = 'lemburg'
assignee = 'lemburg'
closed = True
closed_date = None
closer = None
components = ['Unicode']
creation = <Date 2004-06-07.07:00:09.000>
creator = 'donut'
dependencies = []
files = []
hgrepos = []
issue_num = 967986
keywords = []
message_count = 3.0
messages = ['21063', '21064', '21065']
nosy_count = 2.0
nosy_names = ['lemburg', 'donut']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue967986'
versions = ['Python 2.3']

@donut
Copy link
Mannequin Author

donut mannequin commented Jun 7, 2004

In python2.3 printing unicode to an appropriate terminal
actually works. But using sys.stdout.write doesn't.

Ex:
Python 2.3.4 (#2, May 29 2004, 03:31:27) 
[GCC 3.3.3 (Debian 20040417)] on linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> sys.stdout.encoding
'UTF-8'
>>> u=u'\u3053\u3093\u306b\u3061\u308f'
>>> print u
S“ka�
>>> sys.stdout.write(u)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
UnicodeEncodeError: 'ascii' codec can't encode
characters in position 0-4: ordinal not in range(128)

The file object docs say:
"encoding
The encoding that this file uses. When Unicode
strings are written to
a file, they will be converted to byte strings
using this encoding.
..."
Which indicates to me that it is supposed to work.

@donut donut mannequin closed this as completed Jun 7, 2004
@donut donut mannequin assigned malemburg Jun 7, 2004
@donut donut mannequin added the topic-unicode label Jun 7, 2004
@donut donut mannequin closed this as completed Jun 7, 2004
@donut donut mannequin assigned malemburg Jun 7, 2004
@donut donut mannequin added the topic-unicode label Jun 7, 2004
@malemburg
Copy link
Member

Logged In: YES
user_id=38388

The encoding feature is currently only implemented for
printing. We could also add it to .write() and .writelines()
... patches are welcome.

@malemburg
Copy link
Member

Not sure whether this is still the case. No patches were provided, so closing the feature request.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant