Skip to content

gh-76637: Deprecate the "undefined" codec #113834

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,12 @@ Deprecated
* Deprecate undocumented :func:`!pydoc.ispackage` function.
(Contributed by Zackery Spytz in :gh:`64020`.)

* Deprecate the ``undefined`` codec. This codec always raises a
:exc:`ValueError` exception when being used. It was intended for use by the
:mod:`site` module to switch off automatic string to Unicode coercion, but
it's no longer used by the :mod:`site` module.
(Contributed by Victor Stinner in :gh:`76637`.)


Pending Removal in Python 3.14
------------------------------
Expand Down Expand Up @@ -721,6 +727,12 @@ Pending Removal in Python 3.15
All arguments will be removed from :func:`threading.RLock` in Python 3.15.
(Contributed by Nikita Sobolev in :gh:`102029`.)

* The codec ``undefined`` is deprecated. This codec always raises a
:exc:`ValueError` exception when being used. It was intended for use by the
:mod:`site` module to switch off automatic string to Unicode coercion, but
it's no longer used by the :mod:`site` module.
(Contributed by Victor Stinner in :gh:`76637`.)

Pending Removal in Python 3.16
------------------------------

Expand Down
5 changes: 5 additions & 0 deletions Lib/encodings/undefined.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@

"""
import codecs
import warnings


warnings._deprecated('codec "undefined"', remove=(3, 15))


### Codec APIs

Expand Down
8 changes: 7 additions & 1 deletion Lib/test/test_codecs.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import codecs
import contextlib
import copy
import encodings
import io
import locale
import pickle
import sys
import unittest
import encodings
import warnings
from unittest import mock

from test import support
Expand Down Expand Up @@ -1744,6 +1745,11 @@ def test_open(self):
self.assertIsInstance(file, codecs.StreamReaderWriter)

def test_undefined(self):
# ignore the DeprecationWarning
with warnings.catch_warnings():
warnings.simplefilter('ignore', category=DeprecationWarning)
codecs.lookup('undefined')

self.assertRaises(UnicodeError, codecs.encode, 'abc', 'undefined')
self.assertRaises(UnicodeError, codecs.decode, b'abc', 'undefined')
self.assertRaises(UnicodeError, codecs.encode, '', 'undefined')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deprecate the ``undefined`` codec. Patch by Victor Stinner.
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy