Skip to content

Commit

Permalink
Merge pull request #112 from radarhere/type-hints-replace-io.BytesIO
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk authored Feb 10, 2024
2 parents 159fc06 + 152a24e commit 958a651
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 2 additions & 4 deletions src/PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -2385,7 +2385,7 @@ def save(self, fp, format=None, **params) -> None:
filename = ""
open_fp = False
if is_path(fp):
filename = os.fspath(fp)
filename = os.path.realpath(os.fspath(fp))
open_fp = True
elif fp == sys.stdout:
try:
Expand Down Expand Up @@ -3240,10 +3240,8 @@ def open(fp, mode="r", formats=None) -> Image:

exclusive_fp = False
filename = ""
if isinstance(fp, os.PathLike):
if is_path(fp):
filename = os.path.realpath(os.fspath(fp))
elif is_path(fp):
filename = fp

if filename:
fp = builtins.open(filename, "rb")
Expand Down
6 changes: 3 additions & 3 deletions src/PIL/ImageFont.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
import warnings
from enum import IntEnum
from io import BytesIO
from pathlib import Path
from typing import BinaryIO

from . import Image
from ._typing import StrOrBytesPath
from ._util import is_directory, is_path


Expand Down Expand Up @@ -193,7 +193,7 @@ class FreeTypeFont:

def __init__(
self,
font: bytes | str | Path | BinaryIO | None = None,
font: StrOrBytesPath | BinaryIO | None = None,
size: float = 10,
index: int = 0,
encoding: str = "",
Expand Down Expand Up @@ -230,7 +230,7 @@ def load_from_bytes(f):
)

if is_path(font):
font = os.fspath(font)
font = os.path.realpath(os.fspath(font))
if sys.platform == "win32":
font_bytes_path = font if isinstance(font, bytes) else font.encode()
try:
Expand Down

0 comments on commit 958a651

Please sign in to comment.