Skip to content

gh-135273: Unify ZoneInfo.from_file signatures #135274

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions Doc/library/zoneinfo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Lib/zoneinfo/_zoneinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ def _new_instance(cls, key):
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
Expand Down
Loading