comp.lang.python - 25 new messages in 11 topics - digest
comp.lang.python
http://groups.google.com/group/comp.lang.python?hl=en
comp.lang.python@googlegroups.com
Today's topics:
* Function attributes - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/73a7dac9c913c91c?hl=en
* Modifying Class Object - 5 messages, 3 authors
http://groups.google.com/group/comp.lang.python/t/fd36962c4970ac48?hl=en
* Please help with MemoryError - 5 messages, 5 authors
http://groups.google.com/group/comp.lang.python/t/6ed1981bc9821443?hl=en
* ANN: ActivePython 2.5.5.7 is now available - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/ff48fd9be9d32b5e?hl=en
* python crash on windows but not on linux - 6 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/7d380bb24fe5e8b8?hl=en
* Pycrypto RSA ciphertext to string back to ciphertext issue - 2 messages, 2
authors
http://groups.google.com/group/comp.lang.python/t/fb33a49ed28f949e?hl=en
* Need debugging knowhow for my creeping Unicodephobia - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/f468546c655f085f?hl=en
* Is a merge interval function available? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/028e0e78c5df5168?hl=en
* timer for a function - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/a52c427850c5ef89?hl=en
* Bizarre arithmetic results - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/a84e4f9c6dcb911a?hl=en
* ANN: obfuscate - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/6374e775e474ee1a?hl=en
==============================================================================
TOPIC: Function attributes
http://groups.google.com/group/comp.lang.python/t/73a7dac9c913c91c?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Feb 11 2010 3:36 pm
From: "Gabriel Genellina"
En Thu, 11 Feb 2010 00:25:00 -0300, Terry Reedy <tjreedy@udel.edu>
escribió:
> On 2/10/2010 4:49 PM, Gabriel Genellina wrote:
>
>> I've written a decorator for "injecting" a __function__ name into the
>> function namespace, but I can't find it anywhere. I think I implemented
>> it by adding a fake additional argument and replacing LOAD_GLOBAL with
>> LOAD_NAME in the bytecode.
>
> The decorator only needs to replace the defaults args tuple.
> It does not even need to know the parameter name,
> just that it is the only (or last) with a default .
>
> def f(n, me=None):
> if n > 0: return n*me(n-1)
> elif n==0: return 1
>
> f.__defaults__ = (f,) # 3.1
> print(f(5))
This is simple to implement, but requires changing the function
definition. My goal was to keep the original code unchanged, that is,
leave it as:
def f(n):
if n > 0: return n*f(n-1)
elif n==0: return 1
(like a normal, recursive function), and make the 'f' inside the function
body "magically" refer to the function itself.
> Of course, user could still screw up recursion by providing another
> value for 'me'. This strikes me as about a likely (low) as a user
> screwing up recursion in a library module function by rebinding the name
> in the imported module.
Well, if people really want to shoot themselves in the foot, there's
nothing we can do to avoid that...
--
Gabriel Genellina
==============================================================================
TOPIC: Modifying Class Object
http://groups.google.com/group/comp.lang.python/t/fd36962c4970ac48?hl=en
==============================================================================
== 1 of 5 ==
Date: Thurs, Feb 11 2010 3:46 pm
From: "Martin P. Hellwig"
<cut all>
Well at least you are well written and more subtle than Xah Lee.
Though I find him also quite amusing, I do like a good flame-war every
now and again, and in that perspective I solute you.
--
mph
== 2 of 5 ==
Date: Thurs, Feb 11 2010 5:09 pm
From: Steven D'Aprano
On Thu, 11 Feb 2010 17:11:17 -0500, Terry Reedy wrote:
> About 13 years ago, I noticed that electronically executable Python was
> very similar to some of the designed-for-human-reading algoritm
> languages (pseudocode) that were not. I then coined the oxymoron
> 'executable pseudocode' for Python.
That was yours? Nice one!
--
Steve
== 3 of 5 ==
Date: Thurs, Feb 11 2010 5:14 pm
From: Steven D'Aprano
On Thu, 11 Feb 2010 23:26:34 +0100, Alf P. Steinbach wrote:
>> I presume you agree that the name 'Alf P. Steinbach' refers to you. Do
>> you then consider it to be a 'reference' to you?
>
> Yes, and that's irrelevant, because you can't change a name.
Pardon me, but you most certainly can. Even Germany, which doesn't allow
people to change their legal name for frivolous reasons, makes exceptions
and will allow people to change their name if (e.g.) they have a sex
change, or if they are burdened with a name that causes them ridicule,
and presumably for their equivalent of the witness relocation program.
And even Germany doesn't presume to tell people what name they are known
by to their friends and family.
In Python, one can't change names *in place*, because strings are
immutable. (Although I have seen a hack with ctypes which allows you to
modify string objects. It makes a nice trick, but is completely useless
because of the side-effects.) Even if you could modify the name, that
would break the namespace it was stored in. But of course you can change
names in two steps:
x = something()
y = x
del x
And lo, we have changed the name x to y.
--
Steven
== 4 of 5 ==
Date: Thurs, Feb 11 2010 5:17 pm
From: "Alf P. Steinbach"
* Steven D'Aprano:
> On Thu, 11 Feb 2010 23:26:34 +0100, Alf P. Steinbach wrote:
>
>>> I presume you agree that the name 'Alf P. Steinbach' refers to you. Do
>>> you then consider it to be a 'reference' to you?
>> Yes, and that's irrelevant, because you can't change a name.
>
> Pardon me, but you most certainly can. Even Germany, which doesn't allow
> people to change their legal name for frivolous reasons, makes exceptions
> and will allow people to change their name if (e.g.) they have a sex
> change, or if they are burdened with a name that causes them ridicule,
> and presumably for their equivalent of the witness relocation program.
> And even Germany doesn't presume to tell people what name they are known
> by to their friends and family.
>
> In Python, one can't change names *in place*, because strings are
> immutable. (Although I have seen a hack with ctypes which allows you to
> modify string objects. It makes a nice trick, but is completely useless
> because of the side-effects.) Even if you could modify the name, that
> would break the namespace it was stored in. But of course you can change
> names in two steps:
>
> x = something()
> y = x
> del x
>
> And lo, we have changed the name x to y.
Good joke. :-)
Cheers,
- Alf
== 5 of 5 ==
Date: Thurs, Feb 11 2010 6:47 pm
From: "Alf P. Steinbach"
* Martin P. Hellwig:
> <cut all>
> Well at least you are well written and more subtle than Xah Lee.
> Though I find him also quite amusing, I do like a good flame-war every
> now and again, and in that perspective I solute you.
The technical discussion is now at point where one poster maintains that
references don't exist in Python, and another poster, in support, maintains that
"refers to" in the language spec doesn't mean "refers to" but instead means
"refers to", whatever's that meant to mean.
As a technical discussion it's meaningless drivel.
And as an argument in that technical discussion your allegation of trolling is
just yet another fallacy, and meaningless.
But in a social context, declaring support or placing oneself within a group, or
for that matter "Poisoning the well", it can make sense.
This group has an extraordinary high level of flaming and personal attacks, and
it's the only group I've seen where there are threads (I think I've seen 3,
within the last two months, not participating in them) with the regulars
reitererating how "friendly" the group is, how difficult it is to get flamed
here. In other groups it's not necessary for the regulars to point out how
friendly the group is. But then, in other groups personal attacks are rare.
And so when you mention Xah Lee I'm now wondering what is cause, and what is effect.
I was informed that he'd done extensive cross-posting, and his own web site
seems to confirm that his ISP at one time reacted to a complaint about such
cross-posting. I've also seen directly that he has employed pretty foul language
in characterizing Python in an article, and even without that language negative
loaded characterizations without any evidence to back them up (like, for
example, yours above) must be considered intentional flame bait. But did it
start that way for Xah Lee?
I'm not going to check the archives. It's enough, wrt. the point I'm making
about some regulars of the group, that even with such evidence of active
trolling at hand -- ISP reaction to cross-posting, needless foul language,
unsubstantiated characterizations -- based on my experience here I think it's
just as likely that it started out by Xah Lee being flamed, perhaps repeatedly,
with personal attacks and by group action. Or perhaps it didn't, but at this
point it would not surprise me in the slightest.
Cheers & hth.,
- Alf
==============================================================================
TOPIC: Please help with MemoryError
http://groups.google.com/group/comp.lang.python/t/6ed1981bc9821443?hl=en
==============================================================================
== 1 of 5 ==
Date: Thurs, Feb 11 2010 4:03 pm
From: "Alf P. Steinbach"
* Jeremy:
> I have been using Python for several years now and have never run into
> memory errors…
>
> until now.
>
> My Python program now consumes over 2 GB of memory and then I get a
> MemoryError. I know I am reading lots of files into memory, but not
> 2GB worth. I thought I didn't have to worry about memory allocation
> in Python because of the garbage collector. On this note I have a few
> questions. FYI I am using Python 2.6.4 on my Mac.
>
> 1. When I pass a variable to the constructor of a class does it
> copy that variable or is it just a reference/pointer? I was under the
> impression that it was just a pointer to the data.
Uhm, I discovered that "pointer" is apparently a Loaded Word in the Python
community. At least in some sub-community, so, best avoided. But essentially
you're just passing a reference to an object. The object is not copied.
> 2. When do I need to manually allocate/deallocate memory and when
> can I trust Python to take care of it?
Python takes care of deallocation of objects that are /no longer referenced/.
> 3. Any good practice suggestions?
You need to get rid of references to objects before Python will garbage collect
them.
Typically, in a language like Python (or Java, C#...) memory leaks are caused by
keeping object references in singletons or globals, e.g. for purposes of event
notifications. For example, you may have some dictionary somewhere.
Such references from singletons/globals need to be removed.
You do not, however, need to be concerned about circular references, at least
unless you need some immediate deallocation.
For although circular references will prevent the objects involved from being
immediately deallocated, the general garbage collector will take care of them later.
Cheers & hth.,
- Alf
== 2 of 5 ==
Date: Thurs, Feb 11 2010 4:36 pm
From: Jonathan Gardner
On Feb 11, 3:39 pm, Jeremy <jlcon...@gmail.com> wrote:
> I have been using Python for several years now and have never run into
> memory errors…
>
> until now.
>
Yes, Python does a good job of making memory errors the least of your
worries as a programmer. Maybe it's doing too good of a job...
> My Python program now consumes over 2 GB of memory and then I get a
> MemoryError. I know I am reading lots of files into memory, but not
> 2GB worth.
Do a quick calculation: How much are leaving around after you read in
a file? Do you create an object for each line? What does that object
have associated with it? You may find that you have some strange
O(N^2) behavior regarding memory here. Oftentimes people forget that
you have to evaluate how your algorithm will run in time *and* memory.
> I thought I didn't have to worry about memory allocation
> in Python because of the garbage collector.
While it's not the #1 concern, you still have to keep track of how you
are using memory and try not to be wasteful. Use good algorithms, let
things fall out of scope, etc...
> 1. When I pass a variable to the constructor of a class does it
> copy that variable or is it just a reference/pointer? I was under the
> impression that it was just a pointer to the data.
For objects, until you make a copy, there is no copy made. That's the
general rule and even though it isn't always correct, it is correct
enough.
> 2. When do I need to manually allocate/deallocate memory and when
> can I trust Python to take care of it?
Let things fall out of scope. If you're concerned, use delete. Try to
avoid using the global namespace for everything, and try to keep your
lists and dicts small.
> 3. Any good practice suggestions?
>
Don't read in the entire file and then process it. Try to do line-by-
line processing.
Figure out what your algorithm is doing in terms of time *and* memory.
You likely have some O(N^2) or worse in memory usage.
Don't use Python variables to store data long-term. Instead, setup a
database or a file and use that. I'd first look at using a file, then
using SQLite, and then a full-fledged database like PostgreSQL.
Don't write processes that sit around for a long time unless you also
evaluate whether that process grows in size as it runs. If it does,
you need to figure out why and stop that memory leak.
Simpler code uses less memory. Not just because it is smaller, but
because you are not copying and moving data all over the place. See
what you can do to simplify your code. Maybe you'll expose the nasty
O(N^2) behavior.
== 3 of 5 ==
Date: Thurs, Feb 11 2010 5:50 pm
From: Steven D'Aprano
On Thu, 11 Feb 2010 15:39:09 -0800, Jeremy wrote:
> My Python program now consumes over 2 GB of memory and then I get a
> MemoryError. I know I am reading lots of files into memory, but not 2GB
> worth.
Are you sure?
Keep in mind that Python has a comparatively high overhead due to its
object-oriented nature. If you have a list of characters:
['a', 'b', 'c', 'd']
there is the (small) overhead of the list structure itself, but each
individual character is not a single byte, but a relatively large object:
>>> sys.getsizeof('a')
32
So if you read (say) a 500MB file into a single giant string, you will
have 500MB plus the overhead of a single string object (which is
negligible). But if you read it into a list of 500 million single
characters, you will have the overhead of a single list, plus 500 million
strings, and that's *not* negligible: 32 bytes each instead of 1.
So try to avoid breaking a single huge strings into vast numbers of tiny
strings all at once.
> I thought I didn't have to worry about memory allocation in
> Python because of the garbage collector.
You don't have to worry about explicitly allocating memory, and you
almost never have to worry about explicitly freeing memory (unless you
are making objects that, directly or indirectly, contain themselves --
see below); but unless you have an infinite amount of RAM available of
course you can run out of memory if you use it all up :)
> On this note I have a few
> questions. FYI I am using Python 2.6.4 on my Mac.
>
> 1. When I pass a variable to the constructor of a class does it copy
> that variable or is it just a reference/pointer? I was under the
> impression that it was just a pointer to the data.
Python's calling model is the same whether you pass to a class
constructor or any other function or method:
x = ["some", "data"]
obj = f(x)
The function f (which might be a class constructor) sees the exact same
list as you assigned to x -- the list is not copied first. However,
there's no promise made about what f does with that list -- it might copy
the list, or make one or more additional lists:
def f(a_list):
another_copy = a_list[:]
another_list = map(int, a_list)
> 2. When do I need
> to manually allocate/deallocate memory and when can I trust Python to
> take care of it?
You never need to manually allocate memory.
You *may* need to deallocate memory if you make "reference loops", where
one object refers to itself:
l = [] # make an empty list
l.append(l) # add the list l to itself
Python can break such simple reference loops itself, but for more
complicated ones, you may need to break them yourself:
a = []
b = {2: a}
c = (None, b)
d = [1, 'z', c]
a.append(d) # a reference loop
Python will deallocate objects when they are no longer in use. They are
always considered in use any time you have them assigned to a name, or in
a list or dict or other structure which is in use.
You can explicitly remove a name with the del command. For example:
x = ['my', 'data']
del x
After deleting the name x, the list object itself is no longer in use
anywhere and Python will deallocate it. But consider:
x = ['my', 'data']
y = x # y now refers to THE SAME list object
del x
Although you have deleted the name x, the list object is still bound to
the name y, and so Python will *not* deallocate the list.
Likewise:
x = ['my', 'data']
y = [None, 1, x, 'hello world']
del x
Although now the list isn't bound to a name, it is inside another list,
and so Python will not deallocate it.
> 3. Any good practice suggestions?
Write small functions. Any temporary objects created by the function will
be automatically deallocated when the function returns.
Avoid global variables. They are a good way to inadvertently end up with
multiple long-lasting copies of data.
Try to keep data in one big piece rather than lots of little pieces.
But contradicting the above, if the one big piece is too big, it will be
hard for the operating system to swap it in and out of virtual memory,
causing thrashing, which is *really* slow. So aim for big, but not huge.
(By "big" I mean megabyte-sized; by "huge" I mean hundreds of megabytes.)
If possible, avoid reading the entire file in at once, and instead
process it line-by-line.
Hope this helps,
--
Steven
== 4 of 5 ==
Date: Thurs, Feb 11 2010 6:36 pm
From: Tim Chase
Jonathan Gardner wrote:
> Don't use Python variables to store data long-term. Instead, setup a
> database or a file and use that. I'd first look at using a file, then
> using SQLite, and then a full-fledged database like PostgreSQL.
Just to add to the mix, I'd put the "anydbm" module on the
gradient between "using a file" and "using sqlite". It's a nice
intermediate step between rolling your own file formats for data
on disk, and having to write SQL since access is entirely like
you'd do with a regular Python dictionary.
-tkc
== 5 of 5 ==
Date: Thurs, Feb 11 2010 8:58 pm
From: aahz@pythoncraft.com (Aahz)
In article <mailman.2418.1265942230.28905.python-list@python.org>,
Tim Chase <python.list@tim.thechases.com> wrote:
>
>Just to add to the mix, I'd put the "anydbm" module on the gradient
>between "using a file" and "using sqlite". It's a nice intermediate
>step between rolling your own file formats for data on disk, and having
>to write SQL since access is entirely like you'd do with a regular
>Python dictionary.
Not quite. One critical difference between dbm and dicts is the need to
remember to "save" changes by setting the key's valud again.
--
Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/
"At Resolver we've found it useful to short-circuit any doubt and just
refer to comments in code as 'lies'. :-)"
==============================================================================
TOPIC: ANN: ActivePython 2.5.5.7 is now available
http://groups.google.com/group/comp.lang.python/t/ff48fd9be9d32b5e?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Feb 11 2010 4:22 pm
From: Sridhar Ratnakumar
I'm happy to announce that ActivePython 2.5.5.7 is now available for
download from:
http://www.activestate.com/activepython/
This is a minor release with several updates and fixes.
Changes in 2.5.5.7
------------------
- Upgrade to Python 2.5.5
- Upgrade to Tcl/Tk 8.5.8
- Upgrade to PyWin32 CVS (2009-11-10)
- Security upgrade to openssl-0.9.8l
- [Windows] Include Tcl/Tk header files
- [Windows] Allow side-by-side installation of 32-bit and 64-bit builds
- [Mac] Fix the MacOSX build to use Tcl/Tk 8.5.x
See the release notes for full details:
http://docs.activestate.com/activepython/2.5/relnotes.html#changes
What is ActivePython?
---------------------
ActivePython is ActiveState's binary distribution of Python. Builds
for Windows, Mac OS X, Linux are made freely available. Builds
for Solaris, HP-UX and AIX, and access to older versions are
available with ActivePython Business Edition:
http://www.activestate.com/business_edition/
ActivePython includes the Python core and the many core extensions:
zlib and bzip2 for data compression, the Berkeley DB (bsddb) and SQLite
(sqlite3) database libraries, OpenSSL bindings for HTTPS
support, the Tix GUI widgets for Tkinter, ElementTree for XML
processing, ctypes (on supported platforms) for low-level library
access, and others. The Windows distribution ships with PyWin32 -- a
suite of Windows tools developed by Mark Hammond, including bindings
to the Win32 API and Windows COM.
Beginning with the 2.6.3.7 release, ActivePython includes a binary package
manager for Python (PyPM) that can be used to install packages much
easily. For example:
pypm install pylons
See this page for full details:
http://docs.activestate.com/activepython/2.5/whatsincluded.html
As well, ActivePython ships with a wealth of documentation for both
new and experienced Python programmers. In addition to the core Python
docs, ActivePython includes the "What's New in Python" series, "Dive
into Python", the Python FAQs & HOWTOs, and the Python Enhancement
Proposals (PEPs).
An online version of the docs can be found here:
http://docs.activestate.com/activepython/2.5/
We would welcome any and all feedback to:
ActivePython-feedback@activestate.com
Please file bugs against ActivePython at:
http://bugs.activestate.com/query.cgi?set_product=ActivePython
On what platforms does ActivePython run?
----------------------------------------
ActivePython includes installers for the following platforms:
- Windows/x86
- Windows/x64 (aka "AMD64")
- Mac OS X
- Linux/x86
- Linux/x86_64 (aka "AMD64")
- Solaris/SPARC (Business Edition only)
- Solaris/x86 (Business Edition only)
- HP-UX/PA-RISC (Business Edition only)
- AIX/PowerPC (Business Edition only)
- AIX/PowerPC 64-bit (Business Edition only)
Custom builds are available in Enterprise Edition:
http://www.activestate.com/activepython/enterprise/
Thanks, and enjoy!
The Python Team
--
Sridhar Ratnakumar
sridharr at activestate.com
==============================================================================
TOPIC: python crash on windows but not on linux
http://groups.google.com/group/comp.lang.python/t/7d380bb24fe5e8b8?hl=en
==============================================================================
== 1 of 6 ==
Date: Thurs, Feb 11 2010 5:09 pm
From: hjebbers
On Feb 11, 11:59 pm, Terry Reedy <tjre...@udel.edu> wrote:
> On 2/11/2010 9:32 AM, hjebbers wrote:
>
>
>
> > To all,
> > I am running an EDI translator, and doing stress tests.
> > When processing a test with a (relatively) big EDI file(s) on
> > windowsXP I get a crash:
> > 'sorry for the inconvenience' etc (so no clues about what is
> > causing the problem)
>
> > This happens with python 2.4, 2.5, 2.6
> > It does not happen in the same setup&tests on linux. (while the linux
> > machine has only half of the RAM of the windows machine).
> > I am quite sure it is not some external module; there's no GUI (apart
> > from 'print'), no network connections.
> > Actually, the crash is not predictable....the crash occurs most of the
> > time...but at different points.
>
> > So basically I am wondering how to proceed.
> > Is it related to a memory problem? (which does not occur on Linux)
>
> > any pointer is very welcome,
>
> Are you using a 3rd-party extension (compiled-C) module? If so, I would
> suspect something platform specific in that.
That was my first thought. Sop I tried to eliminate that.
well, there is a connection to a database.
but I tested this with connections to SQLite, MySQL, PostGreSQL, and
the crash keeps coming.
So I think it is not a 3rd party module....
And all else is is pure python.
kind regards, Henk-Jan
== 2 of 6 ==
Date: Thurs, Feb 11 2010 5:14 pm
From: hjebbers
On Feb 12, 12:13 am, Emile van Sebille <em...@fenx.com> wrote:
> On 2/11/2010 6:32 AM hjebbers said...
>
> > To all,
> > I am running an EDI translator,
>
> ... let's say bots :)
>
> > and doing stress tests.
> > When processing a test with a (relatively) big EDI file(s) on
> > windowsXP I get a crash:
> > 'sorry for the inconvenience' etc (so no clues about what is
> > causing the problem)
>
> ... and it's running directly under python...
>
> I use textpad. It allows me to launch a script from a command window
> under its control, which when python subsequently crashes, commonly
> leaves the traceback in the textpad launched command window.
>
> Perhaps that'll help?
>
> Emile
> --also on the bots list and will be digging in seriously over the next
> several weeks
>
>
>
> > This happens with python 2.4, 2.5, 2.6
> > It does not happen in the same setup&tests on linux. (while the linux
> > machine has only half of the RAM of the windows machine).
> > I am quite sure it is not some external module; there's no GUI (apart
> > from 'print'), no network connections.
> > Actually, the crash is not predictable....the crash occurs most of the
> > time...but at different points.
>
> > So basically I am wondering how to proceed.
> > Is it related to a memory problem? (which does not occur on Linux)
>
> > any pointer is very welcome,
>
> > henk-jan
>
>
Hi Emile,
yes, we are talking bots.
I run the bots engine from the commandline.
But... there is no python traceback. Python crashed 'hard'.
or have you something else in mind?
kind regards,henk-jan
== 3 of 6 ==
Date: Thurs, Feb 11 2010 5:30 pm
From: hjebbers
On Feb 12, 12:13 am, Emile van Sebille <em...@fenx.com> wrote:
> On 2/11/2010 6:32 AM hjebbers said...
>
> > To all,
> > I am running an EDI translator,
>
> ... let's say bots :)
>
> > and doing stress tests.
> > When processing a test with a (relatively) big EDI file(s) on
> > windowsXP I get a crash:
> > 'sorry for the inconvenience' etc (so no clues about what is
> > causing the problem)
>
> ... and it's running directly under python...
>
> I use textpad. It allows me to launch a script from a command window
> under its control, which when python subsequently crashes, commonly
> leaves the traceback in the textpad launched command window.
>
> Perhaps that'll help?
>
> Emile
> --also on the bots list and will be digging in seriously over the next
> several weeks
>
>
>
> > This happens with python 2.4, 2.5, 2.6
> > It does not happen in the same setup&tests on linux. (while the linux
> > machine has only half of the RAM of the windows machine).
> > I am quite sure it is not some external module; there's no GUI (apart
> > from 'print'), no network connections.
> > Actually, the crash is not predictable....the crash occurs most of the
> > time...but at different points.
>
> > So basically I am wondering how to proceed.
> > Is it related to a memory problem? (which does not occur on Linux)
>
> > any pointer is very welcome,
>
> > henk-jan
>
>
== 4 of 6 ==
Date: Thurs, Feb 11 2010 5:32 pm
From: hjebbers
On Feb 12, 12:13 am, Emile van Sebille <em...@fenx.com> wrote:
> On 2/11/2010 6:32 AM hjebbers said...
>
> > To all,
> > I am running an EDI translator,
>
> ... let's say bots :)
>
> > and doing stress tests.
> > When processing a test with a (relatively) big EDI file(s) on
> > windowsXP I get a crash:
> > 'sorry for the inconvenience' etc (so no clues about what is
> > causing the problem)
>
> ... and it's running directly under python...
>
> I use textpad. It allows me to launch a script from a command window
> under its control, which when python subsequently crashes, commonly
> leaves the traceback in the textpad launched command window.
>
> Perhaps that'll help?
>
> Emile
> --also on the bots list and will be digging in seriously over the next
> several weeks
>
>
>
> > This happens with python 2.4, 2.5, 2.6
> > It does not happen in the same setup&tests on linux. (while the linux
> > machine has only half of the RAM of the windows machine).
> > I am quite sure it is not some external module; there's no GUI (apart
> > from 'print'), no network connections.
> > Actually, the crash is not predictable....the crash occurs most of the
> > time...but at different points.
>
> > So basically I am wondering how to proceed.
> > Is it related to a memory problem? (which does not occur on Linux)
>
> > any pointer is very welcome,
>
> > henk-jan
>
>
== 5 of 6 ==
Date: Thurs, Feb 11 2010 5:33 pm
From: hjebbers
On Feb 11, 11:56 pm, Carl Banks <pavlovevide...@gmail.com> wrote:
> On Feb 11, 2:39 pm, hjebbers <hjebb...@gmail.com> wrote:
>
>
>
> > On Feb 11, 8:42 pm, Jerry Hill <malaclyp...@gmail.com> wrote:
>
> > > On Thu, Feb 11, 2010 at 9:32 AM, hjebbers <hjebb...@gmail.com> wrote:
> > > > To all,
> > > > I am running an EDI translator, and doing stress tests.
> > > > When processing a test with a (relatively) big EDI file(s) on
> > > > windowsXP I get a crash:
> > > > 'sorry for the inconvenience' etc (so no clues about what is
> > > > causing the problem)
>
> > > You need to give us more information if we're going to be able to
> > > help. At the very least, you'll need to copy & paste the actual error
> > > message. It would be even better if you could show us some of your
> > > code, and better yet if you could give us a small bit of code that is
> > > self contained and reproduces the problem you're experiencing.
>
> > > --
> > > Jerry
>
> > the error is a windows thing, I can make a screenshot of it, but I can
> > not copy/paste text.
> > how do I upload a png-file?
>
> > problem is that the same error happens over and over (I can reproduce
> > it), but not at the same place (the is a logging in the application so
> > that is quite easy to see.)
> > but ....I can show you my code. it's an open source EDI application.
> > but it is not a small bit of code....
> > I am more than will to show you how to reproduce the error.
>
> People coming here ask for help will vary in the amount of detail
> given, but I've rarely seen anyone as reluctant as you. It's like
> walking into an auto repair shop and asking the mechanic what's wrong
> with your car by trying to imitate the noise it makes.
>
I am reluctant because it is a lot of code ....as I told you, it
occurs during stress tests.
I am more than willing to show how to reproduce the crash.
> If your code is very largre, you're not going to get out of this
> without doing some of your own legwork. I'm sorry.
I am more than willing to do this, of course.
>
> Do this: Take your code, make a copy of it. Start removing code from
> the copy (in a controlled way) until the problem disappears. When you
> remove code don't worry about whether it produces anything useful, the
> object is to try to identify what's causing the error. Whatever code
> you removed when the error disappears should give you a clue what's
> causing it. Then, if need be, you can come back and post details. If
> you manage to get the program to a small size without eliminating the
> problem, you can post it here.
OK, I know how to trace a bug.
As I said, these are stress tests, in this case the input files are
MUCH larger than usualy.
Other stress tests run thousands of input file of regular to big
size.....
This all runs.
It does run OK on Linux (so am I looking for a bug in my program??).
The crash pops up at different places...this makes the procedure you
suggest quite awkward.
It is a hard crash of python. There is no traceback or something:
Python dies. Python is no more. It's stone dead. It has ceased to be.
It's a stiff. It's kicked the bucket etc
kind regards,
henk-jan
== 6 of 6 ==
Date: Thurs, Feb 11 2010 6:41 pm
From: aahz@pythoncraft.com (Aahz)
In article <34fcf680-1aa4-4835-9eba-3db3249f36b2@q16g2000yqq.googlegroups.com>,
hjebbers <hjebbers@gmail.com> wrote:
>
>the error is a windows thing, I can make a screenshot of it, but I can
>not copy/paste text.
In that case, you need to -- very carefully -- make sure you transcribe
exactly the message that you see on the screen.
--
Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/
"At Resolver we've found it useful to short-circuit any doubt and just
refer to comments in code as 'lies'. :-)"
==============================================================================
TOPIC: Pycrypto RSA ciphertext to string back to ciphertext issue
http://groups.google.com/group/comp.lang.python/t/fb33a49ed28f949e?hl=en
==============================================================================
== 1 of 2 ==
Date: Thurs, Feb 11 2010 5:27 pm
From: Jordan Apgar
Hey all,
I'm trying to convert the encrypted data from RSA to a string for
sending over xmlrpc and then back to usable data. Whenever I decrypt
I just get junk data. Has anyone else tried doing this? Here's some
example code:
from Crypto.PublicKey import RSA
from Crypto import Random
key = RSA.generate(384, Random.new().read)
l = str(key.encrypt("dog",""))
l = stringToTuple(l)
l = key.decrypt(tuple(l))
print l
string to tuple:
def stringToTuple(string):
if string[0] + string[-1] == "()":
items = string[1:-1]
items = items.split(',')
return items
else:
raise ValueError("Badly formatted string (missing brackets).")
thanks for any help, I've been messing with this for days and have
come up dry.
== 2 of 2 ==
Date: Thurs, Feb 11 2010 5:52 pm
From: MRAB
Jordan Apgar wrote:
> Hey all,
> I'm trying to convert the encrypted data from RSA to a string for
> sending over xmlrpc and then back to usable data. Whenever I decrypt
> I just get junk data. Has anyone else tried doing this? Here's some
> example code:
>
> from Crypto.PublicKey import RSA
> from Crypto import Random
>
> key = RSA.generate(384, Random.new().read)
> l = str(key.encrypt("dog",""))
> l = stringToTuple(l)
> l = key.decrypt(tuple(l))
> print l
>
> string to tuple:
> def stringToTuple(string):
> if string[0] + string[-1] == "()":
> items = string[1:-1]
> items = items.split(',')
> return items
> else:
> raise ValueError("Badly formatted string (missing brackets).")
>
> thanks for any help, I've been messing with this for days and have
> come up dry.
I don't know what you're trying to do with converting tuples to
bytestrings and back, but this works:
>>> key = RSA.generate(384, Random.new().read)
>>> encrypted = key.encrypt("dog", "")[0]
>>> encrypted
"NB\xe9\xcf\x88\xf8b.\x81X{\x12\xeaH\x03\xe9\xc4\xd6\xdb\x00lS\r\xc9in|\xa5\xb1'
$\x90_\xc5t$\xd0\xc40-p\x8b\xd0\x95\xdb\xa6\xf7\xc2"
>>> key.decrypt(encrypted)
'dog'
==============================================================================
TOPIC: Need debugging knowhow for my creeping Unicodephobia
http://groups.google.com/group/comp.lang.python/t/f468546c655f085f?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Feb 11 2010 5:27 pm
From: Nobody
On Wed, 10 Feb 2010 12:17:51 -0800, Anthony Tolle wrote:
> 4. Consider switching to Python 3.x, since there is only one string
> type (unicode).
However: one drawback of Python 3.x is that the repr() of a Unicode string
is no longer restricted to ASCII. There is an ascii() function which
behaves like the 2.x repr(). However: the interpreter uses repr() for
displaying the value of an expression typed at the interactive prompt,
which results in "can't encode" errors if the string cannot be converted
to your locale's encoding.
==============================================================================
TOPIC: Is a merge interval function available?
http://groups.google.com/group/comp.lang.python/t/028e0e78c5df5168?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Feb 11 2010 5:37 pm
From: Nobody
On Wed, 10 Feb 2010 23:03:29 -0500, Steve Holden wrote:
>> intervals = sorted(intervals, key = lambda x: x[0])
>
> Since Python uses lexical sorting and the intervals are lists isn't the
> key specification redundant here?
Yes, but I wanted to make it explicit.
Well, omitting the key= would change the sorting order in the event that
multiple intervals have the same start, but it still won't affect the
result of the function overall.
==============================================================================
TOPIC: timer for a function
http://groups.google.com/group/comp.lang.python/t/a52c427850c5ef89?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Feb 11 2010 6:38 pm
From: aahz@pythoncraft.com (Aahz)
In article <mailman.1986.1265390557.28905.python-list@python.org>,
mk <mrkafk@gmail.com> wrote:
>
>self.conobj = paramiko.SSHClient()
>
>self.conobj.connect(self.ip, username=self.username,
>key_filename=self.sshprivkey, port=self.port, timeout=opts.timeout)
>
>2. very slow SSH host that is hanging for 30+ seconds on key exchange.
>
>The timeout in the options regards only a socket timeout, not further
>stages of connection negotiation, so it doesn't work there.
Does paramiko offer any kind of callback? In a similar situation with
pycurl, I built my own timer into a callback.
--
Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/
"At Resolver we've found it useful to short-circuit any doubt and just
refer to comments in code as 'lies'. :-)"
==============================================================================
TOPIC: Bizarre arithmetic results
http://groups.google.com/group/comp.lang.python/t/a84e4f9c6dcb911a?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Feb 11 2010 6:44 pm
From: aahz@pythoncraft.com (Aahz)
In article <hl1j4a$j61$2@reader2.panix.com>,
Grant Edwards <invalid@invalid.invalid> wrote:
>
>Didn't we just do this one last week?
Let's do the Time Warp again!
--
Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/
"At Resolver we've found it useful to short-circuit any doubt and just
refer to comments in code as 'lies'. :-)"
==============================================================================
TOPIC: ANN: obfuscate
http://groups.google.com/group/comp.lang.python/t/6374e775e474ee1a?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Feb 11 2010 7:41 pm
From: Paul Rubin
Mark Lawrence <breamoreboy@yahoo.co.uk> writes:
>> The predecessor of the Enigma was cracked by Polish scientists years
>> before WW2 started....
> I believe that all of Enigma was eventually cracked cos of two major
> flaws.
I think it never would have been cracked if it hadn't been cracked
(whether by the Brits or the Poles) before the war started, using
commercial versions of the Enigma that they had access to. The military
Enigma and its operating methods got more sophisticated as the war went
on, and the cryptanalysts were able to keep up with it by incrementally
improving techniques that they were already using at scale. If they
were suddenly confronted with the full-blown military system in the
middle of the war, it would have been a lot harder to do anything about
it. At least, most of the Enigma-related books I've read give that
impression and even come out and say such things.
> Further, the far more powerful Geheimscreiber was also cracked at
> Bletchley by using Colossus. Sorry some years since I read the book
> about this so can't remember the title or author.
See http://en.wikipedia.org/wiki/Colossus_computer
That was almost at the end of the war though.
==============================================================================
You received this message because you are subscribed to the Google Groups "comp.lang.python"
group.
To post to this group, visit http://groups.google.com/group/comp.lang.python?hl=en
To unsubscribe from this group, send email to comp.lang.python+unsubscribe@googlegroups.com
To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.python/subscribe?hl=en
To report abuse, send email explaining the problem to abuse@googlegroups.com
==============================================================================
Google Groups: http://groups.google.com/?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home