This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rushant
Recipients rushant
Date 2021-03-21.04:46:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1616302012.93.0.356074990603.issue43576@roundup.psfhosted.org>
In-reply-to
Content
# -*- coding: utf-8 -*-
import os
job_name = os.environ['a']
print(job_name)
print(isinstance(job_name, str))
print(type(job_name))
with open('name.txt', 'w', encoding='utf-8')as fw:
    fw.write(job_name)


i have set environment param by :
export a="中文"
it returns error:
中文
True
<class 'str'>
Traceback (most recent call last):
  File "aa.py", line 8, in <module>
    fw.write(job_name)
UnicodeEncodeError: 'utf-8' codec can't encode characters in position 0-5: surrogates not allowed
History
Date User Action Args
2021-03-21 04:46:52rushantsetrecipients: + rushant
2021-03-21 04:46:52rushantsetmessageid: <1616302012.93.0.356074990603.issue43576@roundup.psfhosted.org>
2021-03-21 04:46:52rushantlinkissue43576 messages
2021-03-21 04:46:52rushantcreate