Skip to content

Commit

Permalink
Remove more traces of Python2 (GH-280)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-detiste authored Feb 15, 2025
1 parent 0d382c4 commit 04696c5
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 36 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ setter function implementations for a ``LuaRuntime``:
... raise AttributeError(
... 'not allowed to write attribute "%s"' % attr_name)
>>> class X(object):
>>> class X:
... yes = 123
... put = 'abc'
... noway = 2.1
Expand Down
2 changes: 0 additions & 2 deletions lupa/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import absolute_import

from contextlib import contextmanager as _contextmanager

# Find the implementation with the latest Lua version available.
Expand Down
2 changes: 0 additions & 2 deletions lupa/_lupa.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
A fast Python wrapper around Lua and LuaJIT2.
"""

from __future__ import absolute_import

cimport cython

from libc.string cimport strlen, strchr
Expand Down
2 changes: 0 additions & 2 deletions lupa/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import absolute_import

import unittest
import doctest
import os
Expand Down
47 changes: 20 additions & 27 deletions lupa/tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def _next(o):
return o.next()


class SetupLuaRuntimeMixin(object):
class SetupLuaRuntimeMixin:
lua_runtime_kwargs = {}

def setUp(self):
Expand Down Expand Up @@ -262,10 +262,7 @@ def test_none(self):

def test_pybuiltins(self):
function = self.lua.eval('function() return python.builtins end')
try:
import __builtin__ as builtins
except ImportError:
import builtins
import builtins
self.assertEqual(builtins, function())

def test_pybuiltins_disabled(self):
Expand All @@ -290,7 +287,7 @@ def test_call_str_py(self):

def test_call_str_class(self):
called = [False]
class test(object):
class test:
def __str__(self):
called[0] = True
return 'STR!!'
Expand Down Expand Up @@ -837,14 +834,14 @@ def test_pysetitem(self):

def test_pygetattr(self):
lua_func = self.lua.eval('function(x) return x.ATTR end')
class test(object):
class test:
def __init__(self):
self.ATTR = 5
self.assertEqual(test().ATTR, lua_func(test()))

def test_pysetattr(self):
lua_func = self.lua.eval('function(x) x.ATTR = 123 end')
class test(object):
class test:
def __init__(self):
self.ATTR = 5
t = test()
Expand Down Expand Up @@ -943,7 +940,7 @@ def attr_filter(obj, name, setting):

lua = self.lupa.LuaRuntime(attribute_filter=attr_filter)
function = lua.eval('function(obj) return obj.__name__ end')
class X(object):
class X:
a = 0
a1 = 1
_a = 2
Expand Down Expand Up @@ -1049,14 +1046,14 @@ def test_pysetitem(self):

def test_pygetattr(self):
lua_func = self.lua.eval('function(x) return x.ATTR end')
class test(object):
class test:
def __init__(self):
self.ATTR = 5
self.assertEqual(test().ATTR, lua_func(test()))

def test_pysetattr(self):
lua_func = self.lua.eval('function(x) x.ATTR = 123 end')
class test(object):
class test:
def __init__(self):
self.ATTR = 5
t = test()
Expand All @@ -1078,7 +1075,7 @@ def test_call_str_py(self):

def test_call_str_class(self):
called = [False]
class test(object):
class test:
def __str__(self):
called[0] = True
return 'STR!!'
Expand All @@ -1100,13 +1097,13 @@ def tearDown(self):
self.lua = None
gc.collect()

class X(object):
class X:
a = 0
a1 = 1
_a = 2
__a = 3

class Y(object):
class Y:
a = 0
a1 = 1
_a = 2
Expand Down Expand Up @@ -1282,7 +1279,7 @@ def test_pyobject_wrapping_callable(self):
lua_type = self.lua.eval('type')
lua_get_call = self.lua.eval('function(obj) return getmetatable(obj).__call end')

class Callable(object):
class Callable:
def __call__(self): pass
def __getitem__(self, item): pass

Expand All @@ -1293,7 +1290,7 @@ def test_pyobject_wrapping_getitem(self):
lua_type = self.lua.eval('type')
lua_get_index = self.lua.eval('function(obj) return getmetatable(obj).__index end')

class GetItem(object):
class GetItem:
def __getitem__(self, item): pass

self.assertEqual('userdata', lua_type(GetItem()))
Expand All @@ -1303,7 +1300,7 @@ def test_pyobject_wrapping_getattr(self):
lua_type = self.lua.eval('type')
lua_get_index = self.lua.eval('function(obj) return getmetatable(obj).__index end')

class GetAttr(object):
class GetAttr:
pass

self.assertEqual('userdata', lua_type(GetAttr()))
Expand Down Expand Up @@ -2234,7 +2231,7 @@ def setUp(self):

self.lua = self.lupa.LuaRuntime(unpack_returned_tuples=True)

class C(object):
class C:
def __init__(self, x):
self.x = int(x)

Expand Down Expand Up @@ -2364,19 +2361,19 @@ def func_3(x, y, z='default'):
return ("x=%s, y=%s, z=%s" % (x, y, z))


class MyCls_1(object):
class MyCls_1:
@lupa.unpacks_lua_table_method
def meth(self, x):
return ("x=%s" % (x,))


class MyCls_2(object):
class MyCls_2:
@lupa.unpacks_lua_table_method
def meth(self, x, y):
return ("x=%s, y=%s" % (x, y))


class MyCls_3(object):
class MyCls_3:
@lupa.unpacks_lua_table_method
def meth(self, x, y, z='default'):
return ("x=%s, y=%s, z=%s" % (x, y, z))
Expand Down Expand Up @@ -2520,11 +2517,7 @@ class NoEncodingMethodKwargsDecoratorTest(MethodKwargsDecoratorTest):
################################################################################
# tests for the FastRLock implementation

try:
from thread import start_new_thread, get_ident
except ImportError:
# Python 3?
from _thread import start_new_thread, get_ident
from _thread import start_new_thread, get_ident


def _wait():
Expand Down Expand Up @@ -2552,7 +2545,7 @@ def setUp(self):
def tearDown(self):
gc.collect()

class Bunch(object):
class Bunch:
"""
A bunch of threads.
"""
Expand Down
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import absolute_import

import glob
import os
import os.path
Expand Down

0 comments on commit 04696c5

Please sign in to comment.