mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-14 21:56:56 +03:00
Merge pull request #8545 from radarhere/realpath
This commit is contained in:
commit
b7bbcfbffb
|
@ -2550,7 +2550,7 @@ class Image:
|
||||||
filename: str | bytes = ""
|
filename: str | bytes = ""
|
||||||
open_fp = False
|
open_fp = False
|
||||||
if is_path(fp):
|
if is_path(fp):
|
||||||
filename = os.path.realpath(os.fspath(fp))
|
filename = os.fspath(fp)
|
||||||
open_fp = True
|
open_fp = True
|
||||||
elif fp == sys.stdout:
|
elif fp == sys.stdout:
|
||||||
try:
|
try:
|
||||||
|
@ -2559,7 +2559,7 @@ class Image:
|
||||||
pass
|
pass
|
||||||
if not filename and hasattr(fp, "name") and is_path(fp.name):
|
if not filename and hasattr(fp, "name") and is_path(fp.name):
|
||||||
# only set the name for metadata purposes
|
# only set the name for metadata purposes
|
||||||
filename = os.path.realpath(os.fspath(fp.name))
|
filename = os.fspath(fp.name)
|
||||||
|
|
||||||
# may mutate self!
|
# may mutate self!
|
||||||
self._ensure_mutable()
|
self._ensure_mutable()
|
||||||
|
@ -3463,7 +3463,7 @@ def open(
|
||||||
exclusive_fp = False
|
exclusive_fp = False
|
||||||
filename: str | bytes = ""
|
filename: str | bytes = ""
|
||||||
if is_path(fp):
|
if is_path(fp):
|
||||||
filename = os.path.realpath(os.fspath(fp))
|
filename = os.fspath(fp)
|
||||||
|
|
||||||
if filename:
|
if filename:
|
||||||
fp = builtins.open(filename, "rb")
|
fp = builtins.open(filename, "rb")
|
||||||
|
|
|
@ -130,7 +130,7 @@ class ImageFile(Image.Image):
|
||||||
if is_path(fp):
|
if is_path(fp):
|
||||||
# filename
|
# filename
|
||||||
self.fp = open(fp, "rb")
|
self.fp = open(fp, "rb")
|
||||||
self.filename = os.path.realpath(os.fspath(fp))
|
self.filename = os.fspath(fp)
|
||||||
self._exclusive_fp = True
|
self._exclusive_fp = True
|
||||||
else:
|
else:
|
||||||
# stream
|
# stream
|
||||||
|
|
|
@ -270,7 +270,7 @@ class FreeTypeFont:
|
||||||
)
|
)
|
||||||
|
|
||||||
if is_path(font):
|
if is_path(font):
|
||||||
font = os.path.realpath(os.fspath(font))
|
font = os.fspath(font)
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
font_bytes_path = font if isinstance(font, bytes) else font.encode()
|
font_bytes_path = font if isinstance(font, bytes) else font.encode()
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user