Skip to content

Commit

Permalink
Merge branch 'main' into evaluate-expression-exception
Browse files Browse the repository at this point in the history
  • Loading branch information
lukejriddle authored Oct 10, 2024
2 parents da83c33 + 6cd4d43 commit cbaa97e
Show file tree
Hide file tree
Showing 302 changed files with 47,148 additions and 46,837 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pydevd-release-manylinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- uses: actions/setup-python@v3

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.16.2
run: python -m pip install cibuildwheel==2.21.2

- name: Remove .so files (will be rebuilt)
run: rm pydevd_attach_to_process/*.so
Expand Down
17 changes: 13 additions & 4 deletions .github/workflows/pydevd-tests-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,18 @@ jobs:
pip install psutil --no-warn-script-location
pip install ipython --no-warn-script-location
pip install untangle --no-warn-script-location
pip install "django<=4.2" --no-warn-script-location
- name: Install Python 3.x deps
if: contains(matrix.name, 'py3') && !contains(matrix.name, 'pypy') && !contains(matrix.name, 'py312') && !contains(matrix.name, 'py311')
run: |
pip install PySide2 --no-warn-script-location
pip install "numpy<2" --force --no-warn-script-location
pip install cherrypy --no-warn-script-location
pip install gevent greenlet
pip install gevent==23.9.1 greenlet
- name: Install django
if: "!contains(matrix.name, 'py38')"
run: pip install "django<=4.2" --no-warn-script-location

- name: Install Pandas
if: contains(matrix.name, 'py310') && !contains(matrix.name, 'pypy')
# The pandas Styler also requires jinja2.
Expand All @@ -112,22 +117,26 @@ jobs:
- name: Check that wheels can be built
if: contains(matrix.name, 'checkbin') && contains(matrix.name, 'ubuntu')
run: |
python -m pip install cibuildwheel==2.16.2
python -m pip install cibuildwheel==2.21.2
# Remove these .so files (will be rebuilt)
rm pydevd_attach_to_process/*.so
python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: cp310-*manylinux*x86_64 cp311-*manylinux*x86_64 cp312-*manylinux*x86_64
CIBW_BUILD_VERBOSITY: 1

- name: Rebuild .so
if: contains(matrix.name, 'checkbin') && contains(matrix.name, 'ubuntu')
run: |
pydevd_attach_to_process/linux_and_mac/compile_linux.sh
- name: Check cython unchanged
if: contains(matrix.name, 'checkbin')
env:
PYTHONPATH: .
run: |
python build_tools/build.py
python build_tools/check_no_git_modifications.py
- name: Create cython binaries
if: contains(matrix.name, 'cython')
Expand Down
7 changes: 6 additions & 1 deletion .settings/org.python.pydev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ AUTO_LINK: false
AUTO_LITERALS: true
AUTO_PAR: true
AUTO_WRITE_IMPORT_STR: true
BLACK_FORMATTER_FILE_LOCATION: ''
BLACK_FORMATTER_LOCATION_OPTION: LOCATION_SEARCH
BLACK_PARAMETERS: ''
BLANK_LINES_INNER: 1
BLANK_LINES_TOP_LEVEL: 2
Expand All @@ -18,7 +20,7 @@ DATE_FIELD_FORMAT: yyyy-MM-dd
DATE_FIELD_NAME: __updated__
DELETE_UNUSED_IMPORTS: false
ENABLE_DATE_FIELD_ACTION: false
FORMATTER_STYLE: PYDEVF
FORMATTER_STYLE: RUFF
FORMAT_BEFORE_SAVING: true
FORMAT_ONLY_CHANGED_LINES: false
FORMAT_WITH_AUTOPEP8: false
Expand All @@ -32,6 +34,9 @@ PEP8_IMPORTS: true
PYDEV_TEST_RUNNER: '2'
PYDEV_TEST_RUNNER_DEFAULT_PARAMETERS: --capture=no -vv --tb=native -n 0
PYDEV_USE_PYUNIT_VIEW: true
RUFF_FORMATTER_FILE_LOCATION: ''
RUFF_FORMATTER_LOCATION_OPTION: LOCATION_SEARCH
RUFF_PARAMETERS: ''
SAVE_ACTIONS_ONLY_ON_WORKSPACE_FILES: true
SMART_INDENT_PAR: true
SMART_LINE_MOVE: false
Expand Down
43 changes: 36 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
PyDev.Debugger
===============
# PyDev.Debugger


## New

Latest `3.x` version: the PyDev debugger now supports `sys.monitoring` which enables
really fast tracing on `Python 3.12` (so, if speed is an issue, make sure you upgrade).

The PyDev Debugger is a Python debugger which historically was created to
## Important

https://github.com/fabioz/PyDev.Debugger is the main repository
for `pydevd` and the latest versions can always be used directly in:

- [PyDev for Eclipse](http://pydev.org): Enables the usage of `pydevd` in Eclipse (Open Source).

- [Python Debugger (PyDev) for VSCode](https://marketplace.visualstudio.com/items?itemName=fabioz.vscode-pydev-python-debugger): Enables
the usage of `pydevd` in VSCode (note that while `pydevd` itself is open source, this extension is commercial
and helps in the development of the Open Source version. It has a free trial and can be used by acquiring a license for
`PyDev for VSCode` at: https://www.pydev.org/vscode/index.html).

Note that the `Python Debugger (PyDev) for VSCode` may be used as a standalane extension for debugging `Python` by
creating the proper configuration in a `launch.json` and launching it.

Alternatively, [PyDev for VSCode](https://marketplace.visualstudio.com/items?itemName=fabioz.vscode-pydev)
leverages it to offer additional features such as debugging of test cases.

## History / Support

The `PyDev Debugger` (`pydevd` for short) is a **Python debugger** which historically was created to
work with `PyDev` (in Eclipse).

Over the years (as it's open source -- EPL) it was adopted by other IDEs/companies
(so, it was integrated into PyCharm and VSCode Python through `debugpy`, which bundles `pydevd`).
(so, it was integrated into PyCharm and VSCode Python through `debugpy`, which also bundles `pydevd`).

Note that although it was adopted by other IDEs (and over the years companies of other
commercial IDEs did provide backing), by far most of the work was done without any
Expand All @@ -18,21 +40,28 @@ So, if you like using it, please consider becoming a backer of the project (this
done through the `PyDev` umbrella, so please see https://www.pydev.org/about.html
for how to contribute to the project).


## Source code / using

The sources for the PyDev.Debugger may be seen at:

https://github.com/fabioz/PyDev.Debugger

In general, the debugger backend should **NOT** be installed separately if you're using an IDE which already
bundles it (such as PyDev, PyCharm or bundled through debugpy, which is the debug adapter used in
VSCode Python and Visual Studio Python).
bundles it (such as [PyDev for Eclipse](http://pydev.org), [Python Debugger (PyDev) for VSCode](https://marketplace.visualstudio.com/items?itemName=fabioz.vscode-pydev-python-debugger),
PyCharm or the Microsoft Python VSCode Extension, which uses `debugpy`, which is another debug adapter bundling `pydevd` to be used in the Microsoft
VSCode Python Extension and Visual Studio Python).

It is however available in PyPi so that it can be installed for doing remote debugging with `pip` -- so, when
debugging a process which runs in another machine, it's possible to `pip install pydevd` and in the code use
`pydevd.settrace(host='10.1.1.1')` to connect the debugger backend to the debugger UI running in the IDE
`pydevd.settrace(host="10.1.1.1")` (in PyDev) or `pydevd.settrace(host="10.1.1.1", protocol="dap")` (in PyDev for VSCode)
to connect the debugger backend to the debugger UI running in the IDE
(whereas previously the sources had to be manually copied from the IDE installation).

For instructions on how to `Remote Debug` with `PyDev`, see: https://www.pydev.org/manual_adv_remote_debugger.html

For instructions on how to `Remote Debug` with `PyDev for VSCode`, see: https://marketplace.visualstudio.com/items?itemName=fabioz.vscode-pydev-python-debugger

`pydevd` is compatible with Python 3.8 onwards and is tested both with CPython as well as PyPy.

For `Python 3.3 to 3.7` please keep using `pydevd 2.10.0`.
Expand Down
40 changes: 19 additions & 21 deletions _pydev_bundle/_pydev_calltip_util.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
'''
"""
License: Apache 2.0
Author: Yuli Fitterman
'''
"""
import types

from _pydevd_bundle.pydevd_constants import IS_JYTHON

try:
import inspect
except:
import traceback;
import traceback

traceback.print_exc() # Ok, no inspect available (search will not work)

Expand All @@ -18,7 +18,7 @@

def is_bound_method(obj):
if isinstance(obj, types.MethodType):
return getattr(obj, '__self__', getattr(obj, 'im_self', None)) is not None
return getattr(obj, "__self__", getattr(obj, "im_self", None)) is not None
else:
return False

Expand All @@ -28,7 +28,7 @@ def get_class_name(instance):


def get_bound_class_name(obj):
my_self = getattr(obj, '__self__', getattr(obj, 'im_self', None))
my_self = getattr(obj, "__self__", getattr(obj, "im_self", None))
if my_self is None:
return None
return get_class_name(my_self)
Expand All @@ -40,8 +40,8 @@ def get_description(obj):
except:
ob_call = None

if isinstance(obj, type) or type(obj).__name__ == 'classobj':
fob = getattr(obj, '__init__', lambda: None)
if isinstance(obj, type) or type(obj).__name__ == "classobj":
fob = getattr(obj, "__init__", lambda: None)
if not isinstance(fob, (types.FunctionType, types.MethodType)):
fob = obj
elif is_bound_method(ob_call):
Expand All @@ -55,16 +55,16 @@ def get_description(obj):
if isinstance(fob, (types.FunctionType, types.MethodType)):
spec_info = inspect.getfullargspec(fob)
argspec = inspect.formatargspec(*spec_info)
fn_name = getattr(fob, '__name__', None)
if isinstance(obj, type) or type(obj).__name__ == 'classobj':
fn_name = getattr(fob, "__name__", None)
if isinstance(obj, type) or type(obj).__name__ == "classobj":
fn_name = "__init__"
fn_class = getattr(obj, "__name__", "UnknownClass")
elif is_bound_method(obj) or is_bound_method(ob_call):
fn_class = get_bound_class_name(obj) or "UnknownClass"

else:
fn_name = getattr(fob, '__name__', None)
fn_self = getattr(fob, '__self__', None)
fn_name = getattr(fob, "__name__", None)
fn_self = getattr(fob, "__self__", None)
if fn_self is not None and not isinstance(fn_self, types.ModuleType):
fn_class = get_class_name(fn_self)

Expand All @@ -77,7 +77,7 @@ def create_method_stub(fn_name, fn_class, argspec, doc_string):
doc_string = "" if doc_string is None else doc_string
fn_stub = create_function_stub(fn_name, argspec, doc_string, indent=1 if fn_class else 0)
if fn_class:
expr = fn_class if fn_name == '__init__' else fn_class + '().' + fn_name
expr = fn_class if fn_name == "__init__" else fn_class + "()." + fn_name
return create_class_stub(fn_class, fn_stub) + "\n" + expr
else:
expr = fn_name
Expand All @@ -87,10 +87,10 @@ def create_method_stub(fn_name, fn_class, argspec, doc_string):
restored_signature, _ = signature_from_docstring(doc_string, fn_name)
if restored_signature:
return create_method_stub(fn_name, fn_class, restored_signature, doc_string)
return create_function_stub('unknown', '(*args, **kwargs)', doc_string) + '\nunknown'
return create_function_stub("unknown", "(*args, **kwargs)", doc_string) + "\nunknown"

else:
return ''
return ""


def get_docstring(obj):
Expand All @@ -105,21 +105,20 @@ def get_docstring(obj):
from _pydev_bundle import _pydev_jy_imports_tipper

is_method, infos = _pydev_jy_imports_tipper.ismethod(obj)
ret = ''
ret = ""
if is_method:
for info in infos:
ret += info.get_as_doc()
return ret

else:

doc = inspect.getdoc(obj)
if doc is not None:
return doc
except:
pass
else:
return ''
return ""
try:
# if no attempt succeeded, try to return repr()...
return repr(obj)
Expand All @@ -129,17 +128,16 @@ def get_docstring(obj):
return str(obj.__class__)
except:
# if all fails, go to an empty string
return ''
return ""


def create_class_stub(class_name, contents):
return "class %s(object):\n%s" % (class_name, contents)


def create_function_stub(fn_name, fn_argspec, fn_docstring, indent=0):

def shift_right(string, prefix):
return ''.join(prefix + line for line in string.splitlines(True))
return "".join(prefix + line for line in string.splitlines(True))

fn_docstring = shift_right(inspect.cleandoc(fn_docstring), " " * (indent + 1))
ret = '''
Expand All @@ -148,7 +146,7 @@ def %s%s:
pass
''' % (fn_name, fn_argspec, fn_docstring)
ret = ret[1:] # remove first /n
ret = ret.replace('\t', " ")
ret = ret.replace("\t", " ")
if indent:
prefix = " " * indent
ret = shift_right(ret, prefix)
Expand Down
Loading

0 comments on commit cbaa97e

Please sign in to comment.