[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

PyPy support breaking CPython compatibility?

On Wed, Jan 31, 2018 at 7:58 AM, Etienne Robillard <tkadm30 at yandex.com> wrote:
> Hi Ned,
> Le 2018-01-30 ? 15:14, Ned Batchelder a ?crit :
>> I'm curious what you had to change for PyPy? (Unless it's a Py2/Py3 thing
>> as Chris mentions.)
> Please take a look at the changesets:
> https://bitbucket.org/tkadm30/libschevo/commits/745d1aeab5c6ee0d336790cf13d16f327e10c2f8
> https://bitbucket.org/tkadm30/libdurus/commits/875636e9b6caa840fd50ca87d69217d87fc06f43
> In short, it seems PyPy automagically adds a __weakref__ attribute to
> __slots__, causing the CPython interpreter to raise a TypeError...

I'm confused by this:

-if os.environ.get('SCHEVO_OPTIMIZE', '1') == '1':
+if os.environ.get('SCHEVO_OPTIMIZE', '1') == True:

BTW, this part you should probably consider doing differently:

-        except schevo.error.SchemaFileIOError:
+        except schevo.error.SchemaFileIOError, ex:
+            print ex

The comma version is only needed on really old versions of Python
(2.4? something like that), and won't work on Python 3. Unless support
for ancient Pythons is important to you, I recommend using the "except
type as name:" syntax, which works on 2.7 and on 3.x.

But the weakref situation is curious. Can you show a minimal test-case
for the difference? Might be something that one interpreter or the
other needs to update.