This function prints out a given traceback and exception to sys.stderr.

When an exception is raised and uncaught, the interpreter calls sys.excepthook with three arguments, the exception class, exception instance, and a traceback object. In an interactive session this happens just before control is returned to the prompt; in a Python program this happens just before the program exits. The handling of such top-level exceptions can be customized by assigning another three-argument function to sys.excepthook.

Count von Count wrote:Just Saying

It is better to remain silent and be thought a fool, than to speak out and remove all doubt

People are lazy. Imagine you are working your arse off and in the middle ofsomething you think, Jeez, I wish I had a plugin, or could tweak an existingplugin, to help me with this task.

Do you

Reach for you handy command source teleportation plugin, make some tweaks to a plugin, smash out the work, quicker than it would have taken you otherwise and have an enhanced arsenal for the next time you face that situation?

Just tough it out and do shit manually to `Get Shit Done` By the time you have navigated to the source (Which file was it in again? FFFF) you going to get distracted anyway right. Stop fucking around and nail it up and get the money.

How the hell does any of this relate to unicode in `sys.path` I imagine?Everything is connected. A tiny detail can have big implications.

What *is* sys.path? It's basically an array of directories which Python willsearch, in turn, for modules. It can take relative (to the working directory) orabsolute paths.

If you'd read the 'not all beer and sunshine' post you'll know that Sublimeemploys some import chicanery to preemptively work around possible unicodecharacters in sys.path which aren't supported on windows. Before loading eachplugin, sublime makes sure to change the directory to the folder containing theplugin module.

What are the implications of this? Normally it's possible to take a Pythonclass/module and use introspection to determine the file it was declared in.However, when you use relative paths on sys.path, namely '.' as Sublime does,what's determined as a file for an object is a relative path.

If you been paying attention, you'll recall that Sublime changes directorybefore loading each and every plugin. Therefore, the rug has been swept out fromunderneath all the relative paths and they float without anchor.

Let's try and make sense of the above:

"todays (psychotic) episode was brought to you by the letter f (__file___)"

You can see it's a QuickPanel containing a bunch of event handlers, commandsgrouped by command/event type (window|application|text|on_.*)

Upon quickpanel selection it jumps to the source of PackageControls`InstallPackageCommand`

How does it do that? You guessed it. It uses the introspection capabilitiesexposed in the std lib `inspect` module.

Can you see the `object.__file__` mentioned above? When a module is imported,rooted from a relative path on `sys.path`, at least on windows, you'll get arelative path like say `.\Package Control.py`

That's not really enough information to navigate to the source of a plugin isit?

For the navigation to work in the image above a quick patch was applied tosublime_plugin.py to monkeypatch imported modules with the `__file__` attribute.

Ok, so if that's all you need to do, why not just do that then?

Recall J.C. Redish's, "Something is only useful if it's readily useable". Nowimagine you were working again, and you'd just successfully teleported to thecommand to edit it and after some tinkering you got a half useful exceptionmessage.

File ".\sublimezen.py", line 118, in wrapper File ".\sublimezenplugin.py", line 208, in run File ".\zencoding\__init__.py", line 75, in run_action File ".\zencoding\actions\basic.py", line 96, in match_pairZeroDivisionError: integer division or modulo by zero

So what if you had an sys.excepthook handler that opened an output panel (think`Tools -> Build` ) and allowed you to navigate the traceback with f4/shift+f4bindings? What if it automatically navigated to the `most recent call last`?

Count von Count wrote:Out of 1500 users, 16 have non ascii characters in their packages path, of which all are on windows and all are sys.path able via GetShortPathName

So what the fuck is the Count trying to say? And where does he pull thesenumbers from anyway? I'd guess he values numbers over intuition. Hes' called the `Count` after all

Ernie wrote:Hey Bert. But what if there *IS* someone with unicode in their sys.path as a black cat walks under a ladder on friday the 13th?

Bert is saying in the remote case that someone actually IS on windows (roughlyhalf of sublime users are on OSX) and does have unicode in their sys.path andDOES have short path names disabled they can always use the portableinstallation.

He let it go without saying that if you can manage JSON for configuration thenyou'll be likely be comfortable using a portable installation.

Ernie wrote:Wouldn't it be great if the whole `sublime.packages_path()` was on sys.path?