Skip to content

Crash on Windows if Python runs from a directory with umlauts #45683

Closed

Description

@tiran
BPO 1342
Nosy @gvanrossum, @loewis, @amauryfa, @pitrou, @tiran
Files
  • py3k_more_win_fsencoding.patch
  • py3k_win_nonascii.patch
  • win_nonascii.patch: decode paths with FileSystemDefaultEncoding
  • 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/amauryfa'
    closed_at = <Date 2008-06-11.18:26:49.274>
    created_at = <Date 2007-10-27.03:40:35.693>
    labels = ['interpreter-core', 'type-crash']
    title = 'Crash on Windows if Python runs from a directory with umlauts'
    updated_at = <Date 2008-06-11.18:26:43.466>
    user = 'https://github.com/tiran'

    bugs.python.org fields:

    activity = <Date 2008-06-11.18:26:43.466>
    actor = 'amaury.forgeotdarc'
    assignee = 'amaury.forgeotdarc'
    closed = True
    closed_date = <Date 2008-06-11.18:26:49.274>
    closer = 'amaury.forgeotdarc'
    components = ['Interpreter Core']
    creation = <Date 2007-10-27.03:40:35.693>
    creator = 'christian.heimes'
    dependencies = []
    files = ['8633', '8741', '10575']
    hgrepos = []
    issue_num = 1342
    keywords = ['patch']
    message_count = 17.0
    messages = ['56841', '56852', '56853', '56865', '56979', '57094', '57456', '57466', '57474', '57681', '57687', '57698', '66441', '66460', '66462', '67915', '68006']
    nosy_count = 7.0
    nosy_names = ['gvanrossum', 'loewis', 'nnorwitz', 'amaury.forgeotdarc', 'pitrou', 'christian.heimes', 'rasky']
    pr_nums = []
    priority = 'critical'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue1342'
    versions = ['Python 3.0']

    Activity

    1. tiran commented on Oct 27, 2007

      @tiran
      MemberAuthor

      Python 3.0 doesn't run from a directory with umlauts and possible other
      non ASCII chars.

      I renamed my development folder from C:\dev\ to c:\test äöüß name\.
      Python crashes after a few moments before it can reach its shell.

      python30.dll!PyErr_SetObject(_object * exception=0x1e1b9888, \_object \*
      

      value=0x00a0b8a0) Zeile 56 + 0xb Bytes C
      python30.dll!PyErr_SetString(_object * exception=0x1e1b9888, const
      char * string=0x1e18c358) Zeile 77 + 0xd Bytes C
      python30.dll!find_module(char * fullname=0x0021fcc0, char *
      subname=0x00000000, _object * path=0x00000000, char * buf=0x0021fb70,
      unsigned int buflen=257, _iobuf * * p_fp=0x0021fb64, _object * *
      p_loader=0x0021fb68) Zeile 1228 + 0x10 Bytes C
      python30.dll!import_submodule(_object * mod=0x1e1c6a88, char *
      subname=0x0021fcc0, char * fullname=0x00000000) Zeile 2313 + 0x27 Bytes C
      python30.dll!load_next(_object * mod=0x1e1c6a88, _object *
      altmod=0x1e1c6a88, char * * p_name=0x00000000, char * buf=0x0021fcc0,
      int * p_buflen=0x0021fcbc) Zeile 2127 + 0x15 Bytes C
      python30.dll!import_module_level(char * name=0x00000000, _object *
      globals=0x00000000, _object * locals=0x1e069ec3, _object *
      fromlist=0x00000000, int level=0) Zeile 1908 + 0x1a Bytes C
      python30.dll!PyImport_ImportModuleLevel(char * name=0x1e184b04,
      _object * globals=0x00000000, _object * locals=0x00000000, _object *
      fromlist=0x00000000, int level=0) Zeile 1979 + 0x18 Bytes C
      python30.dll!_PyCodecRegistry_Init() Zeile 841 + 0x12 Bytes C
      python30.dll!PyCodec_LookupError(const char * name=0x00000000) Zeile
      436 + 0xc Bytes C
      python30.dll!unicode_decode_call_errorhandler(const char *
      errors=0x00000000, _object * * errorHandler=0x00000009, const char *
      encoding=0x1e1979ec, const char * reason=0x00000000, const char * *
      input=0x0021fe80, const char * * inend=0x0021fe84, int *
      startinpos=0x0021fe6c, int * endinpos=0x0021fe68, _object * *
      exceptionObject=0x00000000, const char * * inptr=0x0021fe90, _object * *
      output=0x0021fe70, int * outpos=0x0021fe88, unsigned short * *
      outptr=0x0021fe74) Zeile 1384 + 0xa Bytes C
      python30.dll!PyUnicodeUCS2_DecodeUTF8Stateful(const char *
      s=0x1e1dd010, int size=48, const char * errors=0x00000000, int *
      consumed=0x00000000) Zeile 1967 + 0x47 Bytes C
      python30.dll!PyUnicodeUCS2_FromStringAndSize(const char *
      u=0x1e1dd008, int size=48) Zeile 464 + 0xb Bytes C
      python30.dll!PyUnicodeUCS2_FromString(const char * u=0x1e1dd008)
      Zeile 482 + 0x7 Bytes C
      python30.dll!_PySys_Init() Zeile 1084 + 0xb Bytes C
      python30.dll!Py_InitializeEx(int install_sigs=1) Zeile 220 C
      python30.dll!Py_Initialize() Zeile 292 + 0x7 Bytes C
      python30.dll!Py_Main(int argc=2, char * * argv=0x00000001) Zeile 432 C

      python.exe!mainCRTStartup() Zeile 398 + 0xe Bytes C
      kernel32.dll!7c816fd7()

    2. added
      interpreter-core(Objects, Python, Grammar, and Parser dirs)
      type-crashA hard crash of the interpreter, possibly with a core dump
      on Oct 27, 2007
    3. tiran commented on Oct 27, 2007

      @tiran
      MemberAuthor

      The patch fixes parts of the problem. At least Python doesn't crash any
      more when run from a directory with non ASCII chars. It just fails with
      an import error in initstdio().

    4. tiran commented on Oct 27, 2007

      @tiran
      MemberAuthor

      I've added a fprintf(stderr, "%s", path) to makepathobject(). I suspect
      that PC/getpathp.c doesn't handle non ASCII chars correctly. It's using
      char instead of w_char all over the place. Could that be related to the
      issue, Neal?

      Microsoft Windows XP [Version 5.1.2600]
      (C) Copyright 1985-2001 Microsoft Corp.

      c:\testäöü\PCBuild8\win32release>set PYTHONPATH=c:\testäöü\Lib

      c:\testäöü\PCBuild8\win32release>python
      c:\testõ÷³\Lib;c:\testõ÷³\PCBuild8\win32release\python30.zip;c:\testõ÷³\DLLs;c:\
      testõ÷³\lib;c:\testõ÷³\lib\plat-win;c:\testõ÷³\lib\lib-tk;c:\testõ÷³\PCBuild8\wi
      n32releaseFatal Python error: Py_Initialize: can't initialize sys
      standard strea
      ms
      object : ImportError('No module named encodings.utf_8',)
      type : ImportError
      refcount: 4
      address : 00A43540
      lost sys.stderr

      This application has requested the Runtime to terminate it in an unusual
      way.
      Please contact the application's support team for more information.

    5. tiran commented on Oct 27, 2007

      @tiran
      MemberAuthor

      The bug is related to http://bugs.python.org/issue1262

    6. tiran commented on Oct 30, 2007

      @tiran
      MemberAuthor

      Hi Martin!

      Thomas Wouters said on #python that you have the Windows Fu to fix the
      problem. Parts of the Python API for file paths, sys.path and os.environ
      have to be reimplemented using the wide char API.

    7. tiran commented on Nov 4, 2007

      @tiran
      MemberAuthor

      I've checked in part of the patch in r58837. It doesn't solve the
      problem but at least it prevents Python from seg faulting on Windows.

    8. tiran commented on Nov 13, 2007

      @tiran
      MemberAuthor

      I like to move _PyExc_Init() before _PySys_Init() and set sys.prefix,
      exec_prefix and executable with PyUnicode_DecodeFSDefault().

      Without the changes Python is seg faulting on Windows when the path
      contains non ASCII chars. With the patch it is failing with a fatal
      error which is a tiny bit nicer.

    9. gvanrossum commented on Nov 13, 2007

      @gvanrossum
      Member

      If this doesn't cause any problems on other platforms, go for it.

    10. tiran commented on Nov 14, 2007

      @tiran
      MemberAuthor

      I'm setting the priority to normal. The issue isn't resolved but it's
      not critical for the next alpha release. By the way what's your ETA for
      the next alpha, Guido?

    11. amauryfa commented on Nov 20, 2007

      @amauryfa
      Contributor

      Assign to myself.
      Among the things to do, use Py_FileSystemDefaultEncoding (=mbcs on
      Windows) to encode sys.path items; likewise in NullImporter_init and
      other functions.
      So many places to change, we need serious testcases.

    12. self-assigned this
      on Nov 20, 2007
    13. loewis commented on Nov 20, 2007

      loewismannequin
      Mannequin

      Please don't use the FileSystemEncoding on Windows for sys.path items.
      Instead, it should use the wide API to perform all system calls. Py3k
      shouldn't ever use the file system encoding for anything on Windows.

    14. amauryfa commented on Nov 20, 2007

      @amauryfa
      Contributor

      Agreed. I will try to stay with PyObjects* until really needed by a system call.

    15. tiran commented on May 8, 2008

      @tiran
      MemberAuthor

      I'm increasing the severity of the bug. It's a still a major show
      stopper for non-English Windows users. For example see bpo-2780

    16. pitrou commented on May 9, 2008

      @pitrou
      Member

      There are some problems under Linux too:

      $ pwd
      /home/antoine/py3k/héhé
      $ ./python
      Fatal Python error: Py_Initialize: can't initialize sys standard streams
      Traceback (most recent call last):
        File "/home/antoine/py3k/pristine/Lib/encodings/__init__.py", line 32,
      in <module>
      TypeError: zipimporter() argument 1 must be string without null bytes,
      not str
      Abandon
    17. pitrou commented on May 9, 2008

      @pitrou
      Member

      See bpo-2798 for the non-Windows case, with a patch.

    18. amauryfa commented on Jun 10, 2008

      @amauryfa
      Contributor

      Here is a quick fix, that decodes filenames using
      Py_FileSystemDefaultEncoding, to let the release pass.

      I am still working on a version that keep PyObjects* as long as
      possible, but it will be a major change.

    19. amauryfa commented on Jun 11, 2008

      @amauryfa
      Contributor

      Fixed as r64126, using Py_FileSystemDefaultEncoding.

      I close this issue, and open bpo-3080 to rewrite all functions in
      import.c with full unicode in mind.

    20. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-crashA hard crash of the interpreter, possibly with a core dump

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions