Skip to content
Merged
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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* Comparisons like `==`, `<` and `isless` between `Py`s now return `Bool` instead of `Py`.
* Removed comparisons between `Py` and `Number` (like `Py(3) < 5`).
* Removed arithmetic between `Py` and `Number` (like `Py(2) * 10`).
* Python errors no longer automatically set `sys.last_traceback` etc. when displayed from Julia.
* Removed `CONFIG.auto_sys_last_traceback`.
* Changes to `PythonCall.GC` (now more like `Base.GC`):
* `enable(true)` replaces `enable()`.
* `enable(false)` replaces `disable()`.
Expand Down
4 changes: 0 additions & 4 deletions docs/src/compat.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ Some packages require a little extra help to work nicely with PythonCall.
Some of these are "fixes" that are silently applied for you, and some are just extra
functions to bridge a gap. We aim to keep these as minimal as possible.

## Python standard library

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`.

## Julia standard library

Python objects can be serialised with the [`Serialization`](https://docs.julialang.org/en/v1/stdlib/Serialization/) stdlib.
Expand Down
6 changes: 6 additions & 0 deletions docs/src/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,9 @@ Each release of PythonCall and JuliaCall will support and require:
- The current Julia LTS version and newer, [see here](https://julialang.org/downloads/#long_term_support_release). Currently 1.10+.

Only the latest patch release within each minor version is supported.

## Can I use the Python debugger `pdb` from Julia?

Yes! If you are used to using the post-mortem debugger `pdb.pm()` in Python, then you
can instead use `pdb.post_mortem(err[1].exception)` at the Julia REPL to debug the
most recent Python error (a [`PyException`](@ref)).
6 changes: 6 additions & 0 deletions docs/src/v1-migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ between Python and Julia is explicit.
* Instead of `Py(5) * 6` use `Py(5) * Py(6)` or `pymul(Py(5), 6)`.
* Instead of `np.array([1,2,3]) < 3` use `pylt(np.array([1,2,3]), 3)`.

When a Python error is displayed in Julia, PythonCall no longer sets `sys.last_traceback`
and friends. This means that the Python post-mortem debugger `pdb.pm()` will no longer
work.

* Instead of `pdb.pm()` use `pdb.post_mortem(err[1].exception)`.

## `PythonCall.GC`

This submodule has been changed to closer mimic the `Base.GC` API.
Expand Down
1 change: 0 additions & 1 deletion src/Core/config.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@kwdef mutable struct Config
meta::String = ""
auto_sys_last_traceback::Bool = true
auto_fix_qt_plugin_path::Bool = true
end

Expand Down
11 changes: 0 additions & 11 deletions src/Core/err.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,6 @@ function _showerror(io::IO, e::PyException, bt; backtrace = true)
return
end

if CONFIG.auto_sys_last_traceback
try
sys = pyimport("sys")
sys.last_type = e.t
sys.last_value = e.v
sys.last_traceback = e.b
catch err
print(io, "<error while setting 'sys.last_traceback': $err>")
end
end

if !pyisnull(pyJuliaError) && pyissubclass(e.t, pyJuliaError)
# handle Julia exceptions specially
try
Expand Down
Loading