[issue13036] time format in logging is wrong

2011-09-23 Thread Yves Dorfsman

New submission from Yves Dorfsman :

The basic time format in the logging module uses a comma instead of a dot to 
separate the seconds from the tenth of seconds:

import logging
logging.basicConfig(format='%(asctime)s %(message)s')
logging.warning('hello')

2011-09-23 09:08:53,739 hello



Using a dot seems to be more accepted, see:

ls -l --full-time

Java's default dates

python's datetime.datetime.isoformat( datetime.datetime.now() )

--
components: Library (Lib)
messages: 17
nosy: y...@zioup.com
priority: normal
severity: normal
status: open
title: time format in logging is wrong
type: behavior
versions: Python 3.2

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



[issue12888] html.parser.HTMLParser.unescape works only with the first 128 entities

2011-09-02 Thread Yves Dorfsman

New submission from Yves Dorfsman :

html.parser.HTMLParser.unescape works only with the first 128 entities, it 
leaves the other ones as they are.

--
components: None
messages: 143434
nosy: y...@zioup.com
priority: normal
severity: normal
status: open
title: html.parser.HTMLParser.unescape works only with the first 128 entities
versions: Python 3.2

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



[issue12888] html.parser.HTMLParser.unescape works only with the first 128 entities

2011-09-03 Thread Yves Dorfsman

Yves Dorfsman  added the comment:

Added a test case:
http://hg.zioup.org/cpython/rev/4accd3181061

If you set the loop < 128 then the test passes (set at 1000 right now).

--
hgrepos: +65

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



[issue11156] email.encoders.encode_base64 create a single long line

2011-02-08 Thread Yves Dorfsman

New submission from Yves Dorfsman :

email.encoders.encode_base64 returns a str of a single long line instead of 
breaking it up into 76 chars line as per RFC 2045, and as implemented by 
email.base64mime.

Solution:
In /usr/lib/python3.1/email/encoders.py, use encodebytes instead of b64encode:

--- encoders.py 2011-02-08 09:37:21.025030051 -0700
+++ encoders.py.yves2011-02-08 09:38:04.945608365 -0700
@@ -12,7 +12,7 @@
 ]
 
 
-from base64 import b64encode as _bencode
+from base64 import encodebytes as _bencode
 from quopri import encodestring as _encode

--
components: Library (Lib)
messages: 128202
nosy: y...@zioup.com
priority: normal
severity: normal
status: open
title: email.encoders.encode_base64 create a single long line
versions: Python 3.1

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



[issue11156] email.encoders.encode_base64 create a single long line

2011-02-09 Thread Yves Dorfsman

Yves Dorfsman  added the comment:

In case this does not get fixed for a long time, here is a work around 
(re-implement the encoder yourself):


.
.
.
def myencoder(msg):
  from base64 import encodebytes as _bencode

  orig = msg.get_payload()
  encdata = str(_bencode(orig), 'ascii')
  msg.set_payload(encdata)
  msg['Content-Transfer-Encoding'] = 'base64'
.
.
.
# here is an example of how to use it
fp = 
open('/usr/share/openclipart/png/animals/mammals/happy_monkey_benji_park_01.png',
 'rb')

bindata = fp.read()

x = email.mime.image.MIMEImage(bindata, _subtype='png', _encoder=myencoder)

y = x.get_payload()
print (y)
.
.
.

--

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



[issue9298] binary email attachment issue with base64 encoding

2011-02-09 Thread Yves Dorfsman

Yves Dorfsman  added the comment:

Solution:
In /usr/lib/python3.1/email/encoders.py, use encodebytes instead of b64encode:

--- encoders.py 2011-02-08 09:37:21.025030051 -0700
+++ encoders.py.yves2011-02-08 09:38:04.945608365 -0700
@@ -12,7 +12,7 @@
 ]
 
 
-from base64 import b64encode as _bencode
+from base64 import encodebytes as _bencode
 from quopri import encodestring as _encode

--

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



[issue9298] binary email attachment issue with base64 encoding

2011-02-09 Thread Yves Dorfsman

Yves Dorfsman  added the comment:

#!/usr/bin/python3.1

import unittest
import email.mime.image


class emailEncoderTestCase(unittest.TestCase):
  def setUp(self):

# point to an image
binaryfile = 
'/usr/share/openclipart/png/animals/mammals/happy_monkey_benji_park_01.png'

while len(binaryfile) == 0:
  print('Enter the name of an image: ')
  binaryfile = raw_input()

fp = 
open('/usr/share/openclipart/png/animals/mammals/happy_monkey_benji_park_01.png',
 'rb')
self.bindata = fp.read()


  def test_convert(self):

mimed = email.mime.image.MIMEImage(self.bindata, _subtype='png')

base64ed = mimed.get_payload()
# print (base64ed)

# work out if any line within the string is > 76 chars
chopped = base64ed.split('\n')
lengths = [ len(x) for x in chopped ]
toolong = [ x for x in lengths if x > 76 ]

msg = 'There is at least one line of ' + str(max(lengths)) + ' chars.'
self.assertEqual(0, len(toolong), msg)



if __name__ == '__main__':
  unittest.main()

--

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



[issue9298] binary email attachment issue with base64 encoding

2011-02-09 Thread Yves Dorfsman

Yves Dorfsman  added the comment:

Here's a better version (sorry I don't know how to remove msg128255:

--

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



[issue9298] binary email attachment issue with base64 encoding

2011-02-09 Thread Yves Dorfsman

Yves Dorfsman  added the comment:

#!/usr/bin/python3.1

import unittest
import email.mime.image


class emailEncoderTestCase(unittest.TestCase):
  def setUp(self):

# point to an image
binaryfile = ''
#binaryfile = 
'/usr/share/openclipart/png/animals/mammals/happy_monkey_benji_park_01.png'

while len(binaryfile) == 0:
  print('Enter the name of an image: ')
  binaryfile = input()

fp = open(binaryfile, 'rb')
self.bindata = fp.read()


  def test_convert(self):

mimed = email.mime.image.MIMEImage(self.bindata, _subtype='png')

base64ed = mimed.get_payload()
# print (base64ed)

# work out if any line within the string is > 76 chars
chopped = base64ed.split('\n')
lengths = [ len(x) for x in chopped ]
toolong = [ x for x in lengths if x > 76 ]

msg = 'There is at least one line of ' + str(max(lengths)) + ' chars.'
self.assertEqual(0, len(toolong), msg)



if __name__ == '__main__':
  unittest.main()

--

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



[issue9298] binary email attachment issue with base64 encoding

2011-02-10 Thread Yves Dorfsman

Yves Dorfsman  added the comment:

Test if email.encoders.encode_base64 returns a single line string, or a string 
broken up in 76 chars line, as per RFC.

--
Added file: http://bugs.python.org/file20742/issue9298-test.py

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



[issue9298] binary email attachment issue with base64 encoding

2011-02-10 Thread Yves Dorfsman

Yves Dorfsman  added the comment:

Replaces b64encode by encodebytes.

--
keywords: +patch
Added file: http://bugs.python.org/file20743/issue9298.patch

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



[issue9298] binary email attachment issue with base64 encoding

2011-02-12 Thread Yves Dorfsman

Yves Dorfsman  added the comment:

I will. Please don't use my patch yet, it breaks something else in the 
test_email:

./python Lib/test/regrtest.py test_email
[1/1] test_email
test test_email failed -- Traceback (most recent call last):
  File "/export/incoming/python/py3k/Lib/email/test/test_email.py", line 1146, 
in test_body
eq(msg.get_payload(), '+vv8/f7/')
AssertionError: '+vv8/f7/\n' != '+vv8/f7/'
- +vv8/f7/
? -
+ +vv8/f7/

1 test failed:
test_email


This is with my code patch, not the test patch. I'll look at it, and post 
again, could be the extra newline you were talking about.

--

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



[issue9298] binary email attachment issue with base64 encoding

2011-02-12 Thread Yves Dorfsman

Yves Dorfsman  added the comment:

I've got two issues with this code (Lib/email/test/test_email.py):


1128 def test_body(self):
1129 eq = self.assertEqual
1130 bytes = b'\xfa\xfb\xfc\xfd\xfe\xff'
1131 msg = MIMEApplication(bytes)
1132 eq(msg.get_payload(), '+vv8/f7/')
1133 eq(msg.get_payload(decode=True), bytes)

1) Even though it works, I find the use of a defined type as the name of a 
variable confusing (line 1130, bytes).

2) The test on line 1132 fails if the base64 payload has an extra newline at 
the end, but newlines are not an issue in base64 and are actually expected. In 
fact the test at line 1133 shows that once decoded, the bytes are reverted to 
their original form.

Is there a way to find who is the author of this test, and what was the intent? 
Would the following test be acceptable (still testing a valid base64 encoding):

eq(msg.get_payload().strip(), '+vv8/f7/')


Thanks.

--

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



[issue9298] binary email attachment issue with base64 encoding

2011-02-13 Thread Yves Dorfsman

Changes by Yves Dorfsman :


Removed file: http://bugs.python.org/file20742/issue9298-test.py

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



[issue9298] binary email attachment issue with base64 encoding

2011-02-13 Thread Yves Dorfsman

Changes by Yves Dorfsman :


Removed file: http://bugs.python.org/file20743/issue9298.patch

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



[issue9298] binary email attachment issue with base64 encoding

2011-02-13 Thread Yves Dorfsman

Yves Dorfsman  added the comment:

encoders.py:
Fixes the issue of base64'ed being > 76 chars


test_email.py:

-test that base64'ed binary is split into 76 chars lines

-WARRNING: Changes the test for MIMEApplication.test_body:
-it changes the name of the variable 'bytes' to 'bytesdata'
-it strip()s the base64ed payload before it compares it to the expected 
payload. With the change above (using encodebytes instead of b64encode in 
encoders.py), this test, as is, fails, because there is an extra newline at the 
end. Extra newlines are part of base64 and should not be an issue, as a matter 
of fact, you obtain the original bytes when you decode, regardless of having 
extra newlines. It would be good to know the intent of the original author of 
this test. Was the intent to ensure there were no newline? If so, why? Or was 
the intent to simply confirm the base64 encoding conform to the standard? If 
the latter, my change should not be an issue.

All test ("make test") passed with this patch.

--
Added file: http://bugs.python.org/file20755/issue9298-2.patch

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