3.11 Regression, Py_Initialize; Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding

Đang mở
#99,004 7 bình luận 2 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
c, python
Lĩnh vực
api, operating-systems

Hướng nghiên cứu

Bắt đầu với chương trình C sử dụng Py_Initialize và Python.h, tái hiện hành vi trên Windows 11 với Python 3.11. So sánh việc thực thi với python311.dll đã cài đặt, một DLL được sao chép và các phiên bản Python trước đó, sau đó điều tra cách quá trình khởi tạo định vị Lib/encodings. Công việc được xem là hoàn tất khi DLL Python 3.11 được sao chép có thể khởi tạo mà không cần sao chép riêng thư mục encodings.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

3.11 OS-windows type-bug

Bug report

Build and run the following program;

  #include <Python.h>
  
  int main(int argc, char* argv[])
  {
    Py_Initialize();
    return 0;
  }

The resulting executable runs fine when executed against the installed C:\Program Files\Python311\python311.dll

Executing against python311.dll copied to some other folder (C:\Windows\System32 for instance) results in;

Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x0000333c (most recent call first):
  <no Python frame>

When also C:\Program Files\Python311\Lib\encodings is copied then the executable runs fine again.

This is not the case with Python versions prior to 3.11. The only thing needed to run Python embedded for versions below 3.11 is the appropriate pythonXXX.dll

Your environment

  • CPython versions tested on:
    Python 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)] on win32
  • Operating system and architecture:
    Edition Windows 11 Pro
    Version 21H2
    Installed on ‎11/‎24/‎2021
    OS build 22000.1098
    Experience Windows Feature Experience Pack 1000.22000.1098.0
  • Compiler used:
    Microsoft Visual Studio Community 2022
    Version 17.3.6
    VisualStudio.17.Release/17.3.6+32929.385
    Microsoft .NET Framework
    Version 4.8.04161
    Installed Version: Community
    Visual C++ 2022 00482-90000-00000-AA258
    Microsoft Visual C++ 2022
Ngôn ngữ chính
Python
Star
77.2k
Fork
36k
Merge trung bình
1 ngày 9 giờ
Pull request đã merge (30 ngày)
558

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của python/cpython

Tất cả issue của python/cpython

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.