I might be wrong, but from what I understand unless you de-reference the symlink, the *NIX OS will tell you the directory you're in is the path as followed by the symlink. A symlink is not a shell function, it is an OS function?
In that sense, Python, perl, etc (and anything you could come up with) don't need special code to handle a symlink - the OS abstracts it for the userland process - a symlink is presented as a file. If the process wishes, it can ask the OS "is this a symlink and if so, give me the dereferenced path."
Maybe directories are different but in the case of a symlink
/usr/lib/foo.so -> /usr/lib/foo.so.1
foo.so is treated exactly and presented to a userland process the same as if they had asked for foo.so.1 - that is, the process believes that foo.so is the library and knows nothing about foo.so.1.
It feels like somewhere in the process here of determining the cwd, maybe the symlink is getting de-ref'd for some reason?
Sent from my iPad