diff --git a/av/container/core.pyx b/av/container/core.pyx index 3da402f2f..2b9a1244b 100755 --- a/av/container/core.pyx +++ b/av/container/core.pyx @@ -95,7 +95,7 @@ cdef int pyav_io_open_gil(lib.AVFormatContext *s, pb[0] = pyio_file.iocontext return 0 - except Exception as e: + except Exception: return stash_exception() @@ -117,7 +117,7 @@ cdef int pyav_io_close_gil(lib.AVFormatContext *s, lib.AVIOContext *pb) noexcept else: result = pyio_close_gil(pb) - except Exception as e: + except Exception: stash_exception() result = lib.AVERROR_UNKNOWN # Or another appropriate error code diff --git a/av/container/pyio.pyx b/av/container/pyio.pyx index 821ae9c0c..c8b82f96a 100644 --- a/av/container/pyio.pyx +++ b/av/container/pyio.pyx @@ -89,7 +89,7 @@ cdef int pyio_read_gil(void *opaque, uint8_t *buf, int buf_size) noexcept: if not res: return lib.AVERROR_EOF return len(res) - except Exception as e: + except Exception: return stash_exception() @@ -108,7 +108,7 @@ cdef int pyio_write_gil(void *opaque, const uint8_t *buf, int buf_size) noexcept bytes_written = ret_value if isinstance(ret_value, int) else buf_size self.pos += bytes_written return bytes_written - except Exception as e: + except Exception: return stash_exception() @@ -140,7 +140,7 @@ cdef int64_t pyio_seek_gil(void *opaque, int64_t offset, int whence): else: res = self.ftell() return res - except Exception as e: + except Exception: return stash_exception() @@ -148,7 +148,7 @@ cdef int pyio_close_gil(lib.AVIOContext *pb): try: return lib.avio_close(pb) - except Exception as e: + except Exception: stash_exception() @@ -158,12 +158,12 @@ cdef int pyio_close_custom_gil(lib.AVIOContext *pb): self = pb.opaque # Flush bytes in the AVIOContext buffers to the custom I/O - result = lib.avio_flush(pb) + lib.avio_flush(pb) if self.fclose is not None: self.fclose() return 0 - except Exception as e: + except Exception: stash_exception() diff --git a/av/logging.pyx b/av/logging.pyx index 66a5095ad..9cb232d2a 100644 --- a/av/logging.pyx +++ b/av/logging.pyx @@ -318,7 +318,7 @@ cdef void log_callback(void *ptr, int level, const char *format, lib.va_list arg with gil: try: log_callback_gil(level, name, message) - except Exception as e: + except Exception: fprintf(stderr, "av.logging: exception while handling %s[%d]: %s\n", name, level, message) # For some reason lib.PyErr_PrintEx(0) won't work. diff --git a/av/subtitles/subtitle.pyx b/av/subtitles/subtitle.pyx index 373bb529b..a713daa22 100644 --- a/av/subtitles/subtitle.pyx +++ b/av/subtitles/subtitle.pyx @@ -16,7 +16,6 @@ cdef class SubtitleSet: """ def __cinit__(self, SubtitleProxy proxy): self.proxy = proxy - cdef int i self.rects = tuple(build_subtitle(self, i) for i in range(self.proxy.struct.num_rects)) def __repr__(self): diff --git a/av/video/frame.pyx b/av/video/frame.pyx index 4647ab81f..84a35cc49 100644 --- a/av/video/frame.pyx +++ b/av/video/frame.pyx @@ -55,7 +55,6 @@ cdef copy_bytes_to_plane(img_bytes, VideoPlane plane, unsigned int bytes_per_pix cdef const uint8_t[:] i_buf = img_bytes cdef size_t i_pos = 0 cdef size_t i_stride = plane.width * bytes_per_pixel - cdef size_t i_size = plane.height * i_stride cdef uint8_t[:] o_buf = plane cdef size_t o_pos = 0 diff --git a/setup.py b/setup.py index bef384515..f1ae841dd 100644 --- a/setup.py +++ b/setup.py @@ -188,15 +188,18 @@ def parse_cflags(raw_flags): library_dirs=extension_extra["library_dirs"], ) +compiler_directives = { + "c_string_type": "str", + "c_string_encoding": "ascii", + "embedsignature": True, + "binding": False, + "language_level": 3, +} + # Add the cythonized loudnorm extension to ext_modules ext_modules = cythonize( loudnorm_extension, - compiler_directives={ - "c_string_type": "str", - "c_string_encoding": "ascii", - "embedsignature": True, - "language_level": 3, - }, + compiler_directives=compiler_directives, build_dir="src", include_path=["include"], ) @@ -223,12 +226,7 @@ def parse_cflags(raw_flags): library_dirs=extension_extra["library_dirs"], sources=[pyx_path], ), - compiler_directives={ - "c_string_type": "str", - "c_string_encoding": "ascii", - "embedsignature": True, - "language_level": 3, - }, + compiler_directives=compiler_directives, build_dir="src", include_path=["include"], )