Skip to content

py.ini and pyw.ini (for the launcher) are ignored if they are encoded in utf-8 with BOM  #99620

Closed as not planned

Description

@WiliTest

Bug report

To reproducible example:

create a py.ini and pyw.ini encoded in utf-8 with BOM.
They won't be recognized by the launcher. (They will work if the encoding is set to UTF8).

Your environment

  • CPython versions tested on: tested on python 3.6 and 3.9 and 3.11
  • Operating system and architecture: windows 10

Activity

  1. urica12 commented on Nov 21, 2022

    @urica12
  2. urica12 commented on Nov 21, 2022

    @urica12
  3. lazka commented on Jun 12, 2024

    @lazka
    Contributor

    I can confirm this (I wrote the file with powershell which adds a BOM in older versions).

    While I'm fine with it failing, the launcher debug output showed # Did not find file C:\Windows\py.ini despite it being there, which was quite confusing.

  4. StanFromIreland commented on Mar 9, 2025

    @StanFromIreland
  5. picnixz commented on Mar 9, 2025

    @picnixz
  6. chris-eibl commented on Mar 10, 2025

    @chris-eibl
    Member

    When implementing #131021 to fix #131020, I've had a quick look at the problem here:

    cpython/PC/launcher2.c

    Lines 920 to 928 in 475f933

    int
    _readIni(const wchar_t *section, const wchar_t *settingName, wchar_t *buffer, int bufferLength)
    {
    wchar_t iniPath[MAXLEN];
    int n;
    if (SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, iniPath)) &&
    join(iniPath, MAXLEN, L"py.ini")) {
    debug(L"# Reading from %s for %s/%s\n", iniPath, section, settingName);
    n = GetPrivateProfileStringW(section, settingName, NULL, buffer, bufferLength, iniPath);

    Internet search for "GetPrivateProfileStringW" "BOM" seems to reveal that indeed that there are issues with it.

  7. zooba commented on Mar 10, 2025

    @zooba
    Member

    Yeah, this issue will have been around forever, which should mean there are precisely zero py.ini files out there with a BOM.

    In any case, if PEP 773 goes through, this launcher will be deprecated and replaced. So let's not worry about this one until we see whether we get to move to a better implementation or not.

  8. zooba commented on Jul 20, 2026

    @zooba
    Member

    The launcher referred to in this issue has now been removed (#153511), and so this issue is expired. Please use the Python install manager to install Python, and file any issues on the pymanager repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions