Skip to content

Commit d94358a

Browse files
committed
Update cython, other minors
1 parent 6d41b24 commit d94358a

File tree

12 files changed

+8806
-10959
lines changed

12 files changed

+8806
-10959
lines changed

.github/workflows/pydevd-tests-python.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jobs:
8181
os: ubuntu-latest
8282
PYDEVD_USE_CYTHON: YES
8383
- name: "windows-py314-cython"
84-
python: "3.14-dev"
84+
python: "3.14"
8585
os: windows-latest
8686
PYDEVD_USE_CYTHON: YES
8787

_pydevd_bundle/pydevd_cython.c

Lines changed: 4575 additions & 5943 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

_pydevd_bundle/pydevd_net_command.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ def __init__(self, cmd_id, seq, text, is_json=False):
7777
as_dict["pydevd_cmd_id"] = cmd_id
7878
as_dict["seq"] = seq
7979
self.as_dict = as_dict
80-
text = json.dumps(as_dict, default=str)
80+
try:
81+
text = json.dumps(as_dict)
82+
except TypeError:
83+
text = json.dumps(as_dict, default=str)
8184

8285
assert isinstance(text, str)
8386

_pydevd_sys_monitoring/_pydevd_sys_monitoring_cython.c

Lines changed: 4121 additions & 4990 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build_tools/pydevd_release_process.txt

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,34 +56,58 @@ pip install -U "setuptools>=0.9"
5656
pip install -U "pip>=1.4" "wheel>=0.21" twine
5757
deactivate
5858

59-
conda create -y -f -n py312_64 python=3.11 -c conda-forge
59+
conda create -y -f -n py312_64 python=3.12 -c conda-forge
6060
activate py312_64
6161
pip install cython
6262
pip install "django>=1.9"
6363
pip install -U "setuptools>=0.9"
6464
pip install -U "pip>=1.4" "wheel>=0.21" twine
6565
deactivate
6666

67+
conda create -y -f -n py313_64 python=3.13 -c conda-forge
68+
activate py313_64
69+
pip install cython
70+
pip install "django>=1.9"
71+
pip install -U "setuptools>=0.9"
72+
pip install -U "pip>=1.4" "wheel>=0.21" twine
73+
deactivate
74+
75+
conda create -y -f -n py314_64 python=3.14 -c conda-forge
76+
activate py314_64
77+
pip install cython
78+
pip install "django>=1.9"
79+
pip install -U "setuptools>=0.9"
80+
pip install -U "pip>=1.4" "wheel>=0.21" twine
81+
deactivate
82+
6783
### UPDATE CYTHON
6884

6985
activate py38_64
70-
pip install cython==3.0.8
86+
pip install cython --upgrade
7187
deactivate
7288

7389
activate py39_64
74-
pip install cython==3.0.8
90+
pip install cython --upgrade
7591
deactivate
7692

7793
activate py310_64
78-
pip install cython==3.0.8
94+
pip install cython --upgrade
7995
deactivate
8096

8197
activate py311_64
82-
pip install cython==3.0.8
98+
pip install cython --upgrade
8399
deactivate
84100

85101
activate py312_64
86-
pip install cython==3.0.8
102+
pip install cython --upgrade
103+
deactivate
104+
105+
activate py313_64
106+
pip install cython --upgrade
107+
deactivate
108+
109+
activate py314_64
110+
pip install cython --upgrade
87111
deactivate
88112

89113
Regenerate the .pyx and .c

pydevd.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
PYDEVD_IPYTHON_COMPATIBLE_DEBUGGING,
9494
PYDEVD_IPYTHON_CONTEXT,
9595
PYDEVD_USE_SYS_MONITORING,
96+
IS_PY314_OR_GREATER,
9697
)
9798
from _pydevd_bundle.pydevd_defaults import PydevdCustomization # Note: import alias used on pydev_monkey.
9899
from _pydevd_bundle.pydevd_custom_frames import CustomFramesContainer, custom_frames_container_init
@@ -724,6 +725,8 @@ def __init__(self, set_as_global=True):
724725

725726
self._local_thread_trace_func = threading.local()
726727

728+
self._client_socket = None
729+
727730
self._server_socket_ready_event = ThreadingEvent()
728731
self._server_socket_name = None
729732

@@ -1287,6 +1290,16 @@ def in_project_scope(self, frame, absolute_filename=None):
12871290
if file_type == self.PYDEV_FILE:
12881291
cache[cache_key] = False
12891292

1293+
elif IS_PY314_OR_GREATER and frame.f_code.co_name == "__annotate__":
1294+
# Special handling for __annotate__ functions (PEP 649 in Python 3.14+).
1295+
# These are compiler-generated functions that can raise NotImplementedError
1296+
# when called with unsupported format arguments by inspect.call_annotate_function.
1297+
# They should be treated as library code to avoid false positives in exception handling.
1298+
# Note: PEP 649 reserves the __annotate__ name for compiler-generated functions,
1299+
# so user-defined functions with this name are discouraged and will also be treated
1300+
# as library code to maintain consistency with the language design.
1301+
cache[cache_key] = False
1302+
12901303
elif absolute_filename == "<string>":
12911304
# Special handling for '<string>'
12921305
if file_type == self.LIB_FILE:
@@ -1501,6 +1514,7 @@ def initialize_network(self, sock, terminate_on_socket_close=True):
15011514
def connect(self, host, port):
15021515
if host:
15031516
s = start_client(host, port)
1517+
self._client_socket = s
15041518
else:
15051519
s = start_server(port)
15061520

@@ -2547,6 +2561,10 @@ def dispose_and_kill_all_pydevd_threads(self, wait=True, timeout=0.5):
25472561
except:
25482562
pass
25492563
finally:
2564+
if self._client_socket:
2565+
self._client_socket.close()
2566+
self._client_socket = None
2567+
25502568
pydev_log.debug("PyDB.dispose_and_kill_all_pydevd_threads: finished")
25512569

25522570
def prepare_to_run(self):
@@ -2935,6 +2953,7 @@ def settrace(
29352953
client_access_token=None,
29362954
notify_stdin=True,
29372955
protocol=None,
2956+
ppid=0,
29382957
**kwargs,
29392958
):
29402959
"""Sets the tracing function with the pydev debug function and initializes needed facilities.
@@ -2994,6 +3013,11 @@ def settrace(
29943013
When using in Eclipse the protocol should not be passed, but when used in VSCode
29953014
or some other IDE/editor that accepts the Debug Adapter Protocol then 'dap' should
29963015
be passed.
3016+
3017+
:param ppid:
3018+
Override the parent process id (PPID) for the current debugging session. This PPID is
3019+
reported to the debug client (IDE) and can be used to act like a child process of an
3020+
existing debugged process without being a child process.
29973021
"""
29983022
if protocol and protocol.lower() == "dap":
29993023
pydevd_defaults.PydevdCustomization.DEFAULT_PROTOCOL = pydevd_constants.HTTP_JSON_PROTOCOL
@@ -3022,6 +3046,7 @@ def settrace(
30223046
client_access_token,
30233047
__setup_holder__=__setup_holder__,
30243048
notify_stdin=notify_stdin,
3049+
ppid=ppid,
30253050
)
30263051

30273052

@@ -3045,6 +3070,7 @@ def _locked_settrace(
30453070
client_access_token,
30463071
__setup_holder__,
30473072
notify_stdin,
3073+
ppid,
30483074
):
30493075
if patch_multiprocessing:
30503076
try:
@@ -3076,6 +3102,7 @@ def _locked_settrace(
30763102
"port": int(port),
30773103
"multiprocess": patch_multiprocessing,
30783104
"skip-notify-stdin": not notify_stdin,
3105+
pydevd_constants.ARGUMENT_PPID: ppid,
30793106
}
30803107
SetupHolder.setup = setup
30813108

pydevd_attach_to_process/add_code_to_python_process.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ def run_python_code_linux(pid, python_code, connect_debugger_tracing=False, show
467467
cmd.extend(
468468
[
469469
"--eval-command='call (void*)dlopen(\"%s\", 2)'" % target_dll,
470+
"--eval-command='call (char*)dlerror()'",
470471
"--eval-command='sharedlibrary %s'" % target_dll_name,
471472
"--eval-command='call (int)DoAttach(%s, \"%s\", %s)'" % (is_debug, python_code, show_debug_info),
472473
]

pydevd_attach_to_process/linux_and_mac/compile_linux.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ ARCH="$(uname -m)"
44
case $ARCH in
55
i*86) SUFFIX=x86;;
66
x86_64*) SUFFIX=amd64;;
7-
*) echo >&2 "unsupported: $ARCH"; exit 1;;
7+
*) echo >&2 "unsupported: $ARCH, this script may not work";;
88
esac
99

1010
SRC="$(dirname "$0")/.."
11-
g++ -std=c++11 -shared -fPIC -O2 -D_FORTIFY_SOURCE=2 -nostartfiles --stack-protector-strong $SRC/linux_and_mac/attach.cpp -o $SRC/attach_linux_$SUFFIX.so
11+
g++ -std=c++11 -shared -fPIC -O2 -D_FORTIFY_SOURCE=2 -nostartfiles -fstack-protector-strong $SRC/linux_and_mac/attach.cpp -o $SRC/attach_linux_$SUFFIX.so

pydevd_attach_to_process/windows/compile_windows.bat

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,29 @@ setlocal
1010

1111
call "%VSDIR%\VC\Auxiliary\Build\vcvarsall.bat" x86 -vcvars_spectre_libs=spectre
1212

13-
cl -DUNICODE -D_UNICODE /EHsc /Zi /O1 /W3 /LD /MD /Qspectre attach.cpp /link /PROFILE /GUARD:CF /CETCOMPAT /out:attach_x86.dll
13+
cl -DUNICODE -D_UNICODE /EHsc /Zi /O1 /W3 /LD /MD /GL /Qspectre attach.cpp /link /LTCG /PROFILE /GUARD:CF /CETCOMPAT /out:attach_x86.dll
1414
copy attach_x86.dll ..\attach_x86.dll /Y
1515
copy attach_x86.pdb ..\attach_x86.pdb /Y
1616

17-
cl -DUNICODE -D_UNICODE /EHsc /Zi /O1 /W3 /LD /MD /D BITS_32 /Qspectre run_code_on_dllmain.cpp /link /PROFILE /GUARD:CF /CETCOMPAT /out:run_code_on_dllmain_x86.dll
17+
cl -DUNICODE -D_UNICODE /EHsc /Zi /O1 /W3 /LD /MD /GL /D BITS_32 /Qspectre run_code_on_dllmain.cpp /link /LTCG /PROFILE /GUARD:CF /CETCOMPAT /out:run_code_on_dllmain_x86.dll
1818
copy run_code_on_dllmain_x86.dll ..\run_code_on_dllmain_x86.dll /Y
1919
copy run_code_on_dllmain_x86.pdb ..\run_code_on_dllmain_x86.pdb /Y
2020

21-
cl /EHsc /Zi /O1 /W3 /Qspectre inject_dll.cpp /link /PROFILE /GUARD:CF /CETCOMPAT /out:inject_dll_x86.exe
21+
cl /EHsc /Zi /O1 /W3 /GL /Qspectre inject_dll.cpp /link /LTCG /PROFILE /GUARD:CF /CETCOMPAT /out:inject_dll_x86.exe
2222
copy inject_dll_x86.exe ..\inject_dll_x86.exe /Y
2323
copy inject_dll_x86.pdb ..\inject_dll_x86.pdb /Y
2424

2525
call "%VSDIR%\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64 -vcvars_spectre_libs=spectre
2626

27-
cl -DUNICODE -D_UNICODE /EHsc /Zi /O1 /W3 /LD /MD /Qspectre attach.cpp /link /PROFILE /GUARD:CF /CETCOMPAT /out:attach_amd64.dll
27+
cl -DUNICODE -D_UNICODE /EHsc /Zi /O1 /W3 /LD /MD /GL /Qspectre attach.cpp /link /LTCG /PROFILE /GUARD:CF /CETCOMPAT /out:attach_amd64.dll
2828
copy attach_amd64.dll ..\attach_amd64.dll /Y
2929
copy attach_amd64.pdb ..\attach_amd64.pdb /Y
3030

31-
cl -DUNICODE -D_UNICODE /EHsc /Zi /O1 /W3 /LD /MD /D BITS_64 /Qspectre run_code_on_dllmain.cpp /link /PROFILE /GUARD:CF /CETCOMPAT /out:run_code_on_dllmain_amd64.dll
31+
cl -DUNICODE -D_UNICODE /EHsc /Zi /O1 /W3 /LD /MD /GL /D BITS_64 /Qspectre run_code_on_dllmain.cpp /link /LTCG /PROFILE /GUARD:CF /CETCOMPAT /out:run_code_on_dllmain_amd64.dll
3232
copy run_code_on_dllmain_amd64.dll ..\run_code_on_dllmain_amd64.dll /Y
3333
copy run_code_on_dllmain_amd64.pdb ..\run_code_on_dllmain_amd64.pdb /Y
3434

35-
cl /EHsc /Zi /O1 /W3 /Qspectre inject_dll.cpp /link /PROFILE /GUARD:CF /CETCOMPAT /out:inject_dll_amd64.exe
35+
cl /EHsc /Zi /O1 /W3 /GL /Qspectre inject_dll.cpp /link /LTCG /PROFILE /GUARD:CF /CETCOMPAT /out:inject_dll_amd64.exe
3636
copy inject_dll_amd64.exe ..\inject_dll_amd64.exe /Y
3737
copy inject_dll_amd64.pdb ..\inject_dll_amd64.pdb /Y
3838

pydevd_file_utils.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -965,17 +965,14 @@ def get_abs_path_real_path_and_base_from_frame(frame, NORM_PATHS_AND_BASE_CONTAI
965965

966966

967967
def get_fullname(mod_name):
968-
import pkgutil
969-
970968
try:
971-
loader = pkgutil.get_loader(mod_name)
972-
except:
973-
return None
974-
if loader is not None:
975-
for attr in ("get_filename", "_get_filename"):
976-
meth = getattr(loader, attr, None)
977-
if meth is not None:
978-
return meth(mod_name)
969+
import importlib.util
970+
971+
spec = importlib.util.find_spec(mod_name)
972+
if spec is not None and spec.origin is not None and spec.has_location:
973+
return spec.origin
974+
except (ImportError, ModuleNotFoundError, ValueError):
975+
pass
979976
return None
980977

981978

0 commit comments

Comments
 (0)