Skip to content

Commit e855ca6

Browse files
author
Christopher Rowley
committed
remove auto-sys-last-traceback functionality
1 parent 8f3b5ab commit e855ca6

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
@@ -6,6 +6,8 @@
66
* Comparisons like `==`, `<` and `isless` between `Py`s now return `Bool` instead of `Py`.
77
* Removed comparisons between `Py` and `Number` (like `Py(3) < 5`).
88
* Removed arithmetic between `Py` and `Number` (like `Py(2) * 10`).
9+
* Python errors no longer automatically set `sys.last_traceback` etc. when displayed from Julia.
10+
* Removed `CONFIG.auto_sys_last_traceback`.
911
* Changes to `PythonCall.GC` (now more like `Base.GC`):
1012
* `enable(true)` replaces `enable()`.
1113
* `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
@@ -24,6 +24,12 @@ between Python and Julia is explicit.
2424
* Instead of `Py(5) * 6` use `Py(5) * Py(6)` or `pymul(Py(5), 6)`.
2525
* Instead of `np.array([1,2,3]) < 3` use `pylt(np.array([1,2,3]), 3)`.
2626

27+
When a Python error is displayed in Julia, PythonCall no longer sets `sys.last_traceback`
28+
and friends. This means that the Python post-mortem debugger `pdb.pm()` will no longer
29+
work.
30+
31+
* Instead of `pdb.pm()` use `pdb.post_mortem(err[1].exception)`.
32+
2733
## `PythonCall.GC`
2834

2935
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)