Skip to content

Commit 58c0317

Browse files
author
Christopher Rowley
committed
Merge remote-tracking branch 'origin/v1' into remove-unsafe-api
2 parents 9d0be77 + 8161918 commit 58c0317

6 files changed

Lines changed: 14 additions & 16 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* Removed arithmetic between `Py` and `Number` (like `Py(2) * 10`).
99
* Removed unsafe API: `getptr`, `pycopy!`, `pyisnull`, `pynew`, `PyNULL`, `unsafe_pynext`.
1010
A `Py` is now always a valid, fixed, non-NULL Python object in the documented API.
11+
* Python errors no longer automatically set `sys.last_traceback` etc. when displayed from Julia.
12+
* Removed `CONFIG.auto_sys_last_traceback`.
1113
* Changes to `PythonCall.GC` (now more like `Base.GC`):
1214
* `enable(true)` replaces `enable()`.
1315
* `enable(false)` replaces `disable()`.

docs/src/compat.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ Some packages require a little extra help to work nicely with PythonCall.
55
Some of these are "fixes" that are silently applied for you, and some are just extra
66
functions to bridge a gap. We aim to keep these as minimal as possible.
77

8-
## Python standard library
9-
10-
Whenever a Python exception is displayed by Julia, `sys.last_traceback` and friends are set. This allows the post-mortem debugger `pdb.pm()` to work. Disable by setting `PythonCall.CONFIG.auto_sys_last_traceback = false`.
11-
128
## Julia standard library
139

1410
Python objects can be serialised with the [`Serialization`](https://docs.julialang.org/en/v1/stdlib/Serialization/) stdlib.

docs/src/faq.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,9 @@ Each release of PythonCall and JuliaCall will support and require:
116116
- The current Julia LTS version and newer, [see here](https://julialang.org/downloads/#long_term_support_release). Currently 1.10+.
117117

118118
Only the latest patch release within each minor version is supported.
119+
120+
## Can I use the Python debugger `pdb` from Julia?
121+
122+
Yes! If you are used to using the post-mortem debugger `pdb.pm()` in Python, then you
123+
can instead use `pdb.post_mortem(err[1].exception)` at the Julia REPL to debug the
124+
most recent Python error (a [`PyException`](@ref)).

docs/src/v1-migration-guide.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ end
5959
* Instead of `PythonCall.pycopy!(x, y)` use `x[] = y`.
6060
* Instead of `PythonCall.unsafe_pynext(x)` (and check for `pyisnull`) use `pynext(x, nothing)` (and check for `nothing`).
6161

62+
When a Python error is displayed in Julia, PythonCall no longer sets `sys.last_traceback`
63+
and friends. This means that the Python post-mortem debugger `pdb.pm()` will no longer
64+
work.
65+
66+
* Instead of `pdb.pm()` use `pdb.post_mortem(err[1].exception)`.
67+
6268
## `PythonCall.GC`
6369

6470
This submodule has been changed to closer mimic the `Base.GC` API.

src/Core/config.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
@kwdef mutable struct Config
22
meta::String = ""
3-
auto_sys_last_traceback::Bool = true
43
auto_fix_qt_plugin_path::Bool = true
54
end
65

src/Core/err.jl

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,6 @@ function _showerror(io::IO, e::PyException, bt; backtrace = true)
105105
return
106106
end
107107

108-
if CONFIG.auto_sys_last_traceback
109-
try
110-
sys = pyimport("sys")
111-
sys.last_type = e.t
112-
sys.last_value = e.v
113-
sys.last_traceback = e.b
114-
catch err
115-
print(io, "<error while setting 'sys.last_traceback': $err>")
116-
end
117-
end
118-
119108
if !pyisnull(pyJuliaError) && pyissubclass(e.t, pyJuliaError)
120109
# handle Julia exceptions specially
121110
try

0 commit comments

Comments
 (0)