An Open Letter to Catriona Nobel, CEO, McDonalds Australia

Dear Ms. Nobel,

You have a golden opportunity to turn McDonalds Australia into a shining example of corporate responsibility and good citizenship by doing somethng very simple: Give up on building a store in Tecoma or anywhere in the Dandenongs. Now, I know, you’ve already bought the land there, made all these plans, and so forth. Let me point out that by donating that land to the town and buliding a park there — JUST a park, now — and using it as a sort of “rainbow” to tell all of Victoria — promise to all of Victoria — that you won’t build any stores in the Dandenongs, ever, you will score mega-tonnes of community love and appreciation that would otherwise cost BILLIONS. It’s cheap advertising, and a win-win for you and for us here in the Dandenongs (especially those of us in Tecoma.)

I’m writing this not because there’s Buckley’s chance of you ever reading it, let alone taking it to heart. But, I just wanted it to be out there, in writing, that you had your chance to make this all come out right. You had the power and the opportunity, and, so far, you’ve simply squandered it.

I’m sure your board of directors will be very, very impressed come the next shareholders meeting.

Warmest Regads,
Nick Seidenman
Tecoma VIC

In response to a question on McDonalds rubbish …

The following was posted on the No Maccas in the Hills facebook page today:

No matter how many signs you put on a product and all of them request that you dispose of your garbage responsibly. It is ultimately the person who choses to discard what is not wanted and the manner of its disposal. As is with alcohol companies that request you to drink responsibly, yet many people still chose to get blind drunk. Do they force people to that outcome and are they the ones to blame for countless of alcohol related incidences. It is inherently the choice of the individual to behave in a responsible manner and no one is to blame but themselves

Ps is it the fault of maccas or c.u.b. for the accompaniment of empty stubbies that often is discarded in the same place?

I offered the following response:

I think this is a strawman argument. I don’t think anyone is suggesting that McDonalds is somehow responsible for where and how their customers choose to dispose of their rubbish. The fact remains, however, that even without a McDonalds in Tecoma, we have McDonalds rubbish being discarded here, be it by customers carelessly or deliberately leaving it anywhere but a bin, by animals fossicking in bins where it has been discarded, or simply carried by the wind. In all cases, the proximity of a McDonalds is more or less directly proportional to the amount of McDonalds-branded rubbish that you’ll find within a given area.

Rubbish is but one of several (strong) reasons why we didn’t want a McDonalds in Tecoma, all of which were put forward to our council and to VCAT. The issues now go beyond these, and pertain to the strong-arm tactics used by large corporations such as McDonalds when they don’t get their way through democratic means. We’re not talking about not wanting, say, a home for indigent aboriginals, or a mosque, or some other basis that can be considered on philosophical or even legal (as in constitutional) grounds. This is about whether or not we as a community have a say in who or what does business here — WHATEVER the reason.

Were this a matter of, say, a couple hundred of us against it, but the rest of the community not caring or being in favor, and were this a matter of a council vote that was split, or even 5-4 or 6-3 in favor, we wouldn’t be having these discussions. There’d be some room for debate on the issues. This is not the case, clearly. The community turned out by the hundreds, sent in over 1,100 written objections to the proposed permit, and the council voted UNANIMOUSLY against issuing that permit. There was no ambiguity here. None. Those who truly wanted a McDonalds here had just as much access and opportunity to say so. To be sure, there were perhaps a dozen or so such proponents at the meeting where 600 of us watched proudly as our council voted it down.

The issue at this point is beyond the rubbish and the noise and the loss of amenity and the impact on well-being. The issue applies to all of us, regardless of where any individual or group may stand on McDonalds per se. This is about corporation showing utter disregard for the will of a community, clearly stated through democratically elected councillors voting unanimously, in accord with that community. Today it’s about McDonalds; tomorrow, it could be about gas drilling, or a scrap metal processing yard in your town. This isn’t just OUR issue; it’s everyone’s issue. We win this, we all win. If McDonalds wins; we all lose. All of us.

An open letter to the “Yes Maccas” proponents

To the Yes Maccas folks:

“If you don’t like Maccas, just don’t eat there.”

So say those who favor a McDonalds in Tecoma. But, is that really the issue? Do you suppoose that we’re afraid Ronald and his minions are going to come storming into our homes and force that McCrap down our throats? Of course not. It’s a correct answer, so it sounds reasonable. The un-asked question, however, makes it absurd.

The “why” of not wanting a Maccas isn’t really relevant. The fact is, we, the residents of Tecoma — and more generally, the Dandenong Ranges — simply don’t want one here, for whatever reason. And we, being residents here, owning property here, having a real vested interest here, as a community have a right to determine the character and composition of OUR community. We have MORE of a right to that than ANY individual or business has to say otherwise. This is especially true of a business that doesn’t currently exist there. We have spoken, in a voice that is loud and clear. We don’t want a Maccas here. Period.

That voice was not only ignored, it was silenced not by reason, but by corporate money and greed. McDonalds is only the latest example of an ongoing effort on the part of large, monied interests to neutralize the obstacles that stand between them and making ever more money — at our expense.

Those who wanted a Maccas in Tecoma had just as much time and opportunity to respond in favor of it as the more than 1,100 of us who filed objections to it. The council meeting during which the permit was unanimously voted down was attended by over 600 of us who objected; I counted no more than a dozen — and I’m being generous — in favor of it.

The council vote should have been the end of the story. Instead, Maccas sued in VCAT, not JUST to build in Tecoma, but … and here’s the really important part, folks … to show that they could nullify the will of the people, that they could silence our voices, to show that they were indifferent to, even spiteful of the quality of life we want in the Hills. To show that Democracy itself is
irrelevant to them and to anyone, any corporation with enough money. Why, again, is irrelevant. It’s simply what corporations do: they make money, as much of it as they can.

The voice of the community — thousands of us — was clearly heard by the council, and they responded appropriately in denying Maccas the permt to build in Tecoma. You had a voice, too. It wasn’t nearlly so loud. But you threw in with the folks with the big money, and, as they say, money talks. It talks, it shouts, and, in this case, it drowned out the voice of the clear majority of people. You may think that this went in your favor. Ultimately, it will not. Today you, who favor a Maccas in Tecoma, think that you’re on the “winning” side of this issue. I suspect that, before long, You will see that we all lost on this one, all of us. The voice you thought was yours was simply the Money talking — you were just mouthing the words for it. One day, soon, you will find your rights trampled, your voice silenced.

You don’t like having your rights trampled, don’t like being told to shut up?

Just give up your rights, and don’t say a thing.

Tecoma, McDonalds and the Corporatocracy

The gist of what I’ve been saying is that this isn’t really about McDonalds per se, nor is it about the people who choose to consume their products. That comes down to a matter of making personal choices, and I’m all for that.  Rather, this pertains to our fight in as much as we, as a community, were not allowed to choose whether or not McDonalds would be permitted to build here. The legal and regulatory (read: planning and environment scheme) framework to support that choice were obviated by TWO people — the VCAT members Megan Carew and Geoff Rundell — who heard our case. Our community solidly and unambiguously opposed the development for reasons that, honestly, did not include whether or not the food is objectively good or bad. The reasons DID include the impact the business would have on the local community, socially, environmentally, and economically. The strongest case McDonalds could make was in that latter category and even THERE it was at best specious (sounding plausible but, with closer scrutiny, found to be false.) McDonalds likes to tout the jobs and income it will bring to the community, yet it will not reveal any details about its supply chain (it will buy most of what it sells from outside Victoria), nor will it be candid about plans to replace counter workers with self-ordering stations, thereby reducing the number of actual humans it needs to run the joint.

In the larger scope, this is not something that is unique to McDonalds. Rather, they are behaving with the same sort of dearth of values and decency that is systemic to any corporation. Does this make corporations “bad” per se? I would argue, no, it does not, any more than not having such values makes a saw or lawn mower “bad”. What these all have in common are that they are TOOLS, the intent of which, ultimately, is to give us HUMANS a better quality of life. They do this by making tough jobs easier, or — and this applies to corporations — allowing us to accomplish things together in groups that would be highly difficult or even impossible as individuals.

Things go pear-shaped when we, individually or corporately, lose sight of this very simple truth: we all just want to live the best life possible. We forget that this requires a balance between what’s “good” for us individually and what’s good for us collectively. When that balance is lost, when those responsible for the vision and guidance (call it governance) of a corporation lose their way, when their moral compass deviates from the optimal path to simply the fastest (i.e. get-richest-quickest one, we have a TOOL operating without an artisan in control, a ship — perhaps even a massive one — assundering all in its path. The fate of all such rudderless vessels can be found in the shoals and reefs of history, succumbed to the tides that are the “business cycle”, and driven aground by the winds of fashion they themselves may have helped to create.

A socially responsible corporation is a very powerful tool for good in this world. if McDonalds were to actually adhere to their own high-sounding statements, we wouldn’t be having this discussion, there would be no McDonalds in Tecoma or the Dandenongs, and they wouldn’t be such a huge contributor to childhood (and adult) obesity and diabetes in ‘western” (and westernised) countries.

The sad truth is that McDonalds, like so many corporations today, is not socially responsible. Instead of being guided by people, the corporate mantra — make money for the shareholders, all else be damned — is the guiding principal. The only thing standing in the way of any corporation simply robbing us blind or even killing us for the sake of profit is the body of law by which we — people — form them and by which they are regulated. The aim of corporations, that is, making money above all else, being what it is, has of late become one of undermining and eliminating these regulatory structures. To put it simply, corporations want to BE the government, not be restrained by it.

In despotic regimes, they do this by simple bribery, whch their great (and growing) wealth facilitates. Democracies, however, present corporations with a vastly different problem: Money is worthless in that realm; the voice(s) of the governed are what count, for it is THEY who empower democratic government.

So, what to do? Get rid of democracy, that’s what. But … how? You could try the direct method: hire armies of mercenaries and overthrow the government by force. This has been tried, and occasionally succeeds, but it more often than not proves to be costlier in the end than the less direct method. Disempower the government by disempowering the GOVERNED.

If you can, little by little, replace various, key elements of democratic government with ostensibly legal, but otherwise undemocratic, unelected, unaccountable ones that seem functionally equivalent, you can gradually close off all the avenues of remedy when those replacement elements begin to favor the corporatocracy. You don’t eliminate the democratic process; you put a price on it, and a high one at that, in currency that corporations have in seemingly endless supply, that we, as individuals generally do not — money.

Which brings us back to our fight against McDonalds. VCAT is a clear example of how a democratic process is replaced with one that is undemocratic and unaccountable.  VCAT was created to help “streamline” the lower court system in Victoria, which was, according to the MPs behind the legislation that created VCAT, “drowning” in small claims, tenant-landlord, falure-to-pay, and so forth cases. To be fair, it has greatly increased the speed and, arguably, the equity with which such cases are now dispensed. However, it can, and does, routinely overstep its bounds, as it did in our case. When this happens, the only recourse is to the Victorian Supreme Court. But this is, and always has been, a hugely expensive proposition for any litigant. It is made doubly so when such cases award costs to the “loser”.

We, of Tecoma and Shire of Yarra Ranges, used the tools of democracy — our elected, accountable council — to examine, debate, and finally turn down McDonalds permit. McDonalds lawyers were ready for this, knowing that it would go to VCAT and that there, they could put on a case that, for all its “legal” verbiage would come down to who could throw the more ostentatious party — who could spend the most. Clearly, that was McDonalds. They had literally NO case, legally; the VCAT members’ ruling never even questioned whether council had the right (and responsibility) to deny the permit. VCAT’s decision was all about finding a way to interpret planning law that would be favorable to McDonalds.

McDonalds, then, is merely the current battlefield on which a much, much larger fight is being fought: to bring corporations to heel, to do what they’re supposed to do, to be ruled by us, not be tools for the wealthy few to rule us.

What Our Protest Means to Me

Our protest isn’t about McDonalds per se. Our protest is mainly about protecting the democratic process by which we determine the character and composition of our community. Our local council spent months carefully studying the McDonalds application. They also received an unprecedented number of written objections from our community — over 1,100 of them — and carefully considered the application before finally, unanimously voting to deny it, as is their right and responsibility under planning scheme clause 65.

McDonalds took the game to a “court” where democracy is irrelevant, where the party who can put on the more expensive show stands the better chance of winning. McDonalds, having the bigger purse, won in that venue. Two people, who are not judges — they’re not even lawyers — who are not elected, but appointed by the governor general, overturned our council’s decision after just a few days of hearings and deliberation.

Our council considered an appeal to the Vic supreme court, but McDonalds had already threatened to sue for costs should that appeal fail. Afraid of the risk of having to pay perhaps as much as a million dollars or more in the event of such a loss, the council voted against pursuing it further. This was a matter of dollars winning out over democracy, plain and simple.

This isn’t just about McDonalds and why it may or may not be good for your health or for the community. This is about large corporations circumventing or altogether obviating the democratic process by using unelected, unaccountable decision-making entities such as VCAT. Today it’s about McDonalds in Tecoma. Tomorrow, it could well be about gas drilling or a landfill in YOUR town. THAT is what our fight is really about.

Keeping up with the Joneses

One of the core reasons given for keeping and stringently adhering to the Second Amendment is that an armed citizenry is a safeguard against the US government becoming a tyranny. This gives rise to the impression that gun owners think they’d be able to mount an armed insurrection against what they believe has become a despotic dictorship, ala Arab Spring or like the Syrian Rebels. However, the thought of these self-proclaimed patriots pitting their pistols and rifles against the might of the US Armed Forces, which, even the NRA would have to quickly (and, perhaps, enviously) admit, have a bit of an edge when it comes to weaponry, to say the very least, is both pitiable and laughable. Indeed, the gun-rightists insistance that they would thusly stand up to government over-reach has been dismissed by comics and pundits alike as testosterone-driven fantasy. Any such rebellion would obviously be both futile and short lived.

Earlier today I read this article about how the average price of gasoline in the US was higher in 2012 than in any previous year.  Big Oil certainly made record profits (again) as well, and wondered what it would take for the federal government to do something about this, like eliminate Big Oil’s tax breaks, or even nationalize the oil industry.  Of course, we can only imagine the chaos that would ensue as right-wing mouthpieces began trumpeting calls to arms such as “Obama took your oil!  Next he’s gonna come for your guns!!  WE MUST FIGHT THIS TYRANNY!!!”.  We could then expect tens of thousands of freedom-loving, government-hating, well-armed citizens expressing their great displeasure with and disapproval of the government taking away the rights of corporations to rip off the public with impunity and charge them ever higher prices even as demand continues to drop. And then it hit me: Could THIS be the sort of “armed revolt” the NRA is thinking of? Gun nuts may see themselves hunkered down in foxholes dug into battle lines drawn along the length of the Mall but I thnk the NRA has a more subtle end-game in mind, one in which the public is put at risk of lethal harm at the hands of their own neighbors armed to the teeth, rising up in white hot rage, nerves frayed to a flash-point, ready to “take out” anyone who so much as disagrees with them or calls their rage into question.

Could it be that this is why the NRA is so sanguine in their response to mass shootings? Newtown, Denver, Columbine, VCU, Gabrielle Giffords, etc. provide a small but clear taste of what would happen — on a much larger scale — if enough gun owners became angry enough to simply pick up their weapons and start shooting. Could it be that it isn’t federal buildings being attacked that they want our elected officials to be afraid of; rather, they want them to fear us attacking — and killing — one another?

Before we invaded Iraq we often heard stories of how Saddam Hussein used chemical weapons against his own population. (Well, OK, against the Kurds, who he really didn’t regard as actual people let alone fellow countrymen.) We’re now hearing stories almost every day about how Syrian President Bashar al-Assad is ruthlessly trying (though failing, it seems) to put down a massive rebellion in his country. These, we are told, are the sorts of dictatorships, the sort of self-interested tyrants that our well-armed citizenry prevents from coming into power here in the US. But, these are, from the outset and to their very core, different kinds of governments. They are not empowered (overtly and expressly) by the people they govern, and their function is more like that of a corporation — to maximize benefit for the empowered at the expense of everyone else. These governments invite rebellion and overthrow precisely because they disenfrancise nearly all of their citizens right from the start, and they derive their power only from the use of force . To them, might makes right. Period.

A benevolent government such as ours is ruled by laws, not military force, and its power comes not from an imaginary divine mandate or heridity; it comes from the people, who created the government to begin with. To immobilize such a government you don’t go up against its military; you threaten to harm or kill the very people who empower it, whose welfare and domestic tranqulity it is litaerally bound to protect. I believe that the NRA and the gun lobby have long since figured this out, and they have made us all hostages without us even realizing it. The tacit threat is that if the government steps out of line or doesn’t do as it’s told, WE (as in The People) will consequently come to harm. Every now and then, a few (or a few dozen) of us are executed just to make sure that we — i.e., the government — take the threat seriously. And yet, the actual shooter always turns out to be some deranged lunatic. The NRA and their minions plausibly distance themselves, claim that they had nothing to do with the latest horror, and continue to insist that the only valid solution is more guns for everyone. One can conclude that the NRA believes the only thing standing between us and tyranny isn’t guns; it’s collective suicide.

Romanticized versions of the stories of Masada and Jonestown tell us that the inhabitants all committed suicide rather than be taken by their besiegers, real or imaginary. In fact, while perhaps many did kill themselves, many others (certainly the children) were either killed by someone else, or were coerced at knife/sword/gun-point into taking their own lives. If this is indeed the NRA strategy, it is brilliant. It lets them accomplish anything they like, advance any agenda at all, even sell their influence to political interests that have nothing whatsoever to do with guns or gun rights. All the while they’re able to hold up their clean hands and with a straight face claim that the way to prevent future mass-killings is more guns in the hands of more people. No doubt, Jim Jones would be impressed.

Update,  30 June 2017:
The NRA recently released this PSA.  It all but validates the thesis of this post.  The NRA wants Americans to fight — and kill — one another.

Australia and Guns — The NRA has it ALL Wrong

In the wake of the Newtown, CT shootings, the NRA has predictably begun its campaign to preempt any attempt to limit Americans’ ability to own guns. Part of this campaign includes articles featuring the well-debunked claim that Australia banned guns and now has a higher crime rate to show for it. Since I live in Australia, several friends and family have forwarded some of these to me recently and I thought I’d toss back my $0.02.

First, these articles are either by or sponsored by the NRA, and all — every single one of them — are bunk.

Rather than expand on this myself, I’ll let you read this page, from FactCheck.org, for yourself. There are two points that I want to make, however.

First, the NRA mouthpieces have been out and about claiming that Australian’s aren’t allowed to own guns. This is FALSE. You can own a gun for hunting and for sport, however, you cannot own a gun for “self-defense”. The notion of protecting oneself with deadly force is simply foreign to the culture, here, and regarded as rather absurd. Now, if you live in a rural area, a farm, a ranch (aka station), or out in the bush somewhere you’ll almost certainly own and have occasion to use a gun. But, that would be for protection from the wildlife (you do NOT want to mess with a male adolescent kangaroo during mating season) or to thin invasive species, such as rabbit and fox, that destroy crops or attack livestock. Getting a gun permit is easy in such areas. In fact, if you own more than 100 acres, you can basically write your own permits for the use of firearms on your property.

Australia did institute a ban on assault-type weapons, which included automatic and semi-automatic guns, and guns with the capacity to fire many rounds between reloads. That was in 1996, in the wake of and in response to a mass-murder that shocked the nation. Since then, there have been exactly ZERO such mass murders.

ZERO

It didn’t put an end to all gun-related deaths, but it made it one hell of alot harder for one person to kill many others in one go. If the US had done the same thing following, say, the Columnbine, CO massacre, or the Gabrielle Giffords shooting, or even the Denver “Batman” shootings, 20 children and six adults in Newtown, CT might well be alive today. That’s a highly relevant statistic that you won’t ever hear the NRA or its minions mention.

Second, the NRA is claiming that the murder rate went up after the 1996 buy-back (what the NRA calls a gun “ban”). Again, this is FALSE. In fact, it has gone down more or less steadily ever since. The NRA (and their proxy) articles I’ve seen so far produce graphs from this article that obfuscate the facts, fail to show how they came up with their numbers (i.e. not even citing source material), and cite legitimate source material vaguely (e.g. Australian Bureau of Statistics, but with no further information as to which datasets were used.) This alone puts a strong stink of bullshit in the air.

Another statistic that’s hard to refute is that where there are more guns, there is a higher risk of being killed by one. The following is derived from Gun homicides and gun ownership listed by country (2007), published in The Guardian:

  • Australia’s population is just under 30 million whereas the US has a population of a bit over 300 million — a factor or roughly ten.
  • There are about 3 million privately-owned guns in Australia; there are 270 million — or about 90 times as many — in the US. That means that while there are enough guns to arm just about every man, woman, and child in the US, there are only enough guns here to arm one out of every ten Australians. Put another way, there are about nine times as many guns per person in the US as there are in Australia.
  • The death rate by firearm in Australia is 0.14 per 100,000 people versus 2.97 per 100,000 in the US. In other words, with roughly nine times as many guns per person in the US, you would expect there to be nine times the mortality rate. Instead, it is TWENTY TIMES as high.

Australians — even such gun nuts as we may have here — think Americans are truly insane when it comes to the whole idea of guns for personal protection. Even sport shooters and gun collectors here think the idea of protecting oneself with a gun is just looney. What makes them — us — all very sad is when we see the NRA trot out the same tactics used time and again whenever a tragedy like Newtown occurs. My Aussie friends and family ask me if maybe this will finally convince the US to do something about gun violence. Sadly I shake my head and reply “Not likely.” This has happened too often. The NRA is now well-practiced at defeating any such measures and, as the articles I was sent show, they’ve already set their misinformation machine in motion. It just goes to show that, on so many levels, the NRA is simply wrong.

UPDATE: Dr. Michael Brown, a scientist at Monash University wrote
this detailed, well-researched article further exposing NRA lies and BS.

Where did THAT come from?

All too often Python programmers ask themselves, “Who took the last cup of coffee and didn’t start another pot brewing!?”  Probably more often they’ll wonder “Where the hell is my proggy loading that function (or library or module) from?”   Whereas one can usually track down the SOB who left the empty pot and go all BobP* on him, it is often harder, depending on the platform, to answer the latter question.

Recently I found myself with several virtualenv paths as well as two or three actual installations (talking Python, here) along with several environment variables (PATH, LD_LIBRARY_PATH, PYTHONPATH, DYLD_LIBRARY_PATH, DYLD_FRAMEWORK_PATH, etc.) that were, to be perfectly blunt, FUBAR.   The code I was working on needed to load a modified version of the SQLITE3 module, which itself loaded a shared object (.so) file somewhere within its bowels.    No matter how I changed the several *PATH variables, I kept getting results that indicated the modified shared library simply wasn’t being referenced.   I could have spent a great deal of time trying various permutations of the paths in each of the PATH variables.   Having no desire to make a career (let alone a life-long persuit) of this, I decided to take a somewhat more sane approach.   Surely, there must be a way to tell which module python actually loads when it encounters a line like:

import sqlite3

Enter the modulefinder module (section 30.6 of the Python Library Reference).  This contains a class by the same name that gathers information from import statements encountered in the course of executing a script.  Its report method can be invoked after the script has finished and will list the modules imported  and the actual files where those modules were found.    So, to find out which sqlite3 module was being imported, I first tried:

from modulefinder import ModuleFinder
mf = ModuleFinder()
mf.run_script('import sqlite3')

which rewards me with:

Traceback (most recent call last):
  File "", line 1, in 
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/modulefinder.py", line 112, in run_script
    fp = open(pathname, READ_MODE)
IOError: [Errno 2] No such file or directory: 'import sqlite3'

What modulefinder really wants is a script that contains the import statements you’re looking to trace.   So, I put

import sqlite3

into a file named import_this.py and tried again:

mf.run_script('import_this.py')
mf.report()

and … Success!

Name                      File
----                      ----
m __main__                  import_this.py
m _sqlite3                  /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_sqlite3.so
m datetime                  /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/datetime.so
P sqlite3                   /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sqlite3/__init__.py
m sqlite3.dbapi2            /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sqlite3/dbapi2.py
m time                      /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/time.so

This canned report is nice, but you might want to use ModuleFinder‘s results
programatically, in which case you’ll want to refer to its modules attribute, which is
a Python dict object mapping module names to the files from whcih they were actually imported.

Beyond Python

Although this doesn’t tell me where my modified SQLITE3 library is being loaded, it does bring me a step closer.
I can now tell where python is picking up its sqlite3 module along with several other modules, some of which I can readily dismiss (datetime.so and time.so.) It’s obvious that sqlite3 is a Python package from the final part of its path (…/sqlite3/__init__.py) as well as from the capital “P” (for “package”) to the left of the module’s name in the report. Looking inside this file we find just one (executable) line of Python:

from dbapi2 import *

From the ModuleFinder report we already knew this module was being imported, so we continue digging there:

from _sqlite3 import *

which, again, confirms what we already knew from the report. But, that’s all we find in this file, aside from a few class declarations that are nothing more than wrappers and dressing for the contents of _sqlite3. If we go fossicking about inside the source code for _sqlite3.so (which can be found under the Modules subdirectory of the Python source tree) we’ll find a very simple and typical Python extension module that wraps the functions found in the SQLITE3 library itself. This seems to be a bit of a dead end. We still don’t know where the actual location of the SQLITE3 library (i.e. libsqlite3.dylib) that the extension module is referencing. For this, we’ll need a different tool: the ctypes module.

Ctypes let’s us load and easily access any dynamically linked library (DLL, .so, .dyld, etc) object and, in the case of function objects, call them from within python code. It also contains a very useful function called find_library that will … well … find shared libraries. It uses the environment’s *PATH variables the same way the dynamic linker would use them (i.e., searching these in the same order) for the specified library. So, we look for sqlite3:

from ctypes.util import find_library

find_library(‘sqlite3’)

and get:

/opt/local/lib/libsqlite3.dylib'

Looking at my DYLD_LIBRARY_PATH environment variable, I have only /opt/local/lib in the path. I can either replace the libsqlite3.dyld file in this directory with my own, modified version, or I can prepend this environment variable with the path where the modified library can be found:

export DYLD_LIBRARY_PATH="/home/nick/tryit/sqlite-3.6.23/.libs:$DYLD_LIBRARY_PATH"

and then use find_library as before

from ctypes.util import find_library

find_library(‘sqlite3’)

which yields

/home/nick/tryit/sqlite-3.6.23/.libs/libsqlite3.dylib

just as I’d expect.

Conclusions

There is always the temptation to automate processes such as these. I could have tied this all together into a nice neat little function that would take the module name as its argument and return the path, if any, of the associated dynamic library. If I were trying to develop a large scale code scanning tool, say, for doing a security audit of the code, I might do just that. Here, I just wanted to find out which of several possible dynamic libraries was being loaded by importing a single, particular module. A few lines of code are all that’s needed in this case. I’ll leave the fancier tool development to the intrepid reader. Right now, I have to go make some more coffee … before I get yelled at. (Again.)

Acquainted with the Night

A poem by Robert Frost, with Dave and Angela in mind:

Acquainted with the Night

I have been one acquainted with the night.
I have walked out in rain — and back in rain.
I have outwalked the furthest city light.

I have looked down the saddest city lane.
I have passed by the watchman on his beat
And dropped my eyes, unwilling to explain.

I have stood still and stopped the sound of feet
When far away an interrupted cry
Came over houses from another street,

But not to call me back or say good-bye;
And further still at an unearthly height,
A luminary clock against the sky

Proclaimed the time was neither wrong nor right.
I have been one acquainted with the night.