From 9c9a45c1f0a264d3006971b8211d948d6883a05b Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Thu, 8 Sep 2016 10:35:16 -0700 Subject: Issue #27781: Change file system encoding on Windows to UTF-8 (PEP 529) --- Doc/library/sys.rst | 51 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 11 deletions(-) (limited to 'Doc/library/sys.rst') diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 8c9ca2aad4..9460b84642 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -428,25 +428,42 @@ always available. .. function:: getfilesystemencoding() - Return the name of the encoding used to convert Unicode filenames into - system file names. The result value depends on the operating system: + Return the name of the encoding used to convert between Unicode + filenames and bytes filenames. For best compatibility, str should be + used for filenames in all cases, although representing filenames as bytes + is also supported. Functions accepting or returning filenames should support + either str or bytes and internally convert to the system's preferred + representation. - * On Mac OS X, the encoding is ``'utf-8'``. + This encoding is always ASCII-compatible. + + :func:`os.fsencode` and :func:`os.fsdecode` should be used to ensure that + the correct encoding and errors mode are used. - * On Unix, the encoding is the user's preference according to the result of - nl_langinfo(CODESET). + * On Mac OS X, the encoding is ``'utf-8'``. - * On Windows NT+, file names are Unicode natively, so no conversion is - performed. :func:`getfilesystemencoding` still returns ``'mbcs'``, as - this is the encoding that applications should use when they explicitly - want to convert Unicode strings to byte strings that are equivalent when - used as file names. + * On Unix, the encoding is the locale encoding. - * On Windows 9x, the encoding is ``'mbcs'``. + * On Windows, the encoding may be ``'utf-8'`` or ``'mbcs'``, depending + on user configuration. .. versionchanged:: 3.2 :func:`getfilesystemencoding` result cannot be ``None`` anymore. + .. versionchanged:: 3.6 + Windows is no longer guaranteed to return ``'mbcs'``. See :pep:`529` + and :func:`_enablelegacywindowsfsencoding` for more information. + +.. function:: getfilesystemencodeerrors() + + Return the name of the error mode used to convert between Unicode filenames + and bytes filenames. The encoding name is returned from + :func:`getfilesystemencoding`. + + :func:`os.fsencode` and :func:`os.fsdecode` should be used to ensure that + the correct encoding and errors mode are used. + + .. versionadded:: 3.6 .. function:: getrefcount(object) @@ -1138,6 +1155,18 @@ always available. This function has been added on a provisional basis (see :pep:`411` for details.) Use it only for debugging purposes. +.. function:: _enablelegacywindowsfsencoding() + + Changes the default filesystem encoding and errors mode to 'mbcs' and + 'replace' respectively, for consistency with versions of Python prior to 3.6. + + This is equivalent to defining the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` + environment variable before launching Python. + + Availability: Windows + + .. versionadded:: 3.6 + See :pep:`529` for more details. .. data:: stdin stdout -- cgit v1.2.1 From 831deb2ea3f31f273438acc797ae12d183a21422 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Fri, 9 Sep 2016 14:57:58 -0700 Subject: remove ceval timestamp support --- Doc/library/sys.rst | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'Doc/library/sys.rst') diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 9460b84642..6ee6c490df 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -1104,18 +1104,6 @@ always available. thus may not be available in all Python implementations. -.. function:: settscdump(on_flag) - - Activate dumping of VM measurements using the Pentium timestamp counter, if - *on_flag* is true. Deactivate these dumps if *on_flag* is off. The function is - available only if Python was compiled with ``--with-tsc``. To understand - the output of this dump, read :file:`Python/ceval.c` in the Python sources. - - .. impl-detail:: - This function is intimately bound to CPython implementation details and - thus not likely to be implemented elsewhere. - - .. function:: set_coroutine_wrapper(wrapper) Allows intercepting creation of :term:`coroutine` objects (only ones that -- cgit v1.2.1 From acffd14de543f9752af1ee29c36739c14b05767c Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Sat, 17 Sep 2016 17:27:48 -0700 Subject: Issue #27932: Prevent memory leak in win32_ver(). --- Doc/library/sys.rst | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'Doc/library/sys.rst') diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 6ee6c490df..55b744e19d 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -552,26 +552,15 @@ always available. Return a named tuple describing the Windows version currently running. The named elements are *major*, *minor*, *build*, *platform*, *service_pack*, *service_pack_minor*, - *service_pack_major*, *suite_mask*, and *product_type*. - *service_pack* contains a string while all other values are + *service_pack_major*, *suite_mask*, *product_type* and + *platform_version*. *service_pack* contains a string, + *platform_version* a 3-tuple and all other values are integers. The components can also be accessed by name, so ``sys.getwindowsversion()[0]`` is equivalent to ``sys.getwindowsversion().major``. For compatibility with prior versions, only the first 5 elements are retrievable by indexing. - *platform* may be one of the following values: - - +-----------------------------------------+-------------------------+ - | Constant | Platform | - +=========================================+=========================+ - | :const:`0 (VER_PLATFORM_WIN32s)` | Win32s on Windows 3.1 | - +-----------------------------------------+-------------------------+ - | :const:`1 (VER_PLATFORM_WIN32_WINDOWS)` | Windows 95/98/ME | - +-----------------------------------------+-------------------------+ - | :const:`2 (VER_PLATFORM_WIN32_NT)` | Windows NT/2000/XP/x64 | - +-----------------------------------------+-------------------------+ - | :const:`3 (VER_PLATFORM_WIN32_CE)` | Windows CE | - +-----------------------------------------+-------------------------+ + *platform* will be :const:`2 (VER_PLATFORM_WIN32_NT)`. *product_type* may be one of the following values: @@ -587,17 +576,23 @@ always available. | | a domain controller. | +---------------------------------------+---------------------------------+ - This function wraps the Win32 :c:func:`GetVersionEx` function; see the Microsoft documentation on :c:func:`OSVERSIONINFOEX` for more information about these fields. + *platform_version* returns the accurate major version, minor version and + build number of the current operating system, rather than the version that + is being emulated for the process. It is intended for use in logging rather + than for feature detection. + Availability: Windows. .. versionchanged:: 3.2 Changed to a named tuple and added *service_pack_minor*, *service_pack_major*, *suite_mask*, and *product_type*. + .. versionchanged:: 3.6 + Added *platform_version* .. function:: get_coroutine_wrapper() -- cgit v1.2.1 From 69c7c787341074d465e03a8c0e55ffe9cc1ce8c2 Mon Sep 17 00:00:00 2001 From: Yury Selivanov Date: Thu, 15 Dec 2016 17:36:05 -0500 Subject: Issue #28091: Document PEP 525 & PEP 530. Patch by Eric Appelt. (grafted from 78c8f450b84ca1864123ec487d363eb151f61a4a) --- Doc/library/sys.rst | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'Doc/library/sys.rst') diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 2d14a1dd18..dd51ffd56c 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -594,6 +594,24 @@ always available. .. versionchanged:: 3.6 Added *platform_version* + +.. function:: get_asyncgen_hooks() + + Returns an *asyncgen_hooks* object, which is similar to a + :class:`~collections.namedtuple` of the form `(firstiter, finalizer)`, + where *firstiter* and *finalizer* are expected to be either ``None`` or + functions which take an :term:`asynchronous generator iterator` as an + argument, and are used to schedule finalization of an asychronous + generator by an event loop. + + .. versionadded:: 3.6 + See :pep:`525` for more details. + + .. note:: + This function has been added on a provisional basis (see :pep:`411` + for details.) + + .. function:: get_coroutine_wrapper() Returns ``None``, or a wrapper set by :func:`set_coroutine_wrapper`. @@ -1098,6 +1116,24 @@ always available. implementation platform, rather than part of the language definition, and thus may not be available in all Python implementations. +.. function:: set_asyncgen_hooks(firstiter, finalizer) + + Accepts two optional keyword arguments which are callables that accept an + :term:`asynchronous generator iterator` as an argument. The *firstiter* + callable will be called when an asynchronous generator is iterated for the + first time. The *finalizer* will be called when an asynchronous generator + is about to be garbage collected. + + .. versionadded:: 3.6 + See :pep:`525` for more details, and for a reference example of a + *finalizer* method see the implementation of + ``asyncio.Loop.shutdown_asyncgens`` in + :source:`Lib/asyncio/base_events.py` + + .. note:: + This function has been added on a provisional basis (see :pep:`411` + for details.) + .. function:: set_coroutine_wrapper(wrapper) -- cgit v1.2.1