diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..c2f1caf --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "pygame_sdl2_windeps"] + path = pygame_sdl2_windeps + url = https://github.com/renpy/pygame_sdl2_windeps.git + branch = master diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..27b81ba --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,154 @@ +cmake_minimum_required(VERSION 3.21) +project(${SKBUILD_PROJECT_NAME} LANGUAGES C) + +# Find required packages +find_package(Python 3.12 EXACT REQUIRED + COMPONENTS Interpreter Development.Module Development.Embed) +find_package(PkgConfig REQUIRED) +include(UseCython) + +# Find SDL2 and related libraries +pkg_check_modules(SDL2 REQUIRED sdl2) +pkg_check_modules(SDL2_IMAGE REQUIRED SDL2_image) +pkg_check_modules(SDL2_TTF REQUIRED SDL2_ttf) +pkg_check_modules(SDL2_MIXER REQUIRED SDL2_mixer) + +# Find additional libraries +find_library(JPEG_LIBRARY jpeg REQUIRED) +find_library(PNG_LIBRARY png REQUIRED) + +# Global settings +set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD_REQUIRED ON) + +# Include directories +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/src + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${SDL2_INCLUDE_DIRS} +) + +set(CYTHON_ARGS + -X embedsignature=True + -I${CMAKE_CURRENT_SOURCE_DIR}/include) + +# Function to create Cython extension +function(add_cython_extension name) + set(options) + set(oneValueArgs) + set(multiValueArgs SOURCES LIBRARIES) + cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + # Convert module name to path + string(REPLACE "." "/" module_path ${name}) + set(pyx_file ${CMAKE_CURRENT_SOURCE_DIR}/src/${module_path}.pyx) + + cython_transpile(${pyx_file} OUTPUT_VARIABLE c_file) + + # Create Python extension + python_add_library(${name} MODULE ${c_file} ${ARG_SOURCES}) + + # Extract the base filename for the extension + get_filename_component(base_filename ${module_path} NAME) + + # Set properties for Python 3.12 + set_target_properties(${name} PROPERTIES + PREFIX "" + OUTPUT_NAME ${base_filename} + ) + + # Link libraries + target_link_libraries(${name} PRIVATE + ${SDL2_LIBRARIES} + ${ARG_LIBRARIES} + ) + + # Add compile flags + target_compile_options(${name} PRIVATE + ${SDL2_CFLAGS_OTHER} + ${EXTRA_CFLAGS} + ) + + # Install the extension + string(REPLACE "." "/" install_subpath ${name}) + get_filename_component(install_dir ${install_subpath} DIRECTORY) + install(TARGETS ${name} DESTINATION ${install_dir}) + +endfunction() + +# Add all Cython extensions +add_cython_extension(pygame_sdl2.error) +add_cython_extension(pygame_sdl2.color) +add_cython_extension(pygame_sdl2.controller) +add_cython_extension(pygame_sdl2.rect) +add_cython_extension(pygame_sdl2.rwobject) +add_cython_extension(pygame_sdl2.surface + SOURCES src/alphablit.c +) +add_cython_extension(pygame_sdl2.display) +add_cython_extension(pygame_sdl2.event) +add_cython_extension(pygame_sdl2.locals) +add_cython_extension(pygame_sdl2.key) +add_cython_extension(pygame_sdl2.mouse) +add_cython_extension(pygame_sdl2.joystick) +add_cython_extension(pygame_sdl2.power) +add_cython_extension(pygame_sdl2.pygame_time) +add_cython_extension(pygame_sdl2.image + SOURCES src/write_jpeg.c src/write_png.c + LIBRARIES ${SDL2_IMAGE_LIBRARIES} ${JPEG_LIBRARY} ${PNG_LIBRARY} +) +add_cython_extension(pygame_sdl2.transform + SOURCES src/SDL2_rotozoom.c +) +add_cython_extension(pygame_sdl2.gfxdraw + SOURCES src/SDL_gfxPrimitives.c +) +add_cython_extension(pygame_sdl2.draw) +add_cython_extension(pygame_sdl2.font + LIBRARIES ${SDL2_TTF_LIBRARIES} +) +add_cython_extension(pygame_sdl2.mixer + LIBRARIES ${SDL2_MIXER_LIBRARIES} +) +add_cython_extension(pygame_sdl2.mixer_music + LIBRARIES ${SDL2_MIXER_LIBRARIES} +) +add_cython_extension(pygame_sdl2.scrap) +add_cython_extension(pygame_sdl2.render + LIBRARIES ${SDL2_IMAGE_LIBRARIES} +) + +# Install Python modules +install( + DIRECTORY src/pygame_sdl2/ + DESTINATION pygame_sdl2 + FILES_MATCHING PATTERN "*.py" +) + +# Install data files +install( + FILES + src/pygame_sdl2/DejaVuSans.ttf + src/pygame_sdl2/DejaVuSans.txt + DESTINATION pygame_sdl2 +) + +# Install headers +install( + FILES + src/pygame_sdl2/pygame_sdl2.h + ${CMAKE_CURRENT_BINARY_DIR}/src/pygame_sdl2/rwobject_api.h + ${CMAKE_CURRENT_BINARY_DIR}/src/pygame_sdl2/surface_api.h + ${CMAKE_CURRENT_BINARY_DIR}/src/pygame_sdl2/display_api.h + DESTINATION include/pygame_sdl2 +) + +# Install dlls +if (WIN32) + install( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/pygame_sdl2_windeps/lib/x64/ + DESTINATION pygame_sdl2 + FILES_MATCHING PATTERN "*.dll" + ) +endif() diff --git a/Setup b/Setup deleted file mode 100644 index 191a14d..0000000 --- a/Setup +++ /dev/null @@ -1,20 +0,0 @@ -pygame_sdl2.error gen/pygame_sdl2.error.c -pygame_sdl2.color gen/pygame_sdl2.color.c -pygame_sdl2.controller gen/pygame_sdl2.controller.c -pygame_sdl2.rect gen/pygame_sdl2.rect.c -pygame_sdl2.rwobject gen/pygame_sdl2.rwobject.c -pygame_sdl2.surface gen/pygame_sdl2.surface.c src/alphablit.c -pygame_sdl2.display gen/pygame_sdl2.display.c -pygame_sdl2.event gen/pygame_sdl2.event.c -pygame_sdl2.locals gen/pygame_sdl2.locals.c -pygame_sdl2.key gen/pygame_sdl2.key.c -pygame_sdl2.mouse gen/pygame_sdl2.mouse.c -pygame_sdl2.joystick gen/pygame_sdl2.joystick.c -pygame_sdl2.power gen/pygame_sdl2.power.c -pygame_sdl2.pygame_time gen/pygame_sdl2.pygame_time.c -pygame_sdl2.image gen/pygame_sdl2.image.c src/write_jpeg.c src/write_png.c -pygame_sdl2.transform gen/pygame_sdl2.transform.c src/SDL2_rotozoom.c -pygame_sdl2.gfxdraw gen/pygame_sdl2.gfxdraw.c src/SDL_gfxPrimitives.c -pygame_sdl2.draw gen/pygame_sdl2.draw.c -pygame_sdl2.scrap gen/pygame_sdl2.scrap.c - diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..70f7410 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,13 @@ +[project] +name = "pygame_sdl2" +version = "2.1.0" +readme = "README.rst" +requires-python = "==3.12.*" +dependencies = [] + +[build-system] +requires = ["scikit-build-core>=0.11", "cython>=3.1.0", "cython-cmake"] +build-backend = "scikit_build_core.build" + +[tool.scikit-build] +build-dir = "build" diff --git a/setup.py b/setup.py deleted file mode 100755 index b873e03..0000000 --- a/setup.py +++ /dev/null @@ -1,180 +0,0 @@ -#!/usr/bin/env python - -# Copyright 2024 Tom Rothamel -# -# This software is provided 'as-is', without any express or implied -# warranty. In no event will the authors be held liable for any damages -# arising from the use of this software. -# -# Permission is granted to anyone to use this software for any purpose, -# including commercial applications, and to alter it and redistribute it -# freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must not -# claim that you wrote the original software. If you use this software -# in a product, an acknowledgment in the product documentation would be -# appreciated but is not required. -# 2. Altered source versions must be plainly marked as such, and must not be -# misrepresented as being the original software. -# 3. This notice may not be removed or altered from any source distribution. - -from __future__ import division, absolute_import, print_function - -# The version of pygame_sdl2. This should also be updated in version.py -VERSION = "2.1.0" - -from setuplib import android, ios, windows, cython, pymodule, setup, parse_cflags, parse_libs, find_unnecessary_gen, gen -import setuplib - -import os -import platform -import shutil -import sys -import sysconfig - -def setup_env(name): - # If PYGAME_SDL2_CC or PYGAME_SDL2_LD are in the environment, and CC or LD are not, use them. - - renpy_name = "PYGAME_SDL2_" + name - if (renpy_name in os.environ) and (name not in os.environ): - os.environ[name] = os.environ[renpy_name] - - -setup_env("CC") -setup_env("LD") -setup_env("CXX") - -temporary_package_data = [ ] - -if android or ios: - sdl_libs = [ 'SDL2' ] - -else: - - setuplib.package_data.extend([ - "DejaVuSans.ttf", - "DejaVuSans.txt", - ]) - - try: - parse_cflags([ "sh", "-c", "sdl2-config --cflags" ]) - sdl_libs = parse_libs([ "sh", "-c", "sdl2-config --libs" ]) - except: - - if not windows: - raise - - windeps = os.path.join(os.path.dirname(__file__), "pygame_sdl2_windeps") - - if not os.path.isdir(windeps): - raise - - sdl_libs = [ 'SDL2' ] - setuplib.include_dirs.append(os.path.join(windeps, "include")) - - if sys.version_info[0] < 3: - setuplib.include_dirs.append(os.path.join(windeps, "include27")) - - if platform.architecture()[0] == "32bit": - libdir = os.path.join(windeps, "lib/x86") - else: - libdir = os.path.join(windeps, "lib/x64") - - setuplib.library_dirs.append(libdir) - - for i in os.listdir(libdir): - if i.lower().endswith(".dll"): - shutil.copy( - os.path.join(libdir, i), - os.path.join(os.path.dirname(__file__), "src", "pygame_sdl2", i), - ) - - temporary_package_data.append(i) - - setuplib.package_data.extend(temporary_package_data) - -if android: - png = "png16" -else: - png = "png" - -pymodule("pygame_sdl2.__init__") -pymodule("pygame_sdl2.compat") -pymodule("pygame_sdl2.threads.__init__") -pymodule("pygame_sdl2.threads.Py25Queue") -pymodule("pygame_sdl2.sprite") -pymodule("pygame_sdl2.sysfont") -pymodule("pygame_sdl2.time") -pymodule("pygame_sdl2.version") - -cython("pygame_sdl2.error", libs=sdl_libs) -cython("pygame_sdl2.color", libs=sdl_libs) -cython("pygame_sdl2.controller", libs=sdl_libs) -cython("pygame_sdl2.rect", libs=sdl_libs) -cython("pygame_sdl2.rwobject", libs=sdl_libs) -cython("pygame_sdl2.surface", source=[ "src/alphablit.c" ], libs=sdl_libs) -cython("pygame_sdl2.display", libs=sdl_libs) -cython("pygame_sdl2.event", libs=sdl_libs) -cython("pygame_sdl2.locals", libs=sdl_libs) -cython("pygame_sdl2.key", libs=sdl_libs) -cython("pygame_sdl2.mouse", libs=sdl_libs) -cython("pygame_sdl2.joystick", libs=sdl_libs) -cython("pygame_sdl2.power", libs=sdl_libs) -cython("pygame_sdl2.pygame_time", libs=sdl_libs) -cython("pygame_sdl2.image", source=[ "src/write_jpeg.c", "src/write_png.c" ], libs=[ 'SDL2_image', "jpeg", png ] + sdl_libs) -cython("pygame_sdl2.transform", source=[ "src/SDL2_rotozoom.c" ], libs=sdl_libs) -cython("pygame_sdl2.gfxdraw", source=[ "src/SDL_gfxPrimitives.c" ], libs=sdl_libs) -cython("pygame_sdl2.draw", libs=sdl_libs) -cython("pygame_sdl2.font", libs=['SDL2_ttf'] + sdl_libs) -cython("pygame_sdl2.mixer", libs=['SDL2_mixer'] + sdl_libs) -cython("pygame_sdl2.mixer_music", libs=['SDL2_mixer'] + sdl_libs) -cython("pygame_sdl2.scrap", libs=sdl_libs) -cython("pygame_sdl2.render", libs=['SDL2_image'] + sdl_libs) - -headers = [ - "src/pygame_sdl2/pygame_sdl2.h", - gen + "/pygame_sdl2.rwobject_api.h", - gen + "/pygame_sdl2.surface_api.h", - gen + "/pygame_sdl2.display_api.h", - ] - -if __name__ == "__main__": - - - if sys.version_info.major <= 3 and sys.version_info.minor <= 11: - py_headers = headers - headers = [ ] - else: - py_headers = [ ] - - setup( - "pygame_sdl2", - VERSION, - headers=py_headers, - url="https://github.com/renpy/pygame_sdl2", - maintainer="Tom Rothamel", - maintainer_email="tom@rothamel.us", - ) - - find_unnecessary_gen() - - for i in temporary_package_data: - os.unlink(os.path.join(os.path.dirname(__file__), "src", "pygame_sdl2", i)) - - if headers: - import pathlib - - virtual_env = os.environ.get("VIRTUAL_ENV", None) - - if virtual_env: - headers_dir = pathlib.Path(virtual_env) / "include" / "pygame_sdl2" - else: - headers_dir = pathlib.Path(sysconfig.get_paths()['include']) / "pygame_sdl2" - - headers_dir.mkdir(parents=True, exist_ok=True) - - for header in headers: - srcpath = pathlib.Path(header) - dstpath = headers_dir / srcpath.name - - shutil.copy(srcpath, dstpath) diff --git a/setuplib.py b/setuplib.py deleted file mode 100644 index a04e68a..0000000 --- a/setuplib.py +++ /dev/null @@ -1,351 +0,0 @@ -# Copyright 2014 Tom Rothamel -# -# This software is provided 'as-is', without any express or implied -# warranty. In no event will the authors be held liable for any damages -# arising from the use of this software. -# -# Permission is granted to anyone to use this software for any purpose, -# including commercial applications, and to alter it and redistribute it -# freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must not -# claim that you wrote the original software. If you use this software -# in a product, an acknowledgment in the product documentation would be -# appreciated but is not required. -# 2. Altered source versions must be plainly marked as such, and must not be -# misrepresented as being the original software. -# 3. This notice may not be removed or altered from any source distribution. - -from __future__ import division, absolute_import, print_function - -import os -import sys -import re -import subprocess -import platform -import warnings - -import setuptools - - -warnings.simplefilter("ignore", category=setuptools.SetuptoolsDeprecationWarning) - -# The include and library dirs that we compile against. -include_dirs = [ ".", "src" ] -library_dirs = [ ] - -# Extra arguments that will be given to the compiler. -extra_compile_args = [ ] -extra_link_args = [ ] - -# Data files (including DLLs) to include with the package. -package_data = [ ] - -# A list of extension objects that we use. -extensions = [ ] - -# A list of macros that are defined for all modules. -global_macros = [ ] - -# True if we're building on android. -android = "PYGAME_SDL2_ANDROID" in os.environ - -# True if we're building on ios. -ios = "PYGAME_SDL2_IOS" in os.environ - -# True if we're doing a static build. -static = "PYGAME_SDL2_STATIC" in os.environ - -windows = platform.win32_ver()[0] - -# The cython command. -if windows: - cython_command = os.path.join(os.path.dirname(sys.executable), "Scripts", "cython.exe") -else: - cython_command = "cython" - -if sys.version_info[0] >= 3: - gen = "gen3" -else: - gen = "gen" - -version_flag = "--3str" - -if static: - gen = gen + "-static" - -def system_path(path): - """ - On windows/msys, converts a unix-style path returned from sdl2-config - to a windows path. Otherwise, returns path. - """ - - if "MSYSTEM" in os.environ: - path = subprocess.check_output([ "sh", "-c", "cmd //c echo " + path ]).strip() - - return path - - -def parse_cflags(command): - """ - Runs `command`, and uses the command's output to set up include_dirs - and extra_compile_args. if `command` is None, parses the cflags from - the environment. - """ - - if "PYGAME_SDL2_CFLAGS" in os.environ: - output = os.environ["PYGAME_SDL2_CFLAGS"] - elif command is not None: - output = subprocess.check_output(command, universal_newlines=True) - else: - output = os.environ.get("CFLAGS", "") - - for i in output.split(): - if i.startswith("-I"): - include_dirs.append(system_path(i[2:])) - else: - extra_compile_args.append(i) - - -parse_cflags(None) - - -def parse_libs(command): - """ - Runs `command`, and uses the command's output to set up library_dirs and - extra_link_args. Returns a list of libraries to link against. If `command` - is None, parses LDFLAGS from the environment. - """ - - if "PYGAME_SDL2_LDFLAGS" in os.environ: - output = os.environ["PYGAME_SDL2_LDFLAGS"] - else: - output = subprocess.check_output(command, universal_newlines=True) - - libs = [ ] - - for i in output.split(): - if i.startswith("-L"): - library_dirs.append(system_path(i[2:])) - elif i.startswith("-l"): - libs.append(i[2:]) - else: - extra_compile_args.append(i) - - return libs - - -# A list of modules we do not wish to include. -exclude = set(os.environ.get("PYGAME_SDL2_EXCLUDE", "").split()) - - -def cmodule(name, source, libs=[], define_macros=[]): - """ - Compiles the python module `name` from the files given in - `source`, and the libraries in `libs`. - """ - - if name in exclude: - return - - extensions.append(setuptools.Extension( - name, - source, - include_dirs=include_dirs, - library_dirs=library_dirs, - extra_compile_args=extra_compile_args, - extra_link_args=extra_link_args, - libraries=libs, - define_macros=define_macros + global_macros, - )) - - -necessary_gen = [ ] - - -def cython(name, source=[], libs=[], compile_if=True, define_macros=[]): - """ - Compiles a cython module. This takes care of regenerating it as necessary - when it, or any of the files it depends on, changes. - """ - - # Find the pyx file. - split_name = name.split(".") - - fn = "src/" + "/".join(split_name) + ".pyx" - - if not os.path.exists(fn): - print("Could not find {0}.".format(fn)) - sys.exit(-1) - - module_dir = os.path.dirname(fn) - - # Figure out what it depends on. - deps = [ fn ] - - f = open(fn, "r") - for l in f: - - m = re.search(r'from\s*([\w.]+)\s*cimport', l) - if m: - deps.append(m.group(1).replace(".", "/") + ".pxd") - continue - - m = re.search(r'cimport\s*([\w.]+)', l) - if m: - deps.append(m.group(1).replace(".", "/") + ".pxd") - continue - - m = re.search(r'include\s*"(.*?)"', l) - if m: - deps.append(m.group(1)) - continue - f.close() - - # Filter out cython stdlib dependencies. - deps = [ i for i in deps if (not i.startswith("cpython/")) and (not i.startswith("libc/")) ] - - # Determine if any of the dependencies are newer than the c file. - c_fn = os.path.join(gen, name + ".c") - necessary_gen.append(name + ".c") - - if os.path.exists(c_fn): - c_mtime = os.path.getmtime(c_fn) - else: - c_mtime = 0 - - out_of_date = False - - # print c_fn, "depends on", deps - - for dep_fn in deps: - - if os.path.exists(os.path.join("src", dep_fn)): - dep_fn = os.path.join("src", dep_fn) - elif os.path.exists(os.path.join("include", dep_fn)): - dep_fn = os.path.join("include", dep_fn) - elif os.path.exists(os.path.join(gen, dep_fn)): - dep_fn = os.path.join(gen, dep_fn) - elif os.path.exists(dep_fn): - pass - else: - print("{0} depends on {1}, which can't be found.".format(fn, dep_fn)) - sys.exit(-1) - - if os.path.getmtime(dep_fn) > c_mtime: - out_of_date = True - - if out_of_date and not cython_command: - print("WARNING:", name, "is out of date, but RENPY_CYTHON isn't set.") - out_of_date = False - - # If the file is out of date, regenerate it. - if out_of_date: - print(name, "is out of date.") - - try: - subprocess.check_call([ - cython_command, - version_flag, - "-X", "profile=False", - "-X", "embedsignature=True", - "-Iinclude", - "-I" + gen, - "-a", - fn, - "-o", - c_fn]) - - # Fix-up source for static loading - if static: - - parent_module = '.'.join(split_name[:-1]) - parent_module_identifier = parent_module.replace('.', '_') - - with open(c_fn, 'r') as f: - ccode = f.read() - - with open(c_fn + ".dynamic", 'w') as f: - f.write(ccode) - - if len(split_name) > 1: - - ccode = re.sub(r'Py_InitModule4\("([^"]+)"', 'Py_InitModule4("' + parent_module + '.\\1"', ccode) # Py2 - ccode = re.sub(r'(__pyx_moduledef.*?"){}"'.format(re.escape(split_name[-1])), '\\1' + '.'.join(split_name) + '"', ccode, count=1, flags=re.DOTALL) # Py3 - ccode = re.sub(r'^__Pyx_PyMODINIT_FUNC init', '__Pyx_PyMODINIT_FUNC init' + parent_module_identifier + '_', ccode, 0, re.MULTILINE) # Py2 Cython 0.28+ - ccode = re.sub(r'^__Pyx_PyMODINIT_FUNC PyInit_', '__Pyx_PyMODINIT_FUNC PyInit_' + parent_module_identifier + '_', ccode, 0, re.MULTILINE) # Py3 Cython 0.28+ - ccode = re.sub(r'^PyMODINIT_FUNC init', 'PyMODINIT_FUNC init' + parent_module_identifier + '_', ccode, 0, re.MULTILINE) # Py2 Cython 0.25.2 - - with open(c_fn, 'w') as f: - f.write(ccode) - - except subprocess.CalledProcessError as e: - print() - print(str(e)) - print() - sys.exit(-1) - - # Build the module normally once we have the c file. - if compile_if: - cmodule(name, [ c_fn ] + source, libs=libs, define_macros=define_macros) - - -def find_unnecessary_gen(): - - for i in os.listdir(gen): - if not i.endswith(".c"): - continue - - if i in necessary_gen: - continue - - print("Unnecessary file", os.path.join(gen, i)) - - -py_modules = [ ] - - -def pymodule(name): - """ - Causes a python module to be included in the build. - """ - - if name in exclude: - return - - py_modules.append(name) - - -def setup(name, version, **kwargs): - """ - Calls the distutils setup function. - """ - - global extensions - - if (len(sys.argv) >= 2) and (sys.argv[1] == "generate"): - return - - if "--no-extensions" in sys.argv: - sys.argv = [ i for i in sys.argv if i != "--no-extensions" ] - extensions = [ ] - - setuptools.setup( - name=name, - version=version, - ext_modules=extensions, - py_modules=py_modules, - packages=[ name ], - package_dir={ name : 'src/' + name }, - package_data={ name : package_data }, - zip_safe=False, - **kwargs - ) - - -# Start in the directory containing setup.py. -os.chdir(os.path.abspath(os.path.dirname(sys.argv[0]))) - -# Ensure the gen directory exists. -if not os.path.exists(gen): - os.mkdir(gen) diff --git a/src/pygame_sdl2/event.pyx b/src/pygame_sdl2/event.pyx index 7b790eb..4becb73 100644 --- a/src/pygame_sdl2/event.pyx +++ b/src/pygame_sdl2/event.pyx @@ -332,7 +332,7 @@ cdef object get_events(kinds): The lock must be held when calling this function. """ - if isinstance(kinds, (int, long)): + if isinstance(kinds, int): kinds = [ kinds ] global event_queue @@ -459,7 +459,7 @@ def set_blocked(t=None): if t == None: for et in event_names.keys(): SDL_EventState(et, SDL_ENABLE) - elif isinstance(t, (int, long)): + elif isinstance(t, int): SDL_EventState(t, SDL_IGNORE) else: for et in t: @@ -469,7 +469,7 @@ def set_allowed(t=None): if t == None: for et in event_names.keys(): SDL_EventState(et, SDL_IGNORE) - elif isinstance(t, (int, long)): + elif isinstance(t, int): SDL_EventState(t, SDL_ENABLE) else: for et in t: