Re: How to guard against bugs like this one?

2010-02-05 Thread John Nagle
kj wrote: ... Through a *lot* of trial an error I finally discovered that the root cause of the problem was the fact that, in the same directory as buggy.py, there is *another* innocuous little script, totally unrelated, whose name happens to be numbers.py. The right answer to this is to

Re: How to guard against bugs like this one?

2010-02-05 Thread Stephen Hansen
On Fri, Feb 5, 2010 at 12:16 PM, John Nagle na...@animats.com wrote: kj wrote: Through a *lot* of trial an error I finally discovered that the root cause of the problem was the fact that, in the same directory as buggy.py, there is *another* innocuous little script, totally unrelated, whose

Re: How to guard against bugs like this one?

2010-02-05 Thread MRAB
Stephen Hansen wrote: On Fri, Feb 5, 2010 at 12:16 PM, John Nagle na...@animats.com mailto:na...@animats.com wrote: kj wrote: Through a *lot* of trial an error I finally discovered that the root cause of the problem was the fact that, in the same directory as

Re: How to guard against bugs like this one?

2010-02-05 Thread Ethan Furman
John Nagle wrote: kj wrote: ... Through a *lot* of trial an error I finally discovered that the root cause of the problem was the fact that, in the same directory as buggy.py, there is *another* innocuous little script, totally unrelated, whose name happens to be numbers.py. The right

Re: How to guard against bugs like this one?

2010-02-04 Thread Tim Golden
On 03/02/2010 16:17, kj wrote: Boy, that was dumb of me. The above apology was meant for Stephen Hansen, not Steve Holden. I guess this is now a meta-apology... (Sheesh.) You see? That's what I like about the Python community: people even apologise for apologising :) TJG --

Re: How to guard against bugs like this one?

2010-02-04 Thread Steve Holden
Tim Golden wrote: On 03/02/2010 16:17, kj wrote: Boy, that was dumb of me. The above apology was meant for Stephen Hansen, not Steve Holden. I guess this is now a meta-apology... (Sheesh.) You see? That's what I like about the Python community: people even apologise for apologising :)

Re: How to guard against bugs like this one?

2010-02-03 Thread kj
Steve, I apologize for the snarkiness of my previous reply to you. After all, I started the thread by asking the forum for advice on how to avoid a certain kind of bugs, you were among those who gave me advice. So nothing other than thanking you for it was in order. I just let myself get

Re: How to guard against bugs like this one?

2010-02-03 Thread kj
In hkbv23$c0...@reader2.panix.com kj no.em...@please.post writes: Steve, I apologize for the snarkiness of my previous reply to you. After all, I started the thread by asking the forum for advice on how to avoid a certain kind of bugs, you were among those who gave me advice. So nothing other

Re: How to guard against bugs like this one?

2010-02-03 Thread Nobody
On Tue, 02 Feb 2010 10:38:53 -0800, Carl Banks wrote: I don't know if that's necessary. Only supporting the foo.h case would work fine if Python behaved like gcc, i.e. if the current directory referred to the directory contain the file performing the import rather than in the process' CWD.

Re: How to guard against bugs like this one?

2010-02-03 Thread Steve Holden
Don't give it another thought. I'd much rather you cared than you didn't ... regards Steve kj wrote: Steve, I apologize for the snarkiness of my previous reply to you. After all, I started the thread by asking the forum for advice on how to avoid a certain kind of bugs, you were among

Re: How to guard against bugs like this one?

2010-02-03 Thread Steve Holden
kj wrote: In hkbv23$c0...@reader2.panix.com kj no.em...@please.post writes: Steve, I apologize for the snarkiness of my previous reply to you. After all, I started the thread by asking the forum for advice on how to avoid a certain kind of bugs, you were among those who gave me advice.

Re: How to guard against bugs like this one?

2010-02-03 Thread Dan Stromberg
kj wrote: I just spent about 1-1/2 hours tracking down a bug. An innocuous little script, let's call it buggy.py, only 10 lines long, and whose output should have been, at most two lines, was quickly dumping tens of megabytes of non-printable characters to my screen (aka gobbledygook), and in

Re: How to guard against bugs like this one?

2010-02-03 Thread Carl Banks
On Feb 3, 8:55 am, Nobody nob...@nowhere.com wrote: On Tue, 02 Feb 2010 10:38:53 -0800, Carl Banks wrote: I don't know if that's necessary. Only supporting the foo.h case would work fine if Python behaved like gcc, i.e. if the current directory referred to the directory contain the file

Re: How to guard against bugs like this one?

2010-02-03 Thread Carl Banks
On Feb 2, 8:52 pm, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Tue, 02 Feb 2010 19:55:15 -0800, Carl Banks wrote: On Feb 2, 5:49 pm, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Tue, 02 Feb 2010 12:26:16 -0800, Carl Banks wrote: I did not propose

Re: How to guard against bugs like this one?

2010-02-02 Thread Mark Dickinson
On Feb 2, 3:28 am, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: There is no module numbers in the standard library, at least not in 2.5. It's new in 2.6 (and 3.0, I think; it's there in 3.1, anyway). It provides abstract base classes for numeric types; see the fractions

Re: How to guard against bugs like this one?

2010-02-02 Thread Jean-Michel Pichavant
Carl Banks wrote: On Feb 1, 7:33 pm, Tim Chase python.l...@tim.thechases.com wrote: Stephen Hansen wrote: First, I don't shadow built in modules. Its really not very hard to avoid. Given the comprehensive nature of the batteries-included in Python, it's not as hard to

Re: How to guard against bugs like this one?

2010-02-02 Thread kj
Let me preface everything by thanking you and all those who replied for their comments. I have only one follow-up question (or rather, set of related questions) that I'm very keen about, plus a bit of a vent at the end. In pan.2010.02.02.03.28...@remove.this.cybersource.com.au Steven D'Aprano

Re: How to guard against bugs like this one?

2010-02-02 Thread Grant Edwards
On 2010-02-02, Roy Smith r...@panix.com wrote: In article hk82uv$8k...@reader1.panix.com, kj no.em...@please.post wrote: Through a *lot* of trial an error I finally discovered that the root cause of the problem was the fact that, in the same directory as buggy.py, there is *another*

Re: How to guard against bugs like this one?

2010-02-02 Thread Stephen Hansen
On Tue, Feb 2, 2010 at 6:13 AM, kj no.em...@please.post wrote: In pan.2010.02.02.03.28...@remove.this.cybersource.com.au Steven D'Aprano ste...@remove.this.cybersource.com.au writes: As for fixing it, unfortunately it's not quite so simple to fix without breaking backwards-compatibility. The

Re: How to guard against bugs like this one?

2010-02-02 Thread Nobody
On Tue, 02 Feb 2010 15:00:28 +, Grant Edwards wrote: It turns out that buggy.py imports psycopg2, as you can see, and apparently psycopg2 (or something imported by psycopg2) tries to import some standard Python module called numbers; instead it ends up importing the innocent

Re: How to guard against bugs like this one?

2010-02-02 Thread Alf P. Steinbach
* Nobody: On Tue, 02 Feb 2010 15:00:28 +, Grant Edwards wrote: It turns out that buggy.py imports psycopg2, as you can see, and apparently psycopg2 (or something imported by psycopg2) tries to import some standard Python module called numbers; instead it ends up importing the innocent

Re: How to guard against bugs like this one?

2010-02-02 Thread Terry Reedy
On 2/2/2010 9:13 AM, kj wrote: As for fixing it, unfortunately it's not quite so simple to fix without breaking backwards-compatibility. The opportunity to do so for Python 3.0 was missed. This last point is to me the most befuddling of all. Does anyone know why this opportunity was missed

Re: How to guard against bugs like this one?

2010-02-02 Thread Carl Banks
On Feb 2, 9:02 am, Nobody nob...@nowhere.com wrote: I don't know if that's necessary. Only supporting the foo.h case would work fine if Python behaved like gcc, i.e. if the current directory referred to the directory contain the file performing the import rather than in the process' CWD. As

Re: How to guard against bugs like this one?

2010-02-02 Thread Carl Banks
On Feb 2, 2:49 am, Jean-Michel Pichavant jeanmic...@sequans.com wrote: Carl Banks wrote: Name your modules send_email.py or sort_email.py or if it's a library module of related functions, email_handling.py.  Modules and scripts do things (usually), they should be given action words as

Re: How to guard against bugs like this one?

2010-02-02 Thread Jean-Michel Pichavant
Carl Banks wrote: On Feb 2, 2:49 am, Jean-Michel Pichavant jeanmic...@sequans.com wrote: Carl Banks wrote: Name your modules send_email.py or sort_email.py or if it's a library module of related functions, email_handling.py. Modules and scripts do things (usually), they should be

Re: How to guard against bugs like this one?

2010-02-02 Thread kj
In mailman.1795.1265135424.28905.python-l...@python.org Terry Reedy tjre...@udel.edu writes: On 2/2/2010 9:13 AM, kj wrote: As for fixing it, unfortunately it's not quite so simple to fix without breaking backwards-compatibility. The opportunity to do so for Python 3.0 was missed. This

Re: How to guard against bugs like this one?

2010-02-02 Thread Carl Banks
On Feb 2, 11:07 am, Jean-Michel Pichavant jeanmic...@sequans.com wrote: Carl Banks wrote: On Feb 2, 2:49 am, Jean-Michel Pichavant jeanmic...@sequans.com wrote: Carl Banks wrote: Name your modules send_email.py or sort_email.py or if it's a library module of related functions,

Re: How to guard against bugs like this one?

2010-02-02 Thread Roel Schroeven
Op 2010-02-02 18:02, Nobody schreef: On Tue, 02 Feb 2010 15:00:28 +, Grant Edwards wrote: It turns out that buggy.py imports psycopg2, as you can see, and apparently psycopg2 (or something imported by psycopg2) tries to import some standard Python module called numbers; instead it ends

Re: How to guard against bugs like this one?

2010-02-02 Thread Jonathan Gardner
On Feb 1, 6:34 pm, kj no.em...@please.post wrote: An innocuous little script, let's call it buggy.py, only 10 lines long, and whose output should have been, at most two lines, was quickly dumping tens of megabytes of non-printable characters to my screen (aka gobbledygook), and in the process

Re: How to guard against bugs like this one?

2010-02-02 Thread Stephen Hansen
On Tue, Feb 2, 2010 at 1:38 PM, Roel Schroeven rschroev_nospam...@fastmail.fm wrote: Apparently, contrary to my expectations, Python looks in the directory containing the currently running script instead. That means that the behavior of import foo depends very much on circumstances not under

Re: How to guard against bugs like this one?

2010-02-02 Thread Terry Reedy
On 2/2/2010 2:43 PM, kj wrote: Inmailman.1795.1265135424.28905.python-l...@python.org Terry Reedytjre...@udel.edu writes: On 2/2/2010 9:13 AM, kj wrote: As for fixing it, unfortunately it's not quite so simple to fix without breaking backwards-compatibility. The opportunity to do so for

Re: How to guard against bugs like this one?

2010-02-02 Thread Steven D'Aprano
On Tue, 02 Feb 2010 12:26:16 -0800, Carl Banks wrote: I did not propose obvious module names. I said obvious names like email.py are bad; more descriptive names like send_email.py are better. But surely send_email.py doesn't just send email, it parses email and receives email as well? --

Re: How to guard against bugs like this one?

2010-02-02 Thread kj
(For reasons I don't understand Stephen Hansen's posts don't show in my news server. I became aware of his reply from a passing reference in one of Terry Reedy's post. Then I found Hansen's post online, and then an earlier one, and pasted the relevant portion below.) First, I don't shadow

Re: How to guard against bugs like this one?

2010-02-02 Thread kj
In mailman.1804.1265150872.28905.python-l...@python.org Terry Reedy tjre...@udel.edu writes: On 2/2/2010 2:43 PM, kj wrote: Inmailman.1795.1265135424.28905.python-l...@python.org Terry Reedytjre...@udel.edu writes: On 2/2/2010 9:13 AM, kj wrote: As for fixing it, unfortunately it's not

Re: How to guard against bugs like this one?

2010-02-02 Thread Steve Holden
kj wrote: (For reasons I don't understand Stephen Hansen's posts don't show in my news server. I became aware of his reply from a passing reference in one of Terry Reedy's post. Then I found Hansen's post online, and then an earlier one, and pasted the relevant portion below.)

Re: How to guard against bugs like this one?

2010-02-02 Thread Carl Banks
On Feb 2, 5:49 pm, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Tue, 02 Feb 2010 12:26:16 -0800, Carl Banks wrote: I did not propose obvious module names.  I said obvious names like email.py are bad; more descriptive names like send_email.py are better. But surely

Re: How to guard against bugs like this one?

2010-02-02 Thread Steven D'Aprano
On Tue, 02 Feb 2010 19:55:15 -0800, Carl Banks wrote: On Feb 2, 5:49 pm, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Tue, 02 Feb 2010 12:26:16 -0800, Carl Banks wrote: I did not propose obvious module names.  I said obvious names like email.py are bad; more descriptive

Re: How to guard against bugs like this one?

2010-02-01 Thread Stephen Hansen
(This is no mere Python wart; this is a suppurating chancre, and the fact that it remains unfixed is a neverending source of puzzlement for me.) How can the average Python programmer guard against this sort of time-devouring bug in the future (while remaining a Python programmer)? The only

Re: How to guard against bugs like this one?

2010-02-01 Thread Chris Colbert
This is kinda akin to creating your own libc.so in a folder where your compiling and executing c programs and then wondering why your program bugs out On Mon, Feb 1, 2010 at 9:34 PM, kj no.em...@please.post wrote: I just spent about 1-1/2 hours tracking down a bug. An innocuous little

Re: How to guard against bugs like this one?

2010-02-01 Thread Chris Rebert
On Mon, Feb 1, 2010 at 6:34 PM, kj no.em...@please.post wrote: I just spent about 1-1/2 hours tracking down a bug. snip Through a *lot* of trial an error I finally discovered that the root cause of the problem was the fact that, in the same directory as buggy.py, there is *another* innocuous

Re: How to guard against bugs like this one?

2010-02-01 Thread Roy Smith
In article hk82uv$8k...@reader1.panix.com, kj no.em...@please.post wrote: Through a *lot* of trial an error I finally discovered that the root cause of the problem was the fact that, in the same directory as buggy.py, there is *another* innocuous little script, totally unrelated, whose name

Re: How to guard against bugs like this one?

2010-02-01 Thread Steven D'Aprano
On Tue, 02 Feb 2010 02:34:07 +, kj wrote: I just spent about 1-1/2 hours tracking down a bug. An innocuous little script, let's call it buggy.py, only 10 lines long, and whose output should have been, at most two lines, was quickly dumping tens of megabytes of non-printable characters

Re: How to guard against bugs like this one?

2010-02-01 Thread Tim Chase
Stephen Hansen wrote: First, I don't shadow built in modules. Its really not very hard to avoid. Given the comprehensive nature of the batteries-included in Python, it's not as hard to accidentally shadow a built-in, unknown to you, but yet that is imported by a module you are using. The

Re: How to guard against bugs like this one?

2010-02-01 Thread Stephen Hansen
On Mon, Feb 1, 2010 at 7:33 PM, Tim Chase python.l...@tim.thechases.comwrote: Stephen Hansen wrote: First, I don't shadow built in modules. Its really not very hard to avoid. Given the comprehensive nature of the batteries-included in Python, it's not as hard to accidentally shadow a

Re: How to guard against bugs like this one?

2010-02-01 Thread Carl Banks
On Feb 1, 6:34 pm, kj no.em...@please.post wrote: Both scripts live in a directory filled with *hundreds* little one-off scripts like the two of them.  I'll call this directory myscripts in what follows. [snip] How can the average Python programmer guard against this sort of time-devouring

Re: How to guard against bugs like this one?

2010-02-01 Thread Carl Banks
On Feb 1, 7:33 pm, Tim Chase python.l...@tim.thechases.com wrote: Stephen Hansen wrote: First, I don't shadow built in modules. Its really not very hard to avoid. Given the comprehensive nature of the batteries-included in Python, it's not as hard to accidentally shadow a built-in, unknown