I'm writing a text editor in python and gtk3 and I keep getting vague warnings from somewhere within glib when I close a window:
/usr/lib/python2.7/dist-packages/gi/types.py:47: Warning: invalid (NULL) pointer instance
return info.invoke(*args, **kwargs)
How can I debug this? I tried running it in gdb, hoping I might be able to learn something from a breakpoint at g_logv, but the warnings appear without triggering the breakpoint. I can't easily replace the log handler either because of https://bugzilla.gnome.org/show_bug.cgi?id=670507.
I've even tried altering the python file referenced in the message so that it always prints a python backtrace at that point, but it has to do it whether the error occurs or not and it gets called on every gobject method call, so it's difficult to interpret the results, and it still doesn't tell me anything about which pointer is null.
If you want to use gdb, just run your script with the G_DEBUG environment variable set to "fatal-warnings" (G_DEBUG=fatal-warnings ./your-script.py). There is documentation in the Running GLib Applications section of the GLib manual.
Related
I was trying to get datetime.py working as one of the functions from it just didn't exist in my datetime.py file. In my datetime.py the fromiso() function is not present in the code. To test it I opened a new VS project and tried compiling a small code snippet that would only invoke the missing function from datetime after import, and that's when I first encountered this problem. I'm not sure if this is related to this problem, but this is the last thing I was doing.
When running the code it will flash console quickly before opening "Launching debug adapter" window, this will prevent me from doing anything for maybe 10s and then will return to the starting point having neither executed my code nor opened the debugger.
Now I am unable to run any program whatsoever, running with either ctr+f5 or fn+f5 leads to same glitch. I have not touched anything in the VS settings prior. I have tried powercycling just for a good measure, but sadly that didn't fix anything. Running as admin yields same result.
When running a script in Ipython (with %run) and there is an error in the script, is it possible to open an editor at the line of the error or have an open editor jump to that line?
Automatically this is not happening, although one could implement something like that. The question is, what would be the correct file to open? The backtrace will reveal all possible files in which the functions raised the error. In a large project, it would not be clear in which file the error is, is it with the caller or callee who made the error?
Most advanced IDEs e.g. eclipse with pydev allow direct jumps to the lines and function calls, so it is covered there.
on an ipython level you could do
%edit file_named_in_error.py
When I'm developing in Python I often want to debug a specific method, in which case it makes sense to call the method from the interactive console or debug interactive console. However, when a method is called from the interactive windows in PTVS, it doesn't stop at the break points in said method.
If it's possible, please tell me how to do it. If not, I would like to request this feature, and also to know if there is any quicker way to debug a specific method than calling it from the main script.
I'm using PTVS 2.0 RC in Visual Studio 2013 Ultimate
When using the regular (non-debug) Python Interactive window, you can actually attach VS to the python.exe process that it is running by using Debug -> Attach to Process. Once that is done, if the interactive window does something to e.g. hit a breakpoint, the debugger will hit on that breakpoint.
The tricky part is loading the code from a file in such a way that breakpoints are resolved. In particular, $load REPL command will not work because it just reads the file and evals it in the REPL line by line, without preserving the original file context. What you need is to load your script using Python facilities - e.g. import, or open+exec.
There are also some gotchas there - e.g. the REPL window will become unresponsive whenever you are paused on a breakpoint.
Ok, I am new to python and my code calls some library (which is wrapping some C++ code) and I pass it a callback function on my side (as library needs to). The strange thing is that if I insert a breakpoint in my other part of the code, it will hit and deugger stops in eclipse but none of my breakpoints in the callback hit. The callback is sure called but the breakpoint is somehow ignored by PyDev. What I am doing wrong? The callback is obviously coming on a different thread. I am using Python 2.7
Try importing pdb and just manually setting breakpoints in the code with pdb.set_trace(). This won't work in all multi-threaded cases, but I find that it works in many of them and is a big improvement over the native Eclipse/PyDev debugger.
I'm trying to use flymake to run pyflakes, as suggested here
This works fine for local files, and almost works with remote files with a bit of tweaking, but I'm left with a problem where flymake/pyflakes 'modifies' the buffer when it runs (although nothing actually seems to change), which renders it a bit useless in practice (e.g. saving a file runs flymake which immediately modifies the buffer again).
Here's what I did to almost get it working:
Installed pyflakes on the remote box.
Customized my tramp-remote-process-environment variable so that pyflakes could be found in its PATH
Used a variant of the code from the wiki link above. Obviously I excluded the check that disables it for remote buffers. Also, the (when (load "flymake" t) ...) construct didn't seem to work as I expected, but I'm not too worried about that.
Re-defined (for test purposes -- advice should be fine if this can be made to work) the flymake-start-syntax-check-process function so that it uses start-file-process (which works with tramp) instead of start-process (which does not).
The change in #4 does not appear to cause any issues when processing a local file, but although this now enables flymake to run the remote pyflakes for the remote files (errors are highlighted as expected), in this instance the buffer is 'modified' whenever flymake runs.
I'm guessing that start-file-process, for remote processes, results in some additional return value/data that does not occur for local processes.
Does anyone have any insight/advice?
Emacs 23.1 and 23.2 on Ubuntu
Python 2.4.6
Pyflakes 0.4.0 (via easy_install)
You need to tell flymake to create it's copy of the buffer somewhere locally, I prefer using the $TMP directory since this also allows me to use tramp on files in directories I don't have write permissions to.
You may want to checkout my fork of flymake-python since it does all this.
I have this fixed in my fork of Flymake (https://github.com/illusori/emacs-flymake).
It will either run the syntax check on the remote machine via Tramp, without the buffer-modification issue you're seeing; or you can set flymake-run-in-place to nil and it will run the syntax check on the local machine, just like flymake on a regular non-Tramp buffer.
Since it's fixed at the Flymake level, this fix works for all languages and syntax checks rather than just pyflakes.
If you're interested in details of why it's happening, basically when the Tramp handler for start-file-process kicks in, it dumps the login message for the connection onto the end of the current buffer before any output filter can be attached to the process.
Usually this manifests as people seeing the contents of /etc/issue appear at the end of their file along with "You have mail." and so on.
In your case it may be that the login message is empty or just a new-line, so you're not seeing any text being added, even though it's setting the buffer as being modified.