Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/pydbgp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def main(argv):
return 0
elif opt in ('-V', '--version'):
import re
kw = re.findall('\$(\w+):\s(.*?)\s\$', __revision__)
kw = re.findall(r'\$(\w+):\s(.*?)\s\$', __revision__)
sys.stderr.write("pydbgp Version %s %s %s %s %s\n"\
% ('.'.join([str(i) for i in __version__]),
kw[0][0], kw[0][1], kw[1][0], kw[1][1]))
Expand Down
35 changes: 27 additions & 8 deletions dbgp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,27 @@
modname = "_client%s%s" % (major, minor)
try:
# Try importing our fast C module.
import imp
import dbgp
info = imp.find_module(modname, dbgp.__path__)
_client = imp.load_module(modname, *info)
sys.modules["_client"] = _client
from _client import *
del sys.modules["_client"], info, _client
_client = None
if sys.version_info >= (3, 5):
import importlib.util
import importlib.machinery
spec = importlib.machinery.PathFinder.find_spec(modname, dbgp.__path__)
if spec:
_client = importlib.util.module_from_spec(spec)
spec.loader.exec_module(_client)
else:
import imp
info = imp.find_module(modname, dbgp.__path__)
_client = imp.load_module(modname, *info)

if _client:
sys.modules["_client"] = _client
from _client import *
del sys.modules["_client"], _client
if 'info' in locals(): del info
else:
raise ImportError("No module named %s" % modname)
except ImportError as ex:
#configureLogging(log, logging.INFO)
#log.exception(ex)
Expand Down Expand Up @@ -521,7 +535,12 @@ def __init__(self, verbose = _verbose):
def modules_dict(self): return sys.modules
pass

import imp
try:
import types
_new_module = types.ModuleType
except ImportError:
import imp
_new_module = imp.new_module

class h_main:
"""
Expand All @@ -532,7 +551,7 @@ class h_main:
def __init__(self, main_name='__main__'):
import __main__
self.name = main_name
self.module = imp.new_module(main_name)
self.module = _new_module(main_name)
if hasattr(__main__, '__builtins__'): # not Jython
self.module.__builtins__ = __main__.__builtins__
self.locals = self.globals = self.module.__dict__
Expand Down
11 changes: 8 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import sys
import shutil

from setuptools import setup
from distutils.core import Extension
from distutils.command.build_ext import build_ext
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext

NAME = 'komodo-python3-dbgp'

Expand Down Expand Up @@ -57,6 +56,12 @@ def build_extensions(self):
"Programming Language :: Python :: 3.1",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
],

Expand Down
34 changes: 34 additions & 0 deletions tests/test_basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import unittest
import sys
import os

# Add the current directory to sys.path so we can import dbgp
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))

class TestDBGPClient(unittest.TestCase):
def test_import(self):
try:
import dbgp.client
from dbgp.client import h_main, backendCmd
except ImportError as e:
self.fail("Failed to import dbgp.client: {0}".format(e))

def test_h_main(self):
from dbgp.client import h_main
hm = h_main()
self.assertEqual(hm.name, '__main__')
self.assertTrue(hasattr(hm, 'module'))
self.assertTrue(hasattr(hm, 'locals'))
self.assertTrue(hasattr(hm, 'globals'))

def test_backendCmd_init(self):
from dbgp.client import backendCmd, h_main
# Just test instantiation with default arguments
try:
client = backendCmd("test_key", None, [], module=h_main())
self.assertIsNotNone(client)
except Exception as e:
self.fail("Failed to instantiate backendCmd: {0}".format(e))

if __name__ == '__main__':
unittest.main()