Skip to content

Commit

Permalink
use _util.DeferredError.new everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
nulano committed Dec 27, 2023
1 parent 1856eed commit 79e8e8b
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_deferred_error():
# Arrange

# Act
thing = _util.DeferredError(ValueError("Some error text"))
thing = _util.DeferredError.new(ValueError("Some error text"))

# Assert
with pytest.raises(ValueError):
Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ exclude = [
'^src/PIL/DdsImagePlugin.py$',
'^src/PIL/FpxImagePlugin.py$',
'^src/PIL/Image.py$',
'^src/PIL/ImageCms.py$',
'^src/PIL/ImageFile.py$',
'^src/PIL/ImageFont.py$',
'^src/PIL/ImageMath.py$',
'^src/PIL/ImageMorph.py$',
'^src/PIL/ImageQt.py$',
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class DecompressionBombError(Exception):
raise ImportError(msg)

except ImportError as v:
core = DeferredError(ImportError("The _imaging C module is not installed."))
core = DeferredError.new(ImportError("The _imaging C module is not installed."))
# Explanations for ways that we know we might have an import error
if str(v).startswith("Module use of python"):
# The _imaging C module is present, but not compiled for
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/ImageCms.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# anything in core.
from ._util import DeferredError

_imagingcms = DeferredError(ex)
_imagingcms = DeferredError.new(ex)

DESCRIPTION = """
pyCMS
Expand Down
6 changes: 3 additions & 3 deletions src/PIL/ImageFont.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from enum import IntEnum
from io import BytesIO
from pathlib import Path
from typing import IO
from typing import BinaryIO

from . import Image
from ._util import is_directory, is_path
Expand All @@ -53,7 +53,7 @@ class Layout(IntEnum):
except ImportError as ex:
from ._util import DeferredError

core = DeferredError(ex)
core = DeferredError.new(ex)


def _string_length_check(text):
Expand Down Expand Up @@ -191,7 +191,7 @@ class FreeTypeFont:

def __init__(
self,
font: bytes | str | Path | IO | None = None,
font: bytes | str | Path | BinaryIO | None = None,
size: float = 10,
index: int = 0,
encoding: str = "",
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/PyAccess.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
# anything in core.
from ._util import DeferredError

FFI = ffi = DeferredError(ex)
FFI = ffi = DeferredError.new(ex)

logger = logging.getLogger(__name__)

Expand Down
5 changes: 5 additions & 0 deletions src/PIL/_imagingcms.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import annotations

from typing import Any

def __getattr__(name: str) -> Any: ...
5 changes: 5 additions & 0 deletions src/PIL/_imagingft.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import annotations

from typing import Any

def __getattr__(name: str) -> Any: ...

0 comments on commit 79e8e8b

Please sign in to comment.