[issue16419] email.message._headers is a list

2012-11-05 Thread DDarko

New submission from DDarko:

in Python 3.3 lib.email.message


  File email/message.py, line 151, in as_string
g.flatten(self, unixfrom=unixfrom)
  File email/generator.py, line 112, in flatten
self._write(msg)
  File email/generator.py, line 171, in _write
self._write_headers(msg)
  File email/generator.py, line 197, in _write_headers
for h, v in msg.raw_items():
  File email/message.py, line 441, in raw_items
return iter(self._headers.copy())
AttributeError: 'list' object has no attribute 'copy'




http://hg.python.org/cpython/file/ec00f8570c55/Lib/email/message.py
in line 443 is:
return iter(self._headers.copy())
I think that it should be:
return iter(self._headers[:])

--
components: Library (Lib)
messages: 174952
nosy: DDarko
priority: normal
severity: normal
status: open
title: email.message._headers is a list
type: crash
versions: Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16419
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16005] smtplib.SMTP().sendmail() and rset()

2012-09-24 Thread DDarko

DDarko added the comment:

I understand, in that case:

/cpython/file/default/Lib/smtplib.py
760c760,761
 self.rset()
---
 try: self.rset()
 except: pass

Solves the problem.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16005
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16005] smtplib.SMTP().sendmail() and rset()

2012-09-23 Thread DDarko

New submission from DDarko:

I'm trying to send an email as follows:

smtp = smtplib.SMTP(host, port=25)
smtp.ehlo()
smtp.sendmail(from_mail, to_mail, data)

The last line / command calls the raise.
I would like to know the reason why SMTP did not accept my email?
In theory, enough to capture the exception.
However, the exception of the last line returns:
smtplib.SMTPServerDisconnected: Connection unexpectedly closed
This is because the smtplib get replies in:
http://hg.python.org/cpython/file/default/Lib/smtplib.py
   767 (code, resp) = self.data(msg)
Then performs:
   769 self.rset()
As a result, the SMTP server disconnects the client. And instead receive info 
with reason I have information about sudden disconnection.

I do not think it should be reset, and if it is wrapped in a try.

Working snippet:
(code, resp) = self.data(msg)
if code != 250:
#self.rset()
raise SMTPDataError(code, resp)
#if we got here then somebody got our mail
return senderrs


This happens on servers mx.google.com

--
components: Library (Lib)
messages: 171029
nosy: DDarko
priority: normal
severity: normal
status: open
title: smtplib.SMTP().sendmail() and rset()
type: behavior
versions: Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16005
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16005] smtplib.SMTP().sendmail() and rset()

2012-09-23 Thread DDarko

DDarko added the comment:

The problem is that this is not my SMTP server.
I want to connect as a client with smtplib.
For this, as I said earlier it is mx.google.com



send: 'ehlo [127.0.1.1]\r\n'
reply: b'250-mx.google.com at your service, [MYIP]\r\n'
reply: b'250-SIZE 35882577\r\n'
reply: b'250-8BITMIME\r\n'
reply: b'250-STARTTLS\r\n'
reply: b'250 ENHANCEDSTATUSCODES\r\n'
reply: retcode (250); Msg: b'mx.google.com at your service, [MYIP]\nSIZE 
35882577\n8BITMIME\nSTARTTLS\nENHANCEDSTATUSCODES'
send: 'mail FROM:EMAIL size=448\r\n'
reply: b'250 2.1.0 OK o7si11249316wiz.31\r\n'
reply: retcode (250); Msg: b'2.1.0 OK o7si11249316wiz.31'
send: 'rcpt TO:EMAIL\r\n'
reply: b'250 2.1.5 OK o7si11249316wiz.31\r\n'
reply: retcode (250); Msg: b'2.1.5 OK o7si11249316wiz.31'
send: 'data\r\n'
reply: b'354  Go ahead o7si11249316wiz.31\r\n'
reply: retcode (354); Msg: b'Go ahead o7si11249316wiz.31'
data: (354, b'Go ahead o7si11249316wiz.31')
send: b'Content-Type: multipart/related; 
boundary0969887089==\r\nMIME-Version: 1.0\r\nFrom: 
\r\n\r\n--===0969887089==--\r\n.\r\n'
reply: b'550-5.7.1 [MYIP   7] Our system has detected that this message 
is\r\n'
reply: b'550-5.7.1 likely unsolicited mail. To reduce the amount of spam sent 
to Gmail,\r\n'
reply: b'550-5.7.1 this message has been blocked. Please visit\r\n'
reply: b'550-5.7.1 
http://support.google.com/mail/bin/answer.py?hl=enanswer=188131 for\r\n'
reply: b'550 5.7.1 more information. o7si11249316wiz.31\r\n'
reply: retcode (550); Msg: b'5.7.1 [MYIP   7] Our system has detected that 
this message is\n5.7.1 likely unsolicited mail. To reduce the amount of spam 
sent to Gmail,\n5.7.1 this message has been blocked. Please visit\n5.7.1 
http://support.google.com/mail/bin/answer.py?hl=enanswer=188131 for\n5.7.1 
more information. o7si11249316wiz.31'
data: (550, b'5.7.1 [MYIP   7] Our system has detected that this message 
is\n5.7.1 likely unsolicited mail. To reduce the amount of spam sent to 
Gmail,\n5.7.1 this message has been blocked. Please visit\n5.7.1 
http://support.google.com/mail/bin/answer.py?hl=enanswer=188131 for\n5.7.1 
more information. o7si11249316wiz.31')
send: 'rset\r\n'
---
Connection unexpectedly closed

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16005
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16005] smtplib.SMTP().sendmail() and rset()

2012-09-23 Thread DDarko

DDarko added the comment:

I do not understand why at all reset is performed ?
If moments later raise is done.

If someone despite error SMTPSenderRefused, SMTPRecipientsRefused or 
SMTPDataError  will still want to maintain a connection and use other data with 
session is likely he will call SMTP().rset() manually.

In my opinion, the most frequent use of the library are:

smtp = smtplib.SMTP(host, port=25)
smtp.ehlo()
try:
smtp.sendmail(from_mail, to_mail, data)
except Exception as e:
print(e)

smtp.quit()


If you wish to use session despite the error:
smtp = smtplib.SMTP(host, port=25)
smtp.ehlo()
for to_mail in mail_list:
try:
smtp.sendmail(from_mail, to_mail, data)
except smtplib.SMTPRecipientsRefused as e:
smtp.rset()
print(e)

smtp.quit()

If we do not handle exception, reset does not matter.


IMHO patch should look like this:
http://hg.python.org/cpython/file/default/Lib/smtplib.py
745d744
 self.rset()
756d754
 self.rset()
760d757
 self.rset()

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16005
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12324] [3.2] sorted(big dict)

2011-06-13 Thread DDarko

New submission from DDarko ddarko...@gmail.com:

I added an example to reproduce the bug.
From the command line the same code:
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24) [GCC 4.5.2] on linux2

$ python sort_test.py

Everything fine.

Python 3.2 (r32:88445, Mar 25 2011, 19:28:28) [GCC 4.5.2] on linux2

$ python3 sort_test.py 
Traceback (most recent call last):
  File sort_test.py, line 1821, in module
r = sorted(d.items(), key=operator.itemgetter(1), reverse=1)
TypeError: unorderable types: dict()  dict()

--
files: sort_test.py
messages: 138231
nosy: DDarko
priority: normal
severity: normal
status: open
title: [3.2] sorted(big dict)
type: behavior
versions: Python 3.2
Added file: http://bugs.python.org/file22339/sort_test.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12324
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12324] [3.2] sorted(big dict)

2011-06-13 Thread DDarko

DDarko ddarko...@gmail.com added the comment:

I am aware of this change.
In this example, I'm sort by item number 1, which is a list, and its first 
value is an int.

$ python3 sort_test.py 
class 'list'
class 'list'
class 'list'
class 'list'
class 'list'
class 'list'
...

Dict index is always No. 2. But I do not sort it.
That's why it surprised me this error because nowhere dicts should not be 
compared.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12324
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12324] [3.2] sorted(big dict)

2011-06-13 Thread DDarko

DDarko ddarko...@gmail.com added the comment:

Sure. I know what's going on.
Sorry for the inconvenience.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12324
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12324] [3.2] sorted(big dict)

2011-06-13 Thread DDarko

DDarko ddarko...@gmail.com added the comment:

I am interested in sorting only by INT0, in this example:
{k: [INT0, INT1, DICT], k: [INT0, INT1, DICT], ...}
not cmp. whole lists.

Unfortunately I can not take advantage of .values() as the keys I need.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12324
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12283] python3.2 smtplib _quote_periods

2011-06-08 Thread DDarko

New submission from DDarko ddarko...@gmail.com:

File /usr/lib/python3.2/smtplib.py, line 166, in _quote_periods

def _quote_periods(bindata):
return re.sub(br'(?m)^\.', '..', bindata)

should be:
return re.sub(br'(?m)^\.', b'..', bindata)

--
components: Extension Modules
messages: 137899
nosy: DDarko
priority: normal
severity: normal
status: open
title: python3.2 smtplib _quote_periods
versions: Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12283
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com