Skip to content

Env var PYTHONUTF8 added by pythonTerminalEnvVarActivation makes error chinese output encoding in pwsh. #22205

Closed
@cesaryuan

Description

@cesaryuan

Type: Bug

Behaviour

Expected vs. Actual

Expect powershell command (Start-Job {python -c "print('中文')"}) | Receive-Job -Wait write 中文 to stdout instead of 涓枃

Steps to reproduce:

  1. enable activateEnvironment and pythonTerminalEnvVarActivation.
  2. open pwsh or Powershell in VSCode terminal.
  3. run (Start-Job {python -c "print('中文')"}) | Receive-Job -Wait.
  4. we can see the output is 涓枃 instead of 中文.
  5. disable activateEnvironment or run $env:PYTHONUTF8 = 0 will make the output correct.

As I can see, the $env:PYTHONUTF8 = 1 is import by Extension: ms-python.python. However, original conda activate command will not add the env var.
image

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.10.13
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Conda
  • Value of the python.languageServer setting: Pylance
Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

XXX

User Settings


languageServer: "Pylance"

linting
• pylintArgs: "<placeholder>"

formatting
• autopep8Args: "<placeholder>"
• yapfArgs: "<placeholder>"

terminal
• activateEnvironment: true

experiments
• optInto: ["pythonTerminalEnvVarActivation"]

Extension version: 2023.18.0
VS Code version: Code 1.83.1 (f1b07bd25dfad64b0167beb15359ae573aecd2cc, 2023-10-10T23:48:05.904Z)
OS version: Windows_NT x64 10.0.19045
Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i7-6850K CPU @ 3.60GHz (12 x 3598)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 63.91GB (39.21GB free)
Process Argv --crash-reporter-id 232c4e71-71ce-4b2d-b368-c38367e676b7
Screen Reader no
VM 24%
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263cf:30335440
vscoreces:30445986
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
pythonvs932:30410667
py29gd2263:30856252
vsclangdf:30486550
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30695312
azure-dev_surveyone:30548225
2e4cg342:30602488
f6dab269:30613381
2i9eh265:30646982
showlangstatbar:30737416
03d35959:30757346
pythonfmttext:30731395
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
pythonnosmt12:30797651
pythonidxptcf:30805731
pythonnoceb:30805159
copilotsettingc:30839828
dsvsc013:30795093
dsvsc014:30804076
diffeditorv1:30821571
dsvsc015:30845448
pyreplss2:30858576

Metadata

Metadata

Assignees

Labels

area-terminalauthor-verification-requestedIssues potentially verifiable by issue authorbugIssue identified by VS Code Team member as probable bugverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions