Comments (4)
Here's a good reproducer to ensure your changes are working (on Linux):
(make install
is required to get pkgconfig
working for all the dependencies).
$ pip install git+https://github.com/python-pillow/Pillow@d879f39
$ pip install matplotlib
$ python
>>> import matplotlib
>>> matplotlib.use("tkagg")
>>> from matplotlib import pyplot as plt
>>> plt.plot([1,2], [3,4])
[<matplotlib.lines.Line2D object at 0x7fd3f2be8050>]
>>> plt.show(block=False)
>>>
If working, a window should appear with a plot in it, and it should respond to mouse events etc. It seems that on CPython main, this is broken, but works with PYTHON_BASIC_REPL=1
set.
Cc: @tacaswell, do I have this right? IIUC this works due to Tkinter's built-in use of PyOS_InputHook, matplotlib itself doesn't touch it.
EDIT: See a simpler reproducer below
from cpython.
With #119843 (currently), this fails with:
>>> Fatal Python error: _PyThreadState_Attach: non-NULL old thread state
Python runtime state: initialized
Current thread 0x00007fad7b63c740 (most recent call first):
File "/home/mdboom/py/lib/python3.14/_pyrepl/reader.py", line 713 in call_PyOS_InputHook
File "/home/mdboom/py/lib/python3.14/_pyrepl/reader.py", line 648 in handle1
File "/home/mdboom/py/lib/python3.14/_pyrepl/reader.py", line 692 in readline
File "/home/mdboom/py/lib/python3.14/_pyrepl/readline.py", line 376 in multiline_input
File "/home/mdboom/py/lib/python3.14/_pyrepl/simple_interact.py", line 176 in run_multiline_interactive_console
File "/home/mdboom/py/lib/python3.14/_pyrepl/__main__.py", line 48 in interactive_console
File "/home/mdboom/py/lib/python3.14/_pyrepl/__main__.py", line 51 in <module>
File "<frozen runpy>", line 88 in _run_code
File "<frozen runpy>", line 198 in _run_module_as_main
Extension modules: numpy.core._multiarray_umath, numpy.core._multiarray_tests, numpy.linalg._umath_linalg, numpy.fft._pocketfft_internal, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator, PIL._imaging, kiwisolver._cext, PIL._imagingmath, PIL._imagingtk (total: 17)
[1] 3965 IOT instruction python
from cpython.
Here's a much easier reproducer with no external dependencies:
from tkinter import *
root = Tk()
w = Label(root, text='Foo')
w.pack()
Current behavior I'm seeing:
CPython main: No window
CPython main / PYTHON_BASIC_REPL=1: Window is displayed, updated automatically with each line of entry (matches 3.12)
#119843: Fatal Python error: _PyThreadState_Attach: non-NULL old thread state
#119843 / PYTHON_BASIC_REPL=1: Window is displayed, updated automatically with each line of entry (matches 3.12)
from cpython.
@mdboom Correct. PyQt, wxpython, and the gtk bindings all provide their own verision of PyOS_InputHook
as well and mpl provides one for macOSX.
To be 100% sure the event loop is running as expected also add a "print on click" callback:
from tkinter import *
root = Tk()
b = Button(root, text='bar', command=lambda: print('bob'))
w = Label(root, text='Foo')
b.pack()
w.pack()
from cpython.
Related Issues (20)
- lexer handles raw string escapes differently than documentation HOT 1
- `PYTHON_BASIC_REPL` is not currently tested
- argparse.ArgumentParser.parses_args does not honor exit_on_error=False when given unrecognized arguments HOT 5
- zip: Support for external attributes in zipinfo
- Winreg makes persistent changes somewhere, but not to the Windows registry HOT 8
- Improve `_xxtestfuzz/README.rst`
- Improve the repr of partialmethod HOT 1
- Lots of new compiler warnings: `unknown warning option '-Wtrampolines' [-Wunknown-warning-option]` HOT 7
- Add __get__ to the partial object HOT 8
- Soft-deprecate `sys.api_version` and the C API's `PYTHON_API_VERSION` HOT 1
- `any()` and generator behavior should be documented HOT 3
- Include lastResort in logging HOWTO flow chart
- Add assertFloatsAreIdentical/assertComplexAreIdentical to unittest (or kwarg to assertEqual)? HOT 1
- -Wimplicit-fallthrough generating warnings HOT 9
- Add footer to github issues template like in xonsh shell HOT 4
- AIX build breaks with "field 'dtoa' has incomplete type"
- zsh: segmentation fault python src/toolkit/app.py HOT 10
- PGO build on Windows: test_datetime crashs with: Windows fatal exception: access violation
- JIT 3.13 job: test_logging: qemu_plugin_vcpu_init_hook: assertion failed: (success) HOT 3
- Warn In PyThreadState_Clear() If the Thread State Still Has an Unhandled Exception HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cpython.