diff --git a/README.rst b/README.rst index f07812a568..9503d1a0db 100644 --- a/README.rst +++ b/README.rst @@ -165,6 +165,7 @@ If you have any questions, please feel free to ask in the `Pygame Community Disc License ------- +**License Identifier:** LGPL-2.1-or-later This library is distributed under `GNU LGPL version 2.1`_, which can be found in the file ``docs/LGPL.txt``. We reserve the right to place diff --git a/buildconfig/stubs/pygame/_common.pyi b/buildconfig/stubs/pygame/_common.pyi index 690b17139a..7ddc96ac72 100644 --- a/buildconfig/stubs/pygame/_common.pyi +++ b/buildconfig/stubs/pygame/_common.pyi @@ -1,8 +1,5 @@ from os import PathLike -from typing import IO, Callable, Tuple, Union, TypeVar, Dict, Any, Optional - -from typing_extensions import Literal as Literal, SupportsIndex as SupportsIndex -from typing_extensions import Protocol +from typing import IO, Callable, Tuple, Union, TypeVar, Dict, Any, Optional, Protocol, SupportsIndex # For functions that take a file name AnyPath = Union[str, bytes, PathLike[str], PathLike[bytes]] diff --git a/buildconfig/stubs/pygame/color.pyi b/buildconfig/stubs/pygame/color.pyi index d53344de1d..d9c2ef2ea7 100644 --- a/buildconfig/stubs/pygame/color.pyi +++ b/buildconfig/stubs/pygame/color.pyi @@ -1,7 +1,8 @@ import sys -from typing import Any, Dict, Iterator, Tuple, Union, overload +from typing import Any, Dict, Iterator, SupportsIndex, Tuple, Union, overload +from typing_extensions import deprecated # added in 3.13 -from ._common import ColorValue, SupportsIndex +from ._common import ColorValue if sys.version_info >= (3, 9): from collections.abc import Collection @@ -79,6 +80,7 @@ class Color(Collection[int]): def from_normalized(cls, r: float, g: float, b: float, a: float, /) -> Color: ... def normalize(self) -> Tuple[float, float, float, float]: ... def correct_gamma(self, gamma: float, /) -> Color: ... + @deprecated("since 2.1.3. Use unpacking instead") def set_length(self, length: int, /) -> None: ... def lerp(self, color: ColorValue, amount: float) -> Color: ... def premul_alpha(self) -> Color: ... diff --git a/buildconfig/stubs/pygame/cursors.pyi b/buildconfig/stubs/pygame/cursors.pyi index d6b610946e..8ab51b003d 100644 --- a/buildconfig/stubs/pygame/cursors.pyi +++ b/buildconfig/stubs/pygame/cursors.pyi @@ -1,8 +1,8 @@ -from typing import Any, Iterator, Tuple, Union, overload +from typing import Any, Iterator, Literal, Tuple, Union, overload from pygame.surface import Surface -from ._common import FileArg, Literal, IntCoordinate, Sequence +from ._common import FileArg, IntCoordinate, Sequence _Small_string = Tuple[ str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str diff --git a/buildconfig/stubs/pygame/display.pyi b/buildconfig/stubs/pygame/display.pyi index 399f462ffa..06842fa78e 100644 --- a/buildconfig/stubs/pygame/display.pyi +++ b/buildconfig/stubs/pygame/display.pyi @@ -1,4 +1,5 @@ from typing import Dict, List, Optional, Tuple, Union, overload, Literal +from typing_extensions import deprecated # added in 3.13 from pygame.constants import FULLSCREEN from pygame.surface import Surface @@ -72,7 +73,9 @@ def gl_set_attribute(flag: int, value: int, /) -> None: ... def get_active() -> bool: ... def iconify() -> bool: ... def toggle_fullscreen() -> int: ... +@deprecated("since 2.1.4. Removed in SDL3") def set_gamma(red: float, green: float = ..., blue: float = ..., /) -> int: ... +@deprecated("since 2.1.4. Removed in SDL3") def set_gamma_ramp( red: Sequence[int], green: Sequence[int], blue: Sequence[int], / ) -> int: ... diff --git a/buildconfig/stubs/pygame/font.pyi b/buildconfig/stubs/pygame/font.pyi index 683a28ef2b..0312136de1 100644 --- a/buildconfig/stubs/pygame/font.pyi +++ b/buildconfig/stubs/pygame/font.pyi @@ -1,8 +1,8 @@ -from typing import Callable, Hashable, Iterable, List, Optional, Tuple, Union +from typing import Callable, Hashable, Iterable, List, Literal, Optional, Tuple, Union from pygame.surface import Surface -from ._common import ColorValue, FileArg, Literal +from ._common import ColorValue, FileArg # TODO: Figure out a way to type this attribute such that mypy knows it's not # always defined at runtime diff --git a/buildconfig/stubs/pygame/freetype.pyi b/buildconfig/stubs/pygame/freetype.pyi index 54751f8385..5f690d3150 100644 --- a/buildconfig/stubs/pygame/freetype.pyi +++ b/buildconfig/stubs/pygame/freetype.pyi @@ -1,4 +1,5 @@ from typing import Any, Callable, Iterable, List, Optional, Tuple, Union +from typing_extensions import deprecated # added in 3.13 from pygame.color import Color from pygame.rect import Rect @@ -11,6 +12,7 @@ def get_version(linked: bool = True) -> Tuple[int, int, int]: ... def init(cache_size: int = 64, resolution: int = 72) -> None: ... def quit() -> None: ... def get_init() -> bool: ... +@deprecated("Use `pygame.freetype.get_init` instead") def was_init() -> bool: ... def get_cache_size() -> int: ... def get_default_resolution() -> int: ... diff --git a/buildconfig/stubs/pygame/image.pyi b/buildconfig/stubs/pygame/image.pyi index 5a6bf0ad9a..7145b2ccd8 100644 --- a/buildconfig/stubs/pygame/image.pyi +++ b/buildconfig/stubs/pygame/image.pyi @@ -1,47 +1,48 @@ -from typing import Optional, Tuple, Union +from typing import Literal, Optional, Tuple, Union +from typing_extensions import deprecated # added in 3.13 from pygame.bufferproxy import BufferProxy from pygame.surface import Surface -from ._common import FileArg, Literal, IntCoordinate, Coordinate +from ._common import FileArg, IntCoordinate, Coordinate _BufferStyle = Union[BufferProxy, bytes, bytearray, memoryview] -_to_string_format = Literal[ +_to_bytes_format = Literal[ "P", "RGB", "RGBX", "RGBA", "ARGB", "BGRA", "ABGR", "RGBA_PREMULT", "ARGB_PREMULT" ] _from_buffer_format = Literal["P", "RGB", "BGR", "BGRA", "RGBX", "RGBA", "ARGB"] -_from_string_format = Literal["P", "RGB", "RGBX", "RGBA", "ARGB", "BGRA", "ABGR"] +_from_bytes_format = Literal["P", "RGB", "RGBX", "RGBA", "ARGB", "BGRA", "ABGR"] def load(file: FileArg, namehint: str = "") -> Surface: ... def load_sized_svg(file: FileArg, size: Coordinate) -> Surface: ... def save(surface: Surface, file: FileArg, namehint: str = "") -> None: ... def get_sdl_image_version(linked: bool = True) -> Optional[Tuple[int, int, int]]: ... def get_extended() -> bool: ... +@deprecated("since 2.3.0. Use `pygame.image.tobytes` instead") def tostring( surface: Surface, - format: _to_string_format, + format: _to_bytes_format, flipped: bool = False, pitch: int = -1, ) -> bytes: ... +@deprecated("since 2.3.0. Use `pygame.image.frombytes` instead") def fromstring( bytes: bytes, size: IntCoordinate, - format: _from_string_format, + format: _from_bytes_format, flipped: bool = False, pitch: int = -1, ) -> Surface: ... - -# the use of tobytes/frombytes is preferred over tostring/fromstring def tobytes( surface: Surface, - format: _to_string_format, + format: _to_bytes_format, flipped: bool = False, pitch: int = -1, ) -> bytes: ... def frombytes( bytes: bytes, size: IntCoordinate, - format: _from_string_format, + format: _from_bytes_format, flipped: bool = False, pitch: int = -1, ) -> Surface: ... diff --git a/buildconfig/stubs/pygame/joystick.pyi b/buildconfig/stubs/pygame/joystick.pyi index c24a7ea88e..2936e5a2b3 100644 --- a/buildconfig/stubs/pygame/joystick.pyi +++ b/buildconfig/stubs/pygame/joystick.pyi @@ -1,4 +1,5 @@ from typing import Tuple, final +from typing_extensions import deprecated # added in 3.13 def init() -> None: ... def quit() -> None: ... @@ -7,9 +8,11 @@ def get_count() -> int: ... @final class JoystickType: def __init__(self, id: int) -> None: ... + @deprecated("since 2.0.0. Multiple initializations are not supported anymore") def init(self) -> None: ... def quit(self) -> None: ... def get_init(self) -> bool: ... + @deprecated("since 2.0.0. Use `pygame.Joystick.get_instance_id` instead") def get_id(self) -> int: ... def get_instance_id(self) -> int: ... def get_guid(self) -> str: ... diff --git a/buildconfig/stubs/pygame/math.pyi b/buildconfig/stubs/pygame/math.pyi index 963f2bd957..f307599c76 100644 --- a/buildconfig/stubs/pygame/math.pyi +++ b/buildconfig/stubs/pygame/math.pyi @@ -5,6 +5,7 @@ from typing import ( Iterator, List, Literal, + SupportsIndex, Tuple, Type, TypeVar, @@ -13,13 +14,14 @@ from typing import ( overload, Optional ) +from typing_extensions import deprecated # added in 3.13 if sys.version_info >= (3, 9): from collections.abc import Collection else: from typing import Collection -from ._common import SupportsIndex, Sequence +from ._common import Sequence def clamp(value: float, min: float, max: float, /) -> float: ... @@ -231,6 +233,7 @@ class Vector2(_GenericVector): def rotate_rad(self: _TVec, angle: float, /) -> _TVec: ... def rotate_ip(self, angle: float, /) -> None: ... def rotate_rad_ip(self, angle: float, /) -> None: ... + @deprecated("since 2.1.1. Use `pygame.Vector2.rotate_rad_ip` instead") def rotate_ip_rad(self, angle: float, /) -> None: ... def cross(self: _TVec, other: Union[Sequence[float], _TVec], /) -> float: ... def as_polar(self) -> Tuple[float, float]: ... @@ -304,6 +307,7 @@ class Vector3(_GenericVector): def rotate_rad_ip( self: _TVec, angle: float, axis: Union[Sequence[float], _TVec], / ) -> None: ... + @deprecated("since 2.1.1. Use `pygame.Vector3.rotate_rad_ip` instead") def rotate_ip_rad( self: _TVec, angle: float, axis: Union[Sequence[float], _TVec], / ) -> None: ... @@ -311,16 +315,19 @@ class Vector3(_GenericVector): def rotate_x_rad(self: _TVec, angle: float, /) -> _TVec: ... def rotate_x_ip(self, angle: float, /) -> None: ... def rotate_x_rad_ip(self, angle: float, /) -> None: ... + @deprecated("since 2.1.1. Use `pygame.Vector3.rotate_x_rad_ip` instead") def rotate_x_ip_rad(self, angle: float, /) -> None: ... def rotate_y(self: _TVec, angle: float, /) -> _TVec: ... def rotate_y_rad(self: _TVec, angle: float, /) -> _TVec: ... def rotate_y_ip(self, angle: float, /) -> None: ... def rotate_y_rad_ip(self, angle: float, /) -> None: ... + @deprecated("since 2.1.1. Use `pygame.Vector3.rotate_y_rad_ip` instead") def rotate_y_ip_rad(self, angle: float, /) -> None: ... def rotate_z(self: _TVec, angle: float, /) -> _TVec: ... def rotate_z_rad(self: _TVec, angle: float, /) -> _TVec: ... def rotate_z_ip(self, angle: float, /) -> None: ... def rotate_z_rad_ip(self, angle: float, /) -> None: ... + @deprecated("since 2.1.1. Use `pygame.Vector3.rotate_z_rad_ip` instead") def rotate_z_ip_rad(self, angle: float, /) -> None: ... def as_spherical(self) -> Tuple[float, float, float]: ... def from_spherical(self, spherical: Tuple[float, float, float], /) -> None: ... @@ -338,7 +345,7 @@ def invlerp(a: float, b: float, value: float, /) -> float: ... def remap(i_min: float, i_max: float, o_min: float, o_max: float, value: float, /) -> float: ... def smoothstep(a: float, b: float, weight: float, /) -> float: ... - -# typehints for deprecated functions, to be removed in a future version +@deprecated("Functionality is removed") def enable_swizzling() -> None: ... +@deprecated("Functionality is removed") def disable_swizzling() -> None: ... diff --git a/buildconfig/stubs/pygame/mouse.pyi b/buildconfig/stubs/pygame/mouse.pyi index bec7b2899c..c3d3a64548 100644 --- a/buildconfig/stubs/pygame/mouse.pyi +++ b/buildconfig/stubs/pygame/mouse.pyi @@ -1,5 +1,6 @@ -from typing import Tuple, overload -from typing_extensions import Literal +from typing import Literal, Tuple, overload +from typing_extensions import deprecated # added in 3.13 + from pygame.cursors import Cursor from pygame.surface import Surface @@ -34,6 +35,7 @@ def set_cursor( @overload def set_cursor(hotspot: IntCoordinate, surface: Surface) -> None: ... def get_cursor() -> Cursor: ... +@deprecated("since 2.2.0. Use `pygame.mouse.set_cursor` instead") def set_system_cursor(cursor: int, /) -> None: ... def get_relative_mode() -> bool: ... def set_relative_mode(enable: bool, /) -> None: ... diff --git a/buildconfig/stubs/pygame/pixelcopy.pyi b/buildconfig/stubs/pygame/pixelcopy.pyi index 9954816074..4c2f59ce7e 100644 --- a/buildconfig/stubs/pygame/pixelcopy.pyi +++ b/buildconfig/stubs/pygame/pixelcopy.pyi @@ -1,9 +1,9 @@ +from typing import Literal + import numpy from pygame.surface import Surface -from ._common import Literal - _kind = Literal["P", "p", "R", "r", "G", "g", "B", "b", "A", "a", "C", "c"] def surface_to_array( diff --git a/buildconfig/stubs/pygame/rect.pyi b/buildconfig/stubs/pygame/rect.pyi index b401f9a930..6cb28ca201 100644 --- a/buildconfig/stubs/pygame/rect.pyi +++ b/buildconfig/stubs/pygame/rect.pyi @@ -2,6 +2,8 @@ import sys from typing import ( Dict, List, + Literal, + SupportsIndex, Tuple, TypeVar, Union, @@ -10,7 +12,7 @@ from typing import ( Optional, ) -from ._common import Coordinate, Literal, RectValue, SupportsIndex, Sequence +from ._common import Coordinate, RectValue, Sequence if sys.version_info >= (3, 11): from typing import Self diff --git a/buildconfig/stubs/pygame/scrap.pyi b/buildconfig/stubs/pygame/scrap.pyi index 5929539a86..edb98e8801 100644 --- a/buildconfig/stubs/pygame/scrap.pyi +++ b/buildconfig/stubs/pygame/scrap.pyi @@ -1,13 +1,22 @@ from typing import List, Optional +from typing_extensions import deprecated # added in 3.13 from collections.abc import ByteString +@deprecated("since 2.2.0. Use the new API instead, which only requires display init") def init() -> None: ... +@deprecated("since 2.2.0. Use the new API instead, which doesn't require scrap init") def get_init() -> bool: ... +@deprecated("since 2.2.0. Use the new API instead: `pygame.scrap.get_text`") def get(data_type: str, /) -> Optional[bytes]: ... +@deprecated("since 2.2.0. Use the new API instead, which only supports strings") def get_types() -> List[str]: ... +@deprecated("since 2.2.0. Use the new API instead: `pygame.scrap.put_text`") def put(data_type: str, data: ByteString, /) -> None: ... +@deprecated("since 2.2.0. Use the new API instead: `pygame.scrap.has_text`") def contains(data_type: str, /) -> bool: ... +@deprecated("since 2.2.0. Use the new API instead, which uses system clipboard") def lost() -> bool: ... +@deprecated("since 2.2.0. Use the new API instead, which only supports strings") def set_mode(mode: int, /) -> None: ... def put_text(text: str, /) -> None: ... def get_text() -> str: ... diff --git a/buildconfig/stubs/pygame/sndarray.pyi b/buildconfig/stubs/pygame/sndarray.pyi index 8b0dd65303..bf03698feb 100644 --- a/buildconfig/stubs/pygame/sndarray.pyi +++ b/buildconfig/stubs/pygame/sndarray.pyi @@ -1,4 +1,5 @@ from typing import Tuple +from typing_extensions import deprecated # added in 3.13 import numpy @@ -7,6 +8,9 @@ from pygame.mixer import Sound def array(sound: Sound) -> numpy.ndarray: ... def samples(sound: Sound) -> numpy.ndarray: ... def make_sound(array: numpy.ndarray) -> Sound: ... +@deprecated("Only numpy is supported") def use_arraytype(arraytype: str) -> Sound: ... +@deprecated("Only numpy is supported") def get_arraytype() -> str: ... +@deprecated("Only numpy is supported") def get_arraytypes() -> Tuple[str]: ... diff --git a/buildconfig/stubs/pygame/sprite.pyi b/buildconfig/stubs/pygame/sprite.pyi index fc9c022ac6..7a96dadc44 100644 --- a/buildconfig/stubs/pygame/sprite.pyi +++ b/buildconfig/stubs/pygame/sprite.pyi @@ -7,14 +7,13 @@ from typing import ( Iterator, List, Optional, + Protocol, SupportsFloat, Tuple, TypeVar, Union, ) - -# Protocol added in python 3.8 -from typing_extensions import Protocol +from typing_extensions import deprecated # added in 3.13 from pygame.rect import FRect, Rect from pygame.surface import Surface @@ -182,12 +181,15 @@ class Group(AbstractGroup[_TSprite]): def __init__( self, *sprites: Union[_TSprite, AbstractGroup[_TSprite], Iterable[_TSprite]] ) -> None: ... - + # these are aliased in the code too -RenderPlain = Group -RenderClear = Group +@deprecated("Use `pygame.sprite.Group` instead") +class RenderPlain(Group): ... +@deprecated("Use `pygame.sprite.Group` instead") +class RenderClear(Group): ... class RenderUpdates(Group[_TSprite]): ... +@deprecated("Use `pygame.sprite.RenderUpdates` instead") class OrderedUpdates(RenderUpdates[_TSprite]): ... class LayeredUpdates(AbstractGroup[_TSprite]): @@ -236,8 +238,10 @@ class LayeredDirty(LayeredUpdates[_TDirtySprite]): def set_timing_threshold( self, time_ms: SupportsFloat ) -> None: ... # This actually accept any value - # deprecated alias - set_timing_treshold = set_timing_threshold + @deprecated("since 2.1.1. Use `pygame.sprite.LayeredDirty.set_timing_threshold` instead") + def set_timing_treshold( + self, time_ms: SupportsFloat + ) -> None: ... class GroupSingle(AbstractGroup[_TSprite]): sprite: _TSprite diff --git a/buildconfig/stubs/pygame/surface.pyi b/buildconfig/stubs/pygame/surface.pyi index 2962f6abb9..7539ea9311 100644 --- a/buildconfig/stubs/pygame/surface.pyi +++ b/buildconfig/stubs/pygame/surface.pyi @@ -1,4 +1,5 @@ -from typing import Any, Iterable, List, Optional, Tuple, Union, overload +from typing import Any, Iterable, List, Literal, Optional, Tuple, Union, overload +from typing_extensions import deprecated # added in 3.13 from pygame.bufferproxy import BufferProxy from pygame.color import Color @@ -7,7 +8,6 @@ from pygame.rect import FRect, Rect from ._common import ( ColorValue, Coordinate, - Literal, RectValue, RGBAOutput, Sequence, @@ -153,8 +153,10 @@ class Surface: def get_flags(self) -> int: ... def get_pitch(self) -> int: ... def get_masks(self) -> RGBAOutput: ... + @deprecated("since 2.0.0. Immutable in SDL2") def set_masks(self, color: ColorValue, /) -> None: ... def get_shifts(self) -> RGBAOutput: ... + @deprecated("since 2.0.0. Immutable in SDL2") def set_shifts(self, color: ColorValue, /) -> None: ... def get_losses(self) -> RGBAOutput: ... def get_bounding_rect(self, min_alpha: int = 1) -> Rect: ... diff --git a/buildconfig/stubs/pygame/surfarray.pyi b/buildconfig/stubs/pygame/surfarray.pyi index bf15758713..c15f089518 100644 --- a/buildconfig/stubs/pygame/surfarray.pyi +++ b/buildconfig/stubs/pygame/surfarray.pyi @@ -1,4 +1,5 @@ from typing import Tuple +from typing_extensions import deprecated # added in 3.13 import numpy @@ -26,6 +27,9 @@ def array_colorkey(surface: Surface) -> numpy.ndarray: ... def make_surface(array: numpy.ndarray) -> Surface: ... def blit_array(surface: Surface, array: numpy.ndarray) -> None: ... def map_array(surface: Surface, array: numpy.ndarray) -> numpy.ndarray: ... +@deprecated("Only numpy is supported") def use_arraytype(arraytype: str) -> None: ... +@deprecated("Only numpy is supported") def get_arraytype() -> str: ... +@deprecated("Only numpy is supported") def get_arraytypes() -> Tuple[str]: ... diff --git a/buildconfig/stubs/pygame/system.pyi b/buildconfig/stubs/pygame/system.pyi index f9f50452ca..f2e367473f 100644 --- a/buildconfig/stubs/pygame/system.pyi +++ b/buildconfig/stubs/pygame/system.pyi @@ -1,6 +1,4 @@ -from typing import List, Optional, final - -from typing_extensions import TypedDict +from typing import List, Optional, TypedDict from pygame._data_classes import PowerState diff --git a/buildconfig/stubs/pygame/version.pyi b/buildconfig/stubs/pygame/version.pyi index 69a3b6fe71..3838d68274 100644 --- a/buildconfig/stubs/pygame/version.pyi +++ b/buildconfig/stubs/pygame/version.pyi @@ -1,6 +1,4 @@ -from typing import Tuple - -from ._common import Literal +from typing import Literal, Tuple class SoftwareVersion(Tuple[int, int, int]): def __new__(cls, major: int, minor: int, patch: int) -> SoftwareVersion: ... diff --git a/buildconfig/stubs/pygame/window.pyi b/buildconfig/stubs/pygame/window.pyi index 02d9fed015..1b18fa06cd 100644 --- a/buildconfig/stubs/pygame/window.pyi +++ b/buildconfig/stubs/pygame/window.pyi @@ -1,4 +1,5 @@ -from typing import Optional, Tuple, Union, final +from typing import Optional, Tuple, Union +from typing_extensions import deprecated # added in 3.13 from pygame._common import Coordinate, RectValue from pygame.locals import WINDOWPOS_UNDEFINED @@ -67,4 +68,5 @@ class Window: @property def opengl(self) -> bool: ... @classmethod + @deprecated("since 2.4.0. Use either the display module or the Window class with get_surface and flip. Try not to mix display and Window") def from_display_module(cls) -> Window: ... diff --git a/docs/reST/ref/special_flags_list.rst b/docs/reST/ref/special_flags_list.rst index 057675257e..9a830cd168 100644 --- a/docs/reST/ref/special_flags_list.rst +++ b/docs/reST/ref/special_flags_list.rst @@ -46,15 +46,15 @@ Special Flags List - ``BLEND_ADD`` / ``BLEND_RGB_ADD`` Adds the source color channels to the destination color channels, clamped to a maximum of 255. - The result color is always a lighter color. + The result color is always a lighter color or the same color. - ``BLEND_SUB`` / ``BLEND_RGB_SUB`` Subtracts the source color channels from the destination color channels, clamped to a minimum of 0. - The result color is always a darker color. + The result color is always a darker color or the same color. - ``BLEND_MULT`` / ``BLEND_RGB_MULT`` Multiplies the destination color channels by the source color channels, divided by 256 (or >> 8). - The result color is always a darker color. + The result color is always a darker color or the same color. - ``BLEND_MIN`` / ``BLEND_RGB_MIN`` Takes the minimum value between the source and destination color channels. diff --git a/docs/readmes/README.es.rst b/docs/readmes/README.es.rst index 197902c8e6..f947c8bc01 100644 --- a/docs/readmes/README.es.rst +++ b/docs/readmes/README.es.rst @@ -129,6 +129,7 @@ Versiones de dependencia: Licencia -------- +**Identificador de licencia:** LGPL-2.1-or-later La biblioteca se distribuye bajo la licencia `GNU LGPL version 2.1`_, que se puede encontrar en el archivo ``docs/LGPL.txt``. Nos reservamos el derecho de licenciar versiones futuras de esta biblioteca bajo una licencia diferente. diff --git a/docs/readmes/README.fa.rst b/docs/readmes/README.fa.rst index ae47e87e97..37f820cda5 100644 --- a/docs/readmes/README.fa.rst +++ b/docs/readmes/README.fa.rst @@ -203,6 +203,8 @@ Dependencies (وابستگی ها) License ------- +LGPL-2.1-or-later **شناسه مجوز:** + این کتابخانه با استفاده از `GNU LGPL version 2.1`_ لایسنس شده است که در فایل diff --git a/docs/readmes/README.fr.rst b/docs/readmes/README.fr.rst index 19230080e3..9d36a7514f 100644 --- a/docs/readmes/README.fr.rst +++ b/docs/readmes/README.fr.rst @@ -158,6 +158,7 @@ Versions des dépendances: Licence ------- +**Identifiant de licence:** LGPL-2.1-or-later La bibliothèque est distribuée sous la licence `GNU LGPL version 2.1`_, qui peut être retrouvée dans le fichier ``docs/LGPL.txt``. Nous nous réservons diff --git a/docs/readmes/README.zh-cn.rst b/docs/readmes/README.zh-cn.rst index c4b1cd35d9..8ca54bfe85 100644 --- a/docs/readmes/README.zh-cn.rst +++ b/docs/readmes/README.zh-cn.rst @@ -122,6 +122,7 @@ pygame显然依赖于SDL和Python。此外pygame还嵌入了几个较小的库 许可证 ------- +**许可证标识符:** LGPL-2.1-or-later 本库在 `GNU LGPL version 2.1`_ 下发布,许可文件: ``docs/LGPL.txt`` 。我们保留将此库的未来版本置于其他许可证下的权利。 diff --git a/src_c/_freetype.c b/src_c/_freetype.c index afab14b887..f4da7757fd 100644 --- a/src_c/_freetype.c +++ b/src_c/_freetype.c @@ -51,6 +51,8 @@ _ft_get_error(PyObject *, PyObject *); static PyObject * _ft_get_init(PyObject *, PyObject *); static PyObject * +_ft_was_init(PyObject *, PyObject *); +static PyObject * _ft_autoinit(PyObject *, PyObject *); static PyObject * _ft_get_cache_size(PyObject *, PyObject *); @@ -495,7 +497,7 @@ static PyMethodDef _ft_methods[] = { DOC_FREETYPE_INIT}, {"quit", (PyCFunction)_ft_quit, METH_NOARGS, DOC_FREETYPE_QUIT}, {"get_init", _ft_get_init, METH_NOARGS, DOC_FREETYPE_GETINIT}, - {"was_init", _ft_get_init, METH_NOARGS, + {"was_init", _ft_was_init, METH_NOARGS, DOC_FREETYPE_WASINIT}, // DEPRECATED {"get_error", _ft_get_error, METH_NOARGS, DOC_FREETYPE_GETERROR}, {"get_version", (PyCFunction)_ft_get_version, METH_VARARGS | METH_KEYWORDS, @@ -2230,6 +2232,19 @@ _ft_get_init(PyObject *self, PyObject *_null) return PyBool_FromLong(FREETYPE_MOD_STATE(self)->freetype ? 1 : 0); } +static PyObject * +_ft_was_init(PyObject *self, PyObject *_null) +{ + if (PyErr_WarnEx( + PyExc_DeprecationWarning, + "was_init has been deprecated and may be removed in a future " + "version. Use the equivalent get_init function instead", + 1) == -1) { + return NULL; + } + return _ft_get_init(self, _null); +} + static PyObject * _ft_get_default_font(PyObject *self, PyObject *_null) { diff --git a/src_c/font.c b/src_c/font.c index b829bdc023..44e2870e17 100644 --- a/src_c/font.c +++ b/src_c/font.c @@ -919,10 +919,7 @@ font_set_script(PyObject *self, PyObject *arg) return RAISE_FONT_QUIT_ERROR(); } -/*Sadly, SDL_TTF_VERSION_ATLEAST is new in SDL_ttf 2.0.15, still too - * new to use */ -#if SDL_VERSIONNUM(SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, \ - SDL_TTF_PATCHLEVEL) >= SDL_VERSIONNUM(2, 20, 0) +#if SDL_TTF_VERSION_ATLEAST(2, 20, 0) TTF_Font *font = PyFont_AsFont(self); Py_ssize_t size; const char *script_code; @@ -956,10 +953,7 @@ font_set_direction(PyObject *self, PyObject *arg, PyObject *kwarg) return RAISE_FONT_QUIT_ERROR(); } -/* Can't use SDL_TTF_VERSION_ATLEAST until SDL_ttf 2.0.15 is minimum supported - */ -#if SDL_VERSIONNUM(SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, \ - SDL_TTF_PATCHLEVEL) >= SDL_VERSIONNUM(2, 20, 0) +#if SDL_TTF_VERSION_ATLEAST(2, 20, 0) TTF_Font *font = PyFont_AsFont(self); int direction; char *kwds[] = {"direction", NULL}; @@ -989,8 +983,7 @@ font_set_direction(PyObject *self, PyObject *arg, PyObject *kwarg) writing this) This bug flips the top-to-bottom and bottom-to-top rendering. So, this is a compat patch for that behavior */ -#if SDL_VERSIONNUM(SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, \ - SDL_TTF_PATCHLEVEL) < SDL_VERSIONNUM(2, 22, 0) +#if !SDL_TTF_VERSION_ATLEAST(2, 22, 0) case 2: { dir = TTF_DIRECTION_BTT; break; diff --git a/src_c/scrap.c b/src_c/scrap.c index e83671b845..b34cb6b06e 100644 --- a/src_c/scrap.c +++ b/src_c/scrap.c @@ -349,6 +349,11 @@ _scrap_lost_scrap(PyObject *self, PyObject *_null) { PYGAME_SCRAP_INIT_CHECK(); + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "pygame.scrap.lost deprecated since 2.2.0", 1) == -1) { + return NULL; + } + if (pygame_scrap_lost()) Py_RETURN_TRUE; Py_RETURN_FALSE; diff --git a/src_py/event.py b/src_py/event.py index 69d539e485..97b031e8c8 100644 --- a/src_py/event.py +++ b/src_py/event.py @@ -1,6 +1,6 @@ from __future__ import annotations -from pygame._event import * # pylint: disable=wildcard-import; lgtm[py/polluting-import] +from pygame._event import * # pylint: disable=wildcard-import,unused-wildcard-import; lgtm[py/polluting-import] from pygame._event import _internal_mod_init as _init, _internal_mod_quit as _quit from pygame.constants import USEREVENT, NUMEVENTS from pygame.base import error @@ -156,8 +156,9 @@ def __getattribute__(self, name): def __setattr__(self, name, value): if name in ("_type", "_dict", "type", "dict"): - return super().__setattr__(name, value) - self._dict[name] = value + super().__setattr__(name, value) + else: + self._dict[name] = value EventType = Event diff --git a/test/freetype_test.py b/test/freetype_test.py index 200a9933bd..dccd7ab780 100644 --- a/test/freetype_test.py +++ b/test/freetype_test.py @@ -1767,6 +1767,10 @@ def test_get_init(self): # Test if get_init() gets the init state. self.assertTrue(ft.get_init()) + def test_was_init_deprecated(self): + with self.assertWarns(DeprecationWarning): + self.assertTrue(ft.was_init()) + def test_cache_size(self): DEFAULT_CACHE_SIZE = 64 self.assertEqual(ft.get_cache_size(), DEFAULT_CACHE_SIZE) diff --git a/test/test_utils/__init__.py b/test/test_utils/__init__.py index 16ffb105b8..040d7b8876 100644 --- a/test/test_utils/__init__.py +++ b/test/test_utils/__init__.py @@ -3,8 +3,6 @@ import sys import tempfile -is_pygame_pkg = __name__.startswith("pygame.tests.") - ############################################################################### @@ -22,11 +20,8 @@ def geterror(): ############################################################################### this_dir = os.path.dirname(os.path.abspath(__file__)) -trunk_dir = os.path.split(os.path.split(this_dir)[0])[0] -if is_pygame_pkg: - test_module = "tests" -else: - test_module = "test" +this_dir_parent = os.path.split(this_dir)[0] +trunk_dir = os.path.split(this_dir_parent)[0] def trunk_relative_path(relative): @@ -34,7 +29,7 @@ def trunk_relative_path(relative): def fixture_path(path): - return trunk_relative_path(os.path.join(test_module, "fixtures", path)) + return os.path.join(this_dir_parent, "fixtures", path) def example_path(path):