[proxy] web.archive.org← back | site home | direct (HTTPS) ↗ | proxy home | ◑ dark◐ light

python/cpython

vstinner

Commits on Nov 4, 2020

  1. bpo-42260: Main init modify sys.flags in-place (GH-23150)

    When Py_Initialize() is called twice, the second call now updates
    more sys attributes for the configuration, rather than only sys.argv.
    
    * Rename _PySys_InitMain() to _PySys_UpdateConfig().
    * _PySys_UpdateConfig() now modifies sys.flags in-place, instead of
      creating a new flags object.
    * Remove old commented sys.flags flags (unbuffered and skip_first).
    * Add private _PySys_GetObject() function.
    * When Py_Initialize(), Py_InitializeFromConfig() and

    committed

    Nov 4, 2020
  2. bpo-42260: Reorganize PyConfig (GH-23149)

    * Move orig_argv before argv
    * Move program_name and platlibdir with other path configuration
      inputs
    
    Give a name to the PyPreConfig and PyConfig structures and separate
    the type definitions.

Commits on Nov 3, 2020

  1. bpo-41796: Call _PyAST_Fini() earlier to fix a leak (GH-23131)

    Call _PyAST_Fini() on all interpreters, not only on the main
    interpreter. Also, call it ealier to fix a reference leak.
    
    Python types contain a reference to themselves in in their
    PyTypeObject.tp_mro member. _PyAST_Fini() must called before the last
    GC collection to destroy AST types.
    
    _PyInterpreterState_Clear() now calls _PyAST_Fini(). It now also
    calls _PyWarnings_Fini() on subinterpeters, not only on the main
    interpreter.
    
    Add an assertion in AST init_types() to ensure that the _ast module
    is no longer used after _PyAST_Fini() has been called.

Commits on Nov 2, 2020

  1. bpo-26789: Fix logging.FileHandler._open() at exit (GH-23053)

    The logging.FileHandler class now keeps a reference to the builtin
    open() function to be able to open or reopen the file during Python
    finalization.
    
    Fix errors like:
    
        Exception ignored in: (...)
        Traceback (most recent call last):
          (...)
          File ".../logging/__init__.py", line 1463, in error
          File ".../logging/__init__.py", line 1577, in _log
          File ".../logging/__init__.py", line 1587, in handle
          File ".../logging/__init__.py", line 1649, in callHandlers
          File ".../logging/__init__.py", line 948, in handle
          File ".../logging/__init__.py", line 1182, in emit
          File ".../logging/__init__.py", line 1171, in _open
        NameError: name 'open' is not defined
  2. bpo-41796: Make _ast module state per interpreter (GH-23024)

    The ast module internal state is now per interpreter.
    
    * Rename "astmodulestate" to "struct ast_state"
    * Add pycore_ast.h internal header: the ast_state structure is now
      declared in pycore_ast.h.
    * Add PyInterpreterState.ast (struct ast_state)
    * Remove get_ast_state()
    * Rename get_global_ast_state() to get_ast_state()
    * PyAST_obj2mod() now handles get_ast_state() failures
  3. bpo-42103: Improve validation of Plist files. (GH-22882)

    * Prevent some possible DoS attacks via providing invalid Plist files
      with extremely large number of objects or collection sizes.
    * Raise InvalidFileException for too large bytes and string size instead of returning garbage.
    * Raise InvalidFileException instead of ValueError for specific invalid datetime (NaN).
    * Raise InvalidFileException instead of TypeError for non-hashable dict keys.
    * Add more tests for invalid Plist files.
  4. bpo-42236: Enhance init and encoding documentation (GH-23109)

    Enhance the documentation of the Python startup, filesystem encoding
    and error handling, locale encoding. Add a new "Python UTF-8 Mode"
    section.
    
    * Add "locale encoding" and "filesystem encoding and error handler"
      to the glossary
    * Remove documentation from Include/cpython/initconfig.h: move it to
      Doc/c-api/init_config.rst.
    * Doc/c-api/init_config.rst:
    
      * Document command line options and environment variables
      * Document default values.
    
    * Add a new "Python UTF-8 Mode" section in Doc/library/os.rst.
    * Add warnings to Py_DecodeLocale() and Py_EncodeLocale() docs.
    * Document how Python selects the filesystem encoding and error
      handler at a single place: PyConfig.filesystem_encoding and
      PyConfig.filesystem_errors.
    * PyConfig: move orig_argv member at the right place.
  5. bpo-41435: Add sys._current_exceptions() function (GH-21689)

    This adds a new function named sys._current_exceptions() which is equivalent ot
    sys._current_frames() except that it returns the exceptions currently handled
    by other threads. It is equivalent to calling sys.exc_info() for each running
    thread.

Commits on Nov 1, 2020

  1. bpo-37193: remove thread objects which finished process its request (G…

    …H-13893)
    
    * bpo-37193: remove the thread which finished process request from threads list
    
    * rename variable t to thread.
    
    * don't remove thread from list if it is daemon.
    
    * use lock to protect self._threads.
    
    * use finally block in case of exception from shutdown_request().
    
    * check "not thread.daemon" before lock to avoid holding the lock if it's unnecessary.
    
    * fix the place of _threads_lock.
    
    * separate code to remove a current thread into a function.
    
    * check ValueError when removing thread.
    
    * fix wrong code which all instance shared same lock.
    
    * Extract thread management into a _Threads class to encapsulate atomic operations and separate concerns.
    
    * Replace multiple references of 'block_on_close' with one, avoiding the possibility that 'block_on_close' could change during the course of processing requests. Now, there's exactly one _threads object with behavior fixed for the duration.
    
    * Add docstrings to private classes.
    
    * Add test to ensure that a ThreadingTCPServer can be closed without serving any requests.
    
    * Use _NoThreads as the default value. Fixes AttributeError when server is closed without serving any requests.
    
    * Add blurb
    
    * Add test capturing failure.
    
    Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
  2. bpo-42236: Use UTF-8 encoding if nl_langinfo(CODESET) fails (GH-23086)

    If the nl_langinfo(CODESET) function returns an empty string, Python
    now uses UTF-8 as the filesystem encoding.
    
    In May 2010 (commit b744ba1), I
    modified Python to log a warning and use UTF-8 as the filesystem
    encoding (instead of None) if nl_langinfo(CODESET) returns an empty
    string.
    
    In August 2020 (commit 94908bb), I
    modified Python startup to fail with a fatal error and a specific
    error message if nl_langinfo(CODESET) returns an empty string. The
    intent was to prevent guessing the encoding and also investigate user
    configuration where this case happens.
    
    In 10 years (2010 to 2020), I saw zero user report about the error
    message related to nl_langinfo(CODESET) returning an empty string.
    
    Today, UTF-8 became the defacto standard and it's safe to make the
    assumption that the user expects UTF-8. For example,
    nl_langinfo(CODESET) can return an empty string on macOS if the
    LC_CTYPE locale is not supported, and UTF-8 is the default encoding
    on macOS.
    
    While this change is likely to not affect anyone in practice, it
    should make UTF-8 lover happy ;-)
    
    Rewrite also the documentation explaining how Python selects the
    filesystem encoding and error handler.
  3. bpo-42236: Enhance _locale._get_locale_encoding() (GH-23083)

    * Rename _Py_GetLocaleEncoding() to _Py_GetLocaleEncodingObject()
    * Add _Py_GetLocaleEncoding() which returns a wchar_t* string to
      share code between _Py_GetLocaleEncodingObject()
      and config_get_locale_encoding().
    * _Py_GetLocaleEncodingObject() now decodes nl_langinfo(CODESET)
      from the current locale encoding with surrogateescape,
      rather than using UTF-8.