[issue9646] Mutable default function parameter warning

2010-08-19 Thread Sérgio Surkamp

New submission from Sérgio Surkamp :

The documentation states that the default value of function parameter, if 
mutable, can change it's default value at runtime due to be evaluated only once 
on function object creation.

I would like to suggest the inclusion of an default language warning when this 
kind of construction is used, as it's Python specific behavior and can lead to 
"strange behavior" or misuse by programmers that are migrating from other 
languages to Python.

Documentation reference:
http://docs.python.org/reference/compound_stmts.html#function

--
components: None
messages: 114394
nosy: surkamp
priority: normal
severity: normal
status: open
title: Mutable default function parameter warning
type: behavior
versions: Python 2.5, Python 2.6, Python 2.7

___
Python tracker 
<http://bugs.python.org/issue9646>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7779] smtplib SASL PLAIN authentication error

2010-01-25 Thread Sérgio Surkamp

New submission from Sérgio Surkamp :

There is bug in PLAIN mechanism's of smtplib. The generated base64 string fail 
when the password start with numbers. As long as I could find, the error occur 
in method encode_plain. Using the null character (\0) in hexadecimal 
representation (\x00) seems to fix the problem.

Origin of the problem:

def encode_plain(user, password):
return encode_base64("\0%s\0%s" % (user, password), eol="")

Proposed fix:

def encode_plain(user, password):
return encode_base64("\x00%s\x00%s" % (user, password), eol="")

Current result:
>>> from email.base64mime import encode as encode_base64
>>> import base64
>>> encode_base64("\0user\0123foo", eol="")
'AHVzZXIKM2Zvbw=='
>>> f = base64.decodestring('AHVzZXIKM2Zvbw==')
>>> f
'\x00user\n3foo'

Expected result:
>>> from email.base64mime import encode as encode_base64
>>> import base64
>>> encode_base64("\x00user\x00123foo", eol="")
'AHVzZXIAMTIzZm9v'
>>> f = base64.decodestring('AHVzZXIAMTIzZm9v')
>>> f
'\x00user\x00123foo'

--
components: Extension Modules
messages: 98295
nosy: surkamp
severity: normal
status: open
title: smtplib SASL PLAIN authentication error
versions: Python 2.5, Python 2.6

___
Python tracker 
<http://bugs.python.org/issue7779>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7779] smtplib SASL PLAIN authentication error

2010-01-25 Thread Sérgio Surkamp

Sérgio Surkamp  added the comment:

The SASL protocol says that the encoded base64 should be formed from:

null + login + null + password

The smtplib is not doing it, instead its "converting" the \012 (\0 + 2 first 
chars from password) in the char "\n", and it's right in the python way to see 
the things, it's not the bug reported here. The bug is a patch to change the 
null character representation from \0 to \x00 (using the hexadecimal 
representation) in the encode_base64 call to prevent the "conversion" and 
generate the right base64 encoded string.

--
status: closed -> open

___
Python tracker 
<http://bugs.python.org/issue7779>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7779] smtplib SASL PLAIN authentication error

2010-01-25 Thread Sérgio Surkamp

Sérgio Surkamp  added the comment:

Got your point. Sorry.

--

___
Python tracker 
<http://bugs.python.org/issue7779>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4177] Crash in MIMEText on FreeBSD

2008-10-22 Thread Sérgio Surkamp

New submission from Sérgio Surkamp <[EMAIL PROTECTED]>:

If you try to create a MIMEText object from a very large string (test
case include a 40Mbytes string), the program just eat all the CPU and
with high memory usage or raise a MemoryError. Sometimes it just
deadlocks when using _charset = "iso-8859-1".

Use the submited file and the script to test the case.

** On Linux its very slow, but work's ** - the problem occour on a
FreeBSD installation.

--
components: Library (Lib), Unicode
files: test_MIMEText.tar.bz2
messages: 75097
nosy: surkamp
severity: normal
status: open
title: Crash in MIMEText on FreeBSD
type: behavior
versions: Python 2.5, Python 2.5.3
Added file: http://bugs.python.org/file11859/test_MIMEText.tar.bz2

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue4177>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4177] Crash in MIMEText on FreeBSD

2008-10-23 Thread Sérgio Surkamp

Sérgio Surkamp <[EMAIL PROTECTED]> added the comment:

Testing on Linux:

$ ulimit -m 128000
$ ulimit -v 196000
$ python test_MIMEText.py
[...]
Traceback (most recent call last):
  File "test_MIMEText.py", line 23, in 
txt = MIMEText(buffer, _subtype="plain", _charset="iso-8859-1")
  File "/usr/lib/python2.5/email/mime/text.py", line 30, in __init__
self.set_payload(_text, _charset)
  File "/usr/lib/python2.5/email/message.py", line 220, in set_payload
self.set_charset(charset)
  File "/usr/lib/python2.5/email/message.py", line 262, in set_charset
self._payload = charset.body_encode(self._payload)
  File "/usr/lib/python2.5/email/charset.py", line 386, in body_encode
return email.quoprimime.body_encode(s)
  File "/usr/lib/python2.5/email/quoprimime.py", line 198, in encode
body = fix_eols(body)
  File "/usr/lib/python2.5/email/utils.py", line 77, in fix_eols
s = re.sub(r'(?
<http://bugs.python.org/issue4177>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4177] Crash in MIMEText on FreeBSD

2008-10-24 Thread Sérgio Surkamp

Sérgio Surkamp <[EMAIL PROTECTED]> added the comment:

> Your text file is ~40 MB. Python may allocate mutiple objects bigger 
than 40 MB to create the email content. The algorithm should be 
changed to work on a stream (process small chunks, eg. 4 KB) instead 
of manipule the full text in memory (+40,000 KB).

The original text block is about 5 to 9 Mbytes - its a server generated
report by pflogsum. When it came to our mailing list processing program
(wrote by someone else in Python), it freezes building the MIMEText
object. Actually no MemoryError isn't raised, just a sudden freeze of
the running thread.

Unfortunately the test script submited does not do the same behavior,
maybe some other things are freezing the software instead of raise the
MemoryError. I have checked for blocks of try: ... except ...: pass that
could hide the problem, but found nothing.

I have already limited the size on Postfix, but the strange thing is why
this happens on FreeBSD and don't on Linux.

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue4177>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4177] Crash in MIMEText on FreeBSD

2008-10-24 Thread Sérgio Surkamp

Sérgio Surkamp <[EMAIL PROTECTED]> added the comment:

- FreeBSD version?

FreeBSD 7.0-RELEASE

 - CPU, memory?

CPU: 2 x Pentium III 1.133 GHz
Memory: 512 Mbytes

 - Full Python version?

Python 2.5.2 (r252:60911, Oct  2 2008, 10:03:50) 
[GCC 4.2.1 20070719  [FreeBSD]] on freebsd7

> On "freeze", the process uses 0% or 100% of the CPU time? You can use
the strace program to trace Python activity during the freeze.

Usually 100%. But saw it with more (using both CPU's), I think that mean
more then one thread "freezed".

I will download your trace program and do some tests with it. Ill try to
collect some informations using GDB too.

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue4177>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4177] Crash in MIMEText on FreeBSD

2008-10-24 Thread Sérgio Surkamp

Sérgio Surkamp <[EMAIL PROTECTED]> added the comment:

When I first saw the problem, the email system queue was stopped about 2
days (weekend) :-(

The email system control the number of open threads, so I wasn't opening
new threads too and issuing many warnings about it on logs

Anyway, already installed the ptrace tool and Ill start debuging when I
came back from launch

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue4177>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4177] Crash in MIMEText on FreeBSD

2008-10-28 Thread Sérgio Surkamp

Sérgio Surkamp <[EMAIL PROTECTED]> added the comment:

Ok. Something is very wrong with our code too. I have dumped the text
that's cousing the "freeze" and run it using the test case scripts. It
worked slow, but worked. It seems that our application is eating too
many memory from server (about 60Mbytes for a 2.4Mbytes message), so its
obviously a application bug/leak.

Unfortunately I cant submit the files for performance test, becose they
may contain confidential information.

As long as I can see on GDB, the python process is in a loop inside this
functions:

#0  0x2825798e in memcpy () from /lib/libc.so.7
#1  0x080a4607 in PyUnicodeUCS4_Concat ()
#2  0x080aec8d in PyEval_EvalFrameEx ()
#3  0x080b2c49 in PyEval_EvalCodeEx ()
#4  0x080b111a in PyEval_EvalFrameEx ()
#5  0x080b2c49 in PyEval_EvalCodeEx ()
#6  0x080b111a in PyEval_EvalFrameEx ()
#7  0x080b1f65 in PyEval_EvalFrameEx ()
#8  0x080b2c49 in PyEval_EvalCodeEx ()
#9  0x080b111a in PyEval_EvalFrameEx ()
#10 0x080b2c49 in PyEval_EvalCodeEx ()
#11 0x080eebd6 in PyClassMethod_New ()
#12 0x08059ef7 in PyObject_Call ()
#13 0x0805f341 in PyClass_IsSubclass ()
#14 0x08059ef7 in PyObject_Call ()
#15 0x080ac86c in PyEval_CallObjectWithKeywords ()
#16 0x080629d6 in PyInstance_New ()
#17 0x08059ef7 in PyObject_Call ()
#18 0x080af2bb in PyEval_EvalFrameEx ()
#19 0x080b2c49 in PyEval_EvalCodeEx ()
#20 0x080b111a in PyEval_EvalFrameEx ()
#21 0x080b1f65 in PyEval_EvalFrameEx ()
#22 0x080b1f65 in PyEval_EvalFrameEx ()
#23 0x080b1f65 in PyEval_EvalFrameEx ()
#24 0x080b2c49 in PyEval_EvalCodeEx ()
#25 0x080eec4e in PyClassMethod_New ()
#26 0x08059ef7 in PyObject_Call ()
#27 0x0805f341 in PyClass_IsSubclass ()
#28 0x08059ef7 in PyObject_Call ()
#29 0x080ac86c in PyEval_CallObjectWithKeywords ()
#30 0x080d4b58 in initthread ()
#31 0x28175acf in pthread_getprio () from /lib/libthr.so.3
#32 0x in ?? ()

Every memcpy call take a lot to complete, but it seems a problem with
GDB debugging as it eats 80% to 95% of the CPU and python just 1% or 2%.

How python charset conversion works from inside? It duplicates the
original string every character substitution?
If this is the case, shouldn't be better to count the substituitions,
calculate the amount of needed memory and make just one allocation for
the new string? Then copy the unmodified characters from the original to
the new string and change other chars as needed?

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue4177>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7390] inconsistent type return

2009-11-24 Thread Sérgio Surkamp

New submission from Sérgio Surkamp :

The type function returns inconsistent value depending on class hierarchy.

>>> class X:
... pass
... 
>>> x = X()
>>> type(x)

>>> class Y(object):
... pass
... 
>>> x = Y()
>>> type(x)

>>> 
>>> class Z(X):
... pass
...  
>>> x = Z()
>>> type(x)

>>> class K(Y):
... pass
...   
>>> x = K()
>>> type(x)


All should reply 'instance'. As long as I have read on documentation the
only way to change the type function return is by writing a
__metaclass__ (PEP3115).

--
components: Interpreter Core
messages: 95670
nosy: surkamp
severity: normal
status: open
title: inconsistent type return
type: behavior
versions: Python 2.6

___
Python tracker 
<http://bugs.python.org/issue7390>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com