]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-135273: Unify `ZoneInfo.from_file` signatures (GH-135274) (#135716)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 19 Jun 2025 15:14:14 +0000 (17:14 +0200)
committerGitHub <noreply@github.com>
Thu, 19 Jun 2025 15:14:14 +0000 (15:14 +0000)
gh-135273: Unify `ZoneInfo.from_file` signatures (GH-135274)

Align `ZoneInfo.from_file` pure-Python signature with Argument Clinic signature.
(cherry picked from commit 7cc89496922b7edb033e2ed47550c7c9e2ae8525)

Co-authored-by: Andrii Hrimov <andrew.hrimov@gmail.com>
Doc/library/zoneinfo.rst
Lib/zoneinfo/_zoneinfo.py

index a57f3b8b3e858c9efb53270229bb68c41ea1454b..53d8e2598ec1c783804381acbbd56c67e3ab0498 100644 (file)
@@ -195,7 +195,7 @@ The ``ZoneInfo`` class
 
 The ``ZoneInfo`` class has two alternate constructors:
 
-.. classmethod:: ZoneInfo.from_file(fobj, /, key=None)
+.. classmethod:: ZoneInfo.from_file(file_obj, /, key=None)
 
     Constructs a ``ZoneInfo`` object from a file-like object returning bytes
     (e.g. a file opened in binary mode or an :class:`io.BytesIO` object).
@@ -325,7 +325,7 @@ The behavior of a ``ZoneInfo`` file depends on how it was constructed:
        >>> a is b
        False
 
-3. ``ZoneInfo.from_file(fobj, /, key=None)``: When constructed from a file, the
+3. ``ZoneInfo.from_file(file_obj, /, key=None)``: When constructed from a file, the
    ``ZoneInfo`` object raises an exception on pickling. If an end user wants to
    pickle a ``ZoneInfo`` constructed from a file, it is recommended that they
    use a wrapper type or a custom serialization function: either serializing by
index b77dc0ed391bb36adc50f20b489b30caa7dcc9ed..3ffdb4c837192b86fc5e61e0846cd041b5cb8a96 100644 (file)
@@ -75,12 +75,12 @@ class ZoneInfo(tzinfo):
         return obj
 
     @classmethod
-    def from_file(cls, fobj, /, key=None):
+    def from_file(cls, file_obj, /, key=None):
         obj = super().__new__(cls)
         obj._key = key
         obj._file_path = None
-        obj._load_file(fobj)
-        obj._file_repr = repr(fobj)
+        obj._load_file(file_obj)
+        obj._file_repr = repr(file_obj)
 
         # Disable pickling for objects created from files
         obj.__reduce__ = obj._file_reduce