Hello community,

here is the log from the commit of package python-spidev for openSUSE:Factory 
checked in at 2020-07-28 17:26:37
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-spidev (Old)
 and      /work/SRC/openSUSE:Factory/.python-spidev.new.3592 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-spidev"

Tue Jul 28 17:26:37 2020 rev:2 rq:823098 version:3.5

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-spidev/python-spidev.changes      
2019-11-13 13:14:18.878822382 +0100
+++ /work/SRC/openSUSE:Factory/.python-spidev.new.3592/python-spidev.changes    
2020-07-28 17:27:40.998064364 +0200
@@ -1,0 +2,6 @@
+Tue Jul 28 08:43:38 UTC 2020 - Marketa Calabkova <mcalabk...@suse.com>
+
+- Update to 3.5
+  * Fixed memory leaks
+
+-------------------------------------------------------------------

Old:
----
  spidev-3.4.tar.gz

New:
----
  spidev-3.5.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-spidev.spec ++++++
--- /var/tmp/diff_new_pack.lUnOFI/_old  2020-07-28 17:27:45.466069433 +0200
+++ /var/tmp/diff_new_pack.lUnOFI/_new  2020-07-28 17:27:45.470069438 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package python-spidev
 #
-# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2020 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,27 +17,23 @@
 
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
-
-%define         orig_name spidev
-
 Name:           python-spidev
-Version:        3.4
+Version:        3.5
 Release:        0
 Summary:        Python module for interfacing with SPI devices
 License:        MIT
-Url:            https://pypi.org/project/spidev/
-Source0:        
https://github.com/doceme/py-spidev/archive/v%{version}.tar.gz#/%{orig_name}-%{version}.tar.gz
+URL:            https://pypi.org/project/spidev/
+Source0:        
https://files.pythonhosted.org/packages/source/s/spidev/spidev-%{version}.tar.gz
 BuildRequires:  %{python_module devel}
 BuildRequires:  %{python_module setuptools}
 BuildRequires:  python-rpm-macros
+%python_subpackages
 
 %description
 This package contains the python module for interfacing with SPI devices from 
user space via the spidev linux kernel driver.
 
-%python_subpackages
-
 %prep
-%setup -q -n py-spidev-%{version}
+%setup -q -n spidev-%{version}
 
 %build
 %python_build

++++++ spidev-3.4.tar.gz -> spidev-3.5.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/py-spidev-3.4/.gitignore new/spidev-3.5/.gitignore
--- old/py-spidev-3.4/.gitignore        2019-02-21 19:02:07.000000000 +0100
+++ new/spidev-3.5/.gitignore   1970-01-01 01:00:00.000000000 +0100
@@ -1,14 +0,0 @@
-__pycache__/
-*.py[cod]
-dist/
-sdist/
-env/
-build/
-develop-eggs/
-eggs/
-*.egg-info/
-.installed.cfg
-*.egg
-
-pip-log.txt
-pip-delete-this-directory.txt
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/py-spidev-3.4/CHANGELOG.md 
new/spidev-3.5/CHANGELOG.md
--- old/py-spidev-3.4/CHANGELOG.md      2019-02-21 19:02:07.000000000 +0100
+++ new/spidev-3.5/CHANGELOG.md 2020-06-02 22:07:30.000000000 +0200
@@ -1,6 +1,11 @@
 Changelog
 ---------
 
+3.5
+====
+
+* Fixed memory leaks
+
 3.4
 =====
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/py-spidev-3.4/MANIFEST.in new/spidev-3.5/MANIFEST.in
--- old/py-spidev-3.4/MANIFEST.in       2019-02-21 19:02:07.000000000 +0100
+++ new/spidev-3.5/MANIFEST.in  2020-06-02 21:58:14.000000000 +0200
@@ -1,5 +1,5 @@
 include spidev_module.c
 include README.md
 include CHANGELOG.md
-include LICENSE.md
+include LICENSE
 include setup.py
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/py-spidev-3.4/Makefile new/spidev-3.5/Makefile
--- old/py-spidev-3.4/Makefile  2019-02-21 19:02:07.000000000 +0100
+++ new/spidev-3.5/Makefile     1970-01-01 01:00:00.000000000 +0100
@@ -1,15 +0,0 @@
-PYTHON ?= python
-
-all:
-       $(PYTHON) setup.py build
-
-install:
-       $(PYTHON) setup.py install
-
-clean:
-       $(PYTHON) setup.py clean
-       rm -rf build dist
-
-cleandir distclean: clean
-       $(PYTHON) setup.py clean -a
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/py-spidev-3.4/PKG-INFO new/spidev-3.5/PKG-INFO
--- old/py-spidev-3.4/PKG-INFO  1970-01-01 01:00:00.000000000 +0100
+++ new/spidev-3.5/PKG-INFO     2020-06-02 22:07:41.000000000 +0200
@@ -0,0 +1,144 @@
+Metadata-Version: 2.1
+Name: spidev
+Version: 3.5
+Summary: Python bindings for Linux SPI access through spidev
+Home-page: http://github.com/doceme/py-spidev
+Author: Volker Thoms
+Author-email: unconnec...@gmx.de
+Maintainer: Stephen Caudle
+Maintainer-email: scau...@doceme.com
+License: MIT
+Description: Python Spidev
+        =============
+        
+        This project contains a python module for interfacing with SPI devices 
from user space via the spidev linux kernel driver.
+        
+        All code is MIT licensed unless explicitly stated otherwise.
+        
+        Usage
+        -----
+        
+        ```python
+        import spidev
+        spi = spidev.SpiDev()
+        spi.open(bus, device)
+        to_send = [0x01, 0x02, 0x03]
+        spi.xfer(to_send)
+        ```
+        Settings
+        --------
+        
+        ```python
+        import spidev
+        spi = spidev.SpiDev()
+        spi.open(bus, device)
+        
+        # Settings (for example)
+        spi.max_speed_hz = 5000
+        spi.mode = 0b01
+        
+        ...
+        ```
+        
+        * `bits_per_word`
+        * `cshigh`
+        * `loop` - Set the "SPI_LOOP" flag to enable loopback mode
+        * `no_cs` - Set the "SPI_NO_CS" flag to disable use of the chip select 
(although the driver may still own the CS pin)
+        * `lsbfirst`
+        * `max_speed_hz`
+        * `mode` - SPI mode as two bit pattern of clock polarity and phase 
[CPOL|CPHA], min: 0b00 = 0, max: 0b11 = 3
+        * `threewire` - SI/SO signals shared
+        
+        Methods
+        -------
+        
+            open(bus, device)
+        
+        Connects to the specified SPI device, opening 
`/dev/spidev<bus>.<device>`
+        
+            readbytes(n)
+        
+        Read n bytes from SPI device.
+        
+            writebytes(list of values)
+        
+        Writes a list of values to SPI device.
+        
+            writebytes2(list of values)
+        
+        Similar to `writebytes` but accepts arbitrary large lists.
+        If list size exceeds buffer size (which is read from 
`/sys/module/spidev/parameters/bufsiz`),
+        data will be split into smaller chunks and sent in multiple operations.
+        
+        Also, `writebytes2` understands [buffer 
protocol](https://docs.python.org/3/c-api/buffer.html)
+        so it can accept numpy byte arrays for example without need to convert 
them with `tolist()` first.
+        This offers much better performance where you need to transfer frames 
to SPI-connected displays for instance.
+        
+            xfer(list of values[, speed_hz, delay_usec, bits_per_word])
+        
+        Performs an SPI transaction. Chip-select should be released and 
reactivated between blocks.
+        Delay specifies the delay in usec between blocks.
+        
+            xfer2(list of values[, speed_hz, delay_usec, bits_per_word])
+        
+        Performs an SPI transaction. Chip-select should be held active between 
blocks.
+        
+            xfer3(list of values[, speed_hz, delay_usec, bits_per_word])
+        
+        Similar to `xfer2` but accepts arbitrary large lists.
+        If list size exceeds buffer size (which is read from 
`/sys/module/spidev/parameters/bufsiz`),
+        data will be split into smaller chunks and sent in multiple operations.
+        
+            close()
+        
+        Disconnects from the SPI device.
+        
+        Changelog
+        ---------
+        
+        3.5
+        ====
+        
+        * Fixed memory leaks
+        
+        3.4
+        =====
+        
+        * Changed license to MIT
+        
+        3.0.1
+        =====
+        
+        * Fixed README.md and CHANGELOG.md formatting, hopefully
+        
+        3.0
+        ===
+        
+        * Memset fix recommended by Dougie Lawson
+        * Fixes for Kernel 3.15+ from https://github.com/chrillomat/py-spidev
+        * Fixes for Python 3/2 compatibility.
+        * Added subclassing support - 
https://github.com/doceme/py-spidev/issues/10
+        
+        2.0
+        ===
+        
+        Code sourced from 
http://elk.informatik.fh-augsburg.de/da/da-49/trees/pyap7k/lang/py-spi
+        and modified.
+        
+        Pre 2.0
+        =======
+        
+        spimodule.c originally uathored by Volker Thoms, 2009.
+        
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Operating System :: POSIX :: Linux
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Intended Audience :: Developers
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Topic :: Software Development
+Classifier: Topic :: System :: Hardware
+Classifier: Topic :: System :: Hardware :: Hardware Drivers
+Description-Content-Type: text/markdown
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/py-spidev-3.4/setup.cfg new/spidev-3.5/setup.cfg
--- old/py-spidev-3.4/setup.cfg 2019-02-21 19:02:07.000000000 +0100
+++ new/spidev-3.5/setup.cfg    2020-06-02 22:07:41.000000000 +0200
@@ -1,2 +1,7 @@
 [metadata]
 description-file = README.md
+
+[egg_info]
+tag_build = 
+tag_date = 0
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/py-spidev-3.4/setup.py new/spidev-3.5/setup.py
--- old/py-spidev-3.4/setup.py  2019-02-21 19:02:07.000000000 +0100
+++ new/spidev-3.5/setup.py     2020-06-02 21:58:14.000000000 +0200
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-from distutils.core import setup, Extension
+from setuptools import setup, Extension
 
 version = "0.0"
 
@@ -14,7 +14,7 @@
 
 classifiers = ['Development Status :: 5 - Production/Stable',
                'Operating System :: POSIX :: Linux',
-               'License :: OSI Approved :: GNU General Public License v2 
(GPLv2)',
+               'License :: OSI Approved :: MIT License',
                'Intended Audience :: Developers',
                'Programming Language :: Python :: 2.6',
                'Programming Language :: Python :: 2.7',
@@ -27,11 +27,12 @@
        version         = version,
        description     = "Python bindings for Linux SPI access through spidev",
        long_description= open('README.md').read() + "\n" + 
open('CHANGELOG.md').read(),
+        long_description_content_type = "text/markdown",
        author          = "Volker Thoms",
        author_email    = "unconnec...@gmx.de",
        maintainer      = "Stephen Caudle",
        maintainer_email= "scau...@doceme.com",
-       license         = "GPLv2",
+       license         = "MIT",
        classifiers     = classifiers,
        url             = "http://github.com/doceme/py-spidev";,
        ext_modules     = [Extension("spidev", ["spidev_module.c"])]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/py-spidev-3.4/spidev.egg-info/PKG-INFO 
new/spidev-3.5/spidev.egg-info/PKG-INFO
--- old/py-spidev-3.4/spidev.egg-info/PKG-INFO  1970-01-01 01:00:00.000000000 
+0100
+++ new/spidev-3.5/spidev.egg-info/PKG-INFO     2020-06-02 22:07:41.000000000 
+0200
@@ -0,0 +1,144 @@
+Metadata-Version: 2.1
+Name: spidev
+Version: 3.5
+Summary: Python bindings for Linux SPI access through spidev
+Home-page: http://github.com/doceme/py-spidev
+Author: Volker Thoms
+Author-email: unconnec...@gmx.de
+Maintainer: Stephen Caudle
+Maintainer-email: scau...@doceme.com
+License: MIT
+Description: Python Spidev
+        =============
+        
+        This project contains a python module for interfacing with SPI devices 
from user space via the spidev linux kernel driver.
+        
+        All code is MIT licensed unless explicitly stated otherwise.
+        
+        Usage
+        -----
+        
+        ```python
+        import spidev
+        spi = spidev.SpiDev()
+        spi.open(bus, device)
+        to_send = [0x01, 0x02, 0x03]
+        spi.xfer(to_send)
+        ```
+        Settings
+        --------
+        
+        ```python
+        import spidev
+        spi = spidev.SpiDev()
+        spi.open(bus, device)
+        
+        # Settings (for example)
+        spi.max_speed_hz = 5000
+        spi.mode = 0b01
+        
+        ...
+        ```
+        
+        * `bits_per_word`
+        * `cshigh`
+        * `loop` - Set the "SPI_LOOP" flag to enable loopback mode
+        * `no_cs` - Set the "SPI_NO_CS" flag to disable use of the chip select 
(although the driver may still own the CS pin)
+        * `lsbfirst`
+        * `max_speed_hz`
+        * `mode` - SPI mode as two bit pattern of clock polarity and phase 
[CPOL|CPHA], min: 0b00 = 0, max: 0b11 = 3
+        * `threewire` - SI/SO signals shared
+        
+        Methods
+        -------
+        
+            open(bus, device)
+        
+        Connects to the specified SPI device, opening 
`/dev/spidev<bus>.<device>`
+        
+            readbytes(n)
+        
+        Read n bytes from SPI device.
+        
+            writebytes(list of values)
+        
+        Writes a list of values to SPI device.
+        
+            writebytes2(list of values)
+        
+        Similar to `writebytes` but accepts arbitrary large lists.
+        If list size exceeds buffer size (which is read from 
`/sys/module/spidev/parameters/bufsiz`),
+        data will be split into smaller chunks and sent in multiple operations.
+        
+        Also, `writebytes2` understands [buffer 
protocol](https://docs.python.org/3/c-api/buffer.html)
+        so it can accept numpy byte arrays for example without need to convert 
them with `tolist()` first.
+        This offers much better performance where you need to transfer frames 
to SPI-connected displays for instance.
+        
+            xfer(list of values[, speed_hz, delay_usec, bits_per_word])
+        
+        Performs an SPI transaction. Chip-select should be released and 
reactivated between blocks.
+        Delay specifies the delay in usec between blocks.
+        
+            xfer2(list of values[, speed_hz, delay_usec, bits_per_word])
+        
+        Performs an SPI transaction. Chip-select should be held active between 
blocks.
+        
+            xfer3(list of values[, speed_hz, delay_usec, bits_per_word])
+        
+        Similar to `xfer2` but accepts arbitrary large lists.
+        If list size exceeds buffer size (which is read from 
`/sys/module/spidev/parameters/bufsiz`),
+        data will be split into smaller chunks and sent in multiple operations.
+        
+            close()
+        
+        Disconnects from the SPI device.
+        
+        Changelog
+        ---------
+        
+        3.5
+        ====
+        
+        * Fixed memory leaks
+        
+        3.4
+        =====
+        
+        * Changed license to MIT
+        
+        3.0.1
+        =====
+        
+        * Fixed README.md and CHANGELOG.md formatting, hopefully
+        
+        3.0
+        ===
+        
+        * Memset fix recommended by Dougie Lawson
+        * Fixes for Kernel 3.15+ from https://github.com/chrillomat/py-spidev
+        * Fixes for Python 3/2 compatibility.
+        * Added subclassing support - 
https://github.com/doceme/py-spidev/issues/10
+        
+        2.0
+        ===
+        
+        Code sourced from 
http://elk.informatik.fh-augsburg.de/da/da-49/trees/pyap7k/lang/py-spi
+        and modified.
+        
+        Pre 2.0
+        =======
+        
+        spimodule.c originally uathored by Volker Thoms, 2009.
+        
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Operating System :: POSIX :: Linux
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Intended Audience :: Developers
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Topic :: Software Development
+Classifier: Topic :: System :: Hardware
+Classifier: Topic :: System :: Hardware :: Hardware Drivers
+Description-Content-Type: text/markdown
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/py-spidev-3.4/spidev.egg-info/SOURCES.txt 
new/spidev-3.5/spidev.egg-info/SOURCES.txt
--- old/py-spidev-3.4/spidev.egg-info/SOURCES.txt       1970-01-01 
01:00:00.000000000 +0100
+++ new/spidev-3.5/spidev.egg-info/SOURCES.txt  2020-06-02 22:07:41.000000000 
+0200
@@ -0,0 +1,11 @@
+CHANGELOG.md
+LICENSE
+MANIFEST.in
+README.md
+setup.cfg
+setup.py
+spidev_module.c
+spidev.egg-info/PKG-INFO
+spidev.egg-info/SOURCES.txt
+spidev.egg-info/dependency_links.txt
+spidev.egg-info/top_level.txt
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/py-spidev-3.4/spidev.egg-info/dependency_links.txt 
new/spidev-3.5/spidev.egg-info/dependency_links.txt
--- old/py-spidev-3.4/spidev.egg-info/dependency_links.txt      1970-01-01 
01:00:00.000000000 +0100
+++ new/spidev-3.5/spidev.egg-info/dependency_links.txt 2020-06-02 
22:07:41.000000000 +0200
@@ -0,0 +1 @@
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/py-spidev-3.4/spidev.egg-info/top_level.txt 
new/spidev-3.5/spidev.egg-info/top_level.txt
--- old/py-spidev-3.4/spidev.egg-info/top_level.txt     1970-01-01 
01:00:00.000000000 +0100
+++ new/spidev-3.5/spidev.egg-info/top_level.txt        2020-06-02 
22:07:41.000000000 +0200
@@ -0,0 +1 @@
+spidev
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/py-spidev-3.4/spidev_module.c 
new/spidev-3.5/spidev_module.c
--- old/py-spidev-3.4/spidev_module.c   2019-02-21 19:02:07.000000000 +0100
+++ new/spidev-3.5/spidev_module.c      2020-06-02 21:58:14.000000000 +0200
@@ -35,7 +35,7 @@
 #include <sys/ioctl.h>
 #include <linux/ioctl.h>
 
-#define _VERSION_ "3.4"
+#define _VERSION_ "3.5"
 #define SPIDEV_MAXPATH 4096
 
 #define BLOCK_SIZE_CONTROL_FILE "/sys/module/spidev/parameters/bufsiz"
@@ -183,7 +183,7 @@
                return NULL;
 
        seq = PySequence_Fast(obj, "expected a sequence");
-       len = PySequence_Fast_GET_SIZE(obj);
+       len = PySequence_Fast_GET_SIZE(seq);
        if (!seq || len <= 0) {
                PyErr_SetString(PyExc_TypeError, wrmsg_list0);
                return NULL;
@@ -267,8 +267,8 @@
        list = PyList_New(len);
 
        for (ii = 0; ii < len; ii++) {
-               PyObject *val = Py_BuildValue("l", (long)rxbuf[ii]);
-               PyList_SET_ITEM(list, ii, val);
+               PyObject *val = PyLong_FromLong((long)rxbuf[ii]);
+               PyList_SET_ITEM(list, ii, val);  // Steals reference, no need 
to Py_DECREF(val)
        }
 
        return list;
@@ -478,8 +478,14 @@
                return NULL;
 
        seq = PySequence_Fast(obj, "expected a sequence");
-       len = PySequence_Fast_GET_SIZE(obj);
-       if (!seq || len <= 0) {
+       if (!seq) {
+               PyErr_SetString(PyExc_TypeError, wrmsg_list0);
+               return NULL;
+       }
+
+       len = PySequence_Fast_GET_SIZE(seq);
+       if (len <= 0) {
+               Py_DECREF(seq);
                PyErr_SetString(PyExc_TypeError, wrmsg_list0);
                return NULL;
        }
@@ -487,6 +493,7 @@
        if (len > SPIDEV_MAXPATH) {
                snprintf(wrmsg_text, sizeof(wrmsg_text) - 1, wrmsg_listmax, 
SPIDEV_MAXPATH);
                PyErr_SetString(PyExc_OverflowError, wrmsg_text);
+               Py_DECREF(seq);
                return NULL;
        }
 
@@ -512,6 +519,7 @@
                                free(xferptr);
                                free(txbuf);
                                free(rxbuf);
+                               Py_DECREF(seq);
                                return NULL;
                        }
                }
@@ -530,11 +538,12 @@
        }
 
        status = ioctl(self->fd, SPI_IOC_MESSAGE(len), xferptr);
+       free(xferptr);
        if (status < 0) {
                PyErr_SetFromErrno(PyExc_IOError);
-               free(xferptr);
                free(txbuf);
                free(rxbuf);
+               Py_DECREF(seq);
                return NULL;
        }
 #else
@@ -553,6 +562,7 @@
                                PyErr_SetString(PyExc_TypeError, wrmsg_text);
                                free(txbuf);
                                free(rxbuf);
+                               Py_DECREF(seq);
                                return NULL;
                        }
                }
@@ -581,13 +591,15 @@
                PyErr_SetFromErrno(PyExc_IOError);
                free(txbuf);
                free(rxbuf);
+               Py_DECREF(seq);
                return NULL;
        }
 #endif
 
        for (ii = 0; ii < len; ii++) {
-               PyObject *val = Py_BuildValue("l", (long)rxbuf[ii]);
+               PyObject *val = PyLong_FromLong((long)rxbuf[ii]);
                PySequence_SetItem(seq, ii, val);
+               Py_DECREF(val); // PySequence_SetItem does not steal reference, 
must Py_DECREF(val)
        }
 
        // WA:
@@ -636,8 +648,14 @@
                return NULL;
 
        seq = PySequence_Fast(obj, "expected a sequence");
-       len = PySequence_Fast_GET_SIZE(obj);
-       if (!seq || len <= 0) {
+       if (!seq) {
+               PyErr_SetString(PyExc_TypeError, wrmsg_list0);
+               return NULL;
+       }
+
+       len = PySequence_Fast_GET_SIZE(seq);
+       if (len <= 0) {
+               Py_DECREF(seq);
                PyErr_SetString(PyExc_TypeError, wrmsg_list0);
                return NULL;
        }
@@ -645,6 +663,7 @@
        if (len > SPIDEV_MAXPATH) {
                snprintf(wrmsg_text, sizeof(wrmsg_text) - 1, wrmsg_listmax, 
SPIDEV_MAXPATH);
                PyErr_SetString(PyExc_OverflowError, wrmsg_text);
+               Py_DECREF(seq);
                return NULL;
        }
 
@@ -668,6 +687,7 @@
                                PyErr_SetString(PyExc_TypeError, wrmsg_text);
                                free(txbuf);
                                free(rxbuf);
+                               Py_DECREF(seq);
                                return NULL;
                        }
                }
@@ -692,12 +712,14 @@
                PyErr_SetFromErrno(PyExc_IOError);
                free(txbuf);
                free(rxbuf);
+               Py_DECREF(seq);
                return NULL;
        }
 
        for (ii = 0; ii < len; ii++) {
-               PyObject *val = Py_BuildValue("l", (long)rxbuf[ii]);
+               PyObject *val = PyLong_FromLong((long)rxbuf[ii]);
                PySequence_SetItem(seq, ii, val);
+               Py_DECREF(val); // PySequence_SetItem does not steal reference, 
must Py_DECREF(val)
        }
        // WA:
        // in CS_HIGH mode CS isnt pulled to low after transfer
@@ -844,8 +866,8 @@
                        return NULL;
                }
                for (ii = 0, jj = block_start; ii < block_size; ii++, jj++) {
-                       PyObject *val = Py_BuildValue("l", (long)rxbuf[ii]);
-                       PyTuple_SetItem(rx_tuple, jj, val);
+                       PyObject *val = PyLong_FromLong((long)rxbuf[ii]);
+                       PyTuple_SetItem(rx_tuple, jj, val);  // Steals 
reference, no need to Py_DECREF(val)
                }
 
                block_start += block_size;
@@ -980,6 +1002,7 @@
 SpiDev_set_mode(SpiDevObject *self, PyObject *val, void *closure)
 {
        uint8_t mode, tmp;
+       int ret;
 
        if (val == NULL) {
                PyErr_SetString(PyExc_TypeError,
@@ -1012,16 +1035,18 @@
        // clean and set CPHA and CPOL bits
        tmp = ( self->mode & ~(SPI_CPHA | SPI_CPOL) ) | mode ;
 
-       __spidev_set_mode(self->fd, tmp);
+       ret = __spidev_set_mode(self->fd, tmp);
 
-       self->mode = tmp;
-       return 0;
+       if (ret != -1)
+               self->mode = tmp;
+       return ret;
 }
 
 static int
 SpiDev_set_cshigh(SpiDevObject *self, PyObject *val, void *closure)
 {
        uint8_t tmp;
+       int ret;
 
        if (val == NULL) {
                PyErr_SetString(PyExc_TypeError,
@@ -1039,16 +1064,18 @@
        else
                tmp = self->mode & ~SPI_CS_HIGH;
 
-       __spidev_set_mode(self->fd, tmp);
+       ret = __spidev_set_mode(self->fd, tmp);
 
-       self->mode = tmp;
-       return 0;
+       if (ret != -1)
+               self->mode = tmp;
+       return ret;
 }
 
 static int
 SpiDev_set_lsbfirst(SpiDevObject *self, PyObject *val, void *closure)
 {
        uint8_t tmp;
+       int ret;
 
        if (val == NULL) {
                PyErr_SetString(PyExc_TypeError,
@@ -1066,16 +1093,18 @@
        else
                tmp = self->mode & ~SPI_LSB_FIRST;
 
-       __spidev_set_mode(self->fd, tmp);
+       ret = __spidev_set_mode(self->fd, tmp);
 
-       self->mode = tmp;
-       return 0;
+       if (ret != -1)
+               self->mode = tmp;
+       return ret;
 }
 
 static int
 SpiDev_set_3wire(SpiDevObject *self, PyObject *val, void *closure)
 {
        uint8_t tmp;
+       int ret;
 
        if (val == NULL) {
                PyErr_SetString(PyExc_TypeError,
@@ -1093,16 +1122,18 @@
        else
                tmp = self->mode & ~SPI_3WIRE;
 
-       __spidev_set_mode(self->fd, tmp);
+       ret = __spidev_set_mode(self->fd, tmp);
 
-       self->mode = tmp;
-       return 0;
+       if (ret != -1)
+               self->mode = tmp;
+       return ret;
 }
 
 static int
 SpiDev_set_no_cs(SpiDevObject *self, PyObject *val, void *closure)
 {
         uint8_t tmp;
+       int ret;
 
         if (val == NULL) {
                 PyErr_SetString(PyExc_TypeError,
@@ -1120,10 +1151,11 @@
         else
                 tmp = self->mode & ~SPI_NO_CS;
 
-        __spidev_set_mode(self->fd, tmp);
+        ret = __spidev_set_mode(self->fd, tmp);
 
-        self->mode = tmp;
-        return 0;
+       if (ret != -1)
+               self->mode = tmp;
+        return ret;
 }
 
 
@@ -1131,6 +1163,7 @@
 SpiDev_set_loop(SpiDevObject *self, PyObject *val, void *closure)
 {
        uint8_t tmp;
+       int ret;
 
        if (val == NULL) {
                PyErr_SetString(PyExc_TypeError,
@@ -1148,10 +1181,11 @@
        else
                tmp = self->mode & ~SPI_LOOP;
 
-       __spidev_set_mode(self->fd, tmp);
+       ret = __spidev_set_mode(self->fd, tmp);
 
-       self->mode = tmp;
-       return 0;
+       if (ret != -1)
+               self->mode = tmp;
+       return ret;
 }
 
 static PyObject *
@@ -1187,9 +1221,9 @@
                }
        }
 
-               if (bits < 8 || bits > 16) {
+               if (bits < 8 || bits > 32) {
                PyErr_SetString(PyExc_TypeError,
-                       "invalid bits_per_word (8 to 16)");
+                       "invalid bits_per_word (8 to 32)");
                return -1;
        }
 


Reply via email to