[issue14880] csv.reader and .writer use wrong kwargs notation in 2.7 docs

2012-08-27 Thread Petri Lehtinen

Petri Lehtinen added the comment:

Chris: Thanks for the patch. I'm not sure register_dialect()'s signature is 
good like that, though. Hynek, what do you think?

--
stage:  - patch review

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



[issue11964] Undocumented change to indent param of json.dump in 3.2

2012-08-27 Thread Petri Lehtinen

Petri Lehtinen added the comment:

I don't think the test changes are needed, because both dump() and dumps() use 
JSONEncoder internally, and all current indent testing is done using dumps() 
anyway.

More important would be to update the documentation of indent for JSONEncoder 
to match that of dump() and add the versionchanged directives to both.

--
nosy: +petri.lehtinen

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



[issue11964] Undocumented change to indent param of json.dump in 3.2

2012-08-27 Thread Petri Lehtinen

Petri Lehtinen added the comment:

Attached a new patch.

--
Added file: http://bugs.python.org/file27017/issue11964.patch

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



[issue13769] json.dump(ensure_ascii=False) return str instead of unicode

2012-08-26 Thread Petri Lehtinen

Petri Lehtinen added the comment:

It seems to me that when ensure_ascii is False, the return value will be a 
unicode instance if and only if there's a unicode object anywhere in the input.

 json.dumps({'foo': 'bar'}, ensure_ascii=False)
'{foo: bar}'

 json.dumps({'foo': u'bar'}, ensure_ascii=False)
u'{foo: bar}'

 json.dumps({'foo': u'äiti'}, ensure_ascii=False)
u'{foo: \xe4iti}'

 json.dumps({'foo': u'äiti'.encode('utf-8')}, ensure_ascii=False)
'{foo: \xc3\xa4iti}'

 json.dumps({'foo': u'äiti'.encode('utf-16')}, ensure_ascii=False)
'{foo: \xff\xfe\xe4\\ui\\ut\\ui\\u}'

--
nosy: +petri.lehtinen

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



[issue15222] mailbox.mbox writes without empty line after each message

2012-08-25 Thread Petri Lehtinen

Petri Lehtinen added the comment:

Attaching two patches.

Patch 1 changes the common message template in mailbox tests to end in a 
newline. If this wasn't done, more or less all common mailbox tests would have 
to be special cased for mbox.

Patch 2 adds a single blank line after each message in mbox. A single blank 
line is added if the added message doesn't end in a newline or ends in a single 
newline. When read back, a single newline is added to the end o the message if 
it wasn't there (and this is the reason why patch 1 is needed).

--
keywords: +patch
Added file: 
http://bugs.python.org/file26998/issue15222_v1_0001_end_test_msg_template_in_newline.patch

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



[issue15222] mailbox.mbox writes without empty line after each message

2012-08-25 Thread Petri Lehtinen

Changes by Petri Lehtinen pe...@digip.org:


--
keywords: +needs review
stage:  - patch review
Added file: 
http://bugs.python.org/file26999/issue15222_v1_0002_insert_blank_after_each_message_in_mbox.patch

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



[issue14674] Link to explain deviations from RFC 4627 in json module docs

2012-08-23 Thread Petri Lehtinen

Petri Lehtinen added the comment:

Using the word scalar sounds wrong to me. Are strings really considered 
scalars in Python? At least RFC 4627 doesn't talk about scalars.


+Since the RFC permits RFC-compliant parsers to accept input texts that are not
+RFC-compliant, this module's deserializer is technically RFC-compliant under
+default settings.

This might scare users. Maybe it should note that there are parameters that can 
be used to turn off the most harmful extra features (namely the Inf and NaN 
support).

Otherwise, the additions look very good and important.

--
nosy: +petri.lehtinen

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



[issue15393] JSONDecoder.raw_decode breaks on leading whitespace

2012-08-23 Thread Petri Lehtinen

Petri Lehtinen added the comment:

I think skipping preceding whitespace in raw_decode() wouldn't hurt, but 
skipping following whitespace would be wrong.

David: Any examples of how this could break backwards compatibility?

--
nosy: +petri.lehtinen

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



[issue13212] json library is decoding/encoding when it should not

2012-08-23 Thread Petri Lehtinen

Petri Lehtinen added the comment:

The strict flag sounds good to me, too. I don't think it should be called 
strict though, as that would imply that we comply with RFC 4627 strictly 
(which is not true without passing allow_nan=False for dump() or  passing a 
parse_constant function for load()). How about encode_any and decode_any or 
any_value?

Deprecation doesn't sound good to me. If the feature is already there, it 
probably has its users and use cases.

--
nosy: +petri.lehtinen

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



[issue15249] email.generator.BytesGenerator doesn't mangle From lines when non-ASCII bytes are present

2012-08-23 Thread Petri Lehtinen

Petri Lehtinen added the comment:

The patch looks good to me and seems to fix my test case. I find the email code 
somewhat complicated, so I'll let David decide whether it's the correct fix :)

--
stage: needs patch - patch review

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



[issue15742] SQLite3 documentation changes

2012-08-20 Thread Petri Lehtinen

Petri Lehtinen added the comment:

+   print(c.fetchone())

I don't think this line should be added because it's not there after the first 
select.

--
nosy: +petri.lehtinen

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



[issue15199] Default mimetype for javascript should be application/javascript

2012-08-20 Thread Petri Lehtinen

Petri Lehtinen added the comment:

Fixed, thanks for the patch.

--
nosy: +petri.lehtinen
resolution:  - fixed
stage:  - committed/rejected
status: open - closed

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



[issue15588] quopri: encodestring and decodestring handle bytes, not strings

2012-08-18 Thread Petri Lehtinen

Petri Lehtinen added the comment:

The encode() and decode() functions also expect binary file objects.

Attached a patch that changes documentation and docstrings. Removed the 
mentions of readline(), because read() is called on input instead, if the 
binascii module is available. Also removed the repeated descriptions of 
quotetabs and header in encodestring()'s docs.

--
keywords: +needs review, patch
nosy: +petri.lehtinen
stage:  - patch review
Added file: http://bugs.python.org/file26886/issue15588.patch

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



[issue14977] mailcap does not respect precedence in the presence of wildcards

2012-08-17 Thread Petri Lehtinen

Petri Lehtinen added the comment:

Sounds like a bug to me.

It's not too straightforward to fix, though. The order of MIME types is lost 
because they are stored as keys of a dict. AFAICS, it wouldn't help to use 
OrderedDict and checking for the wildcard type first if its index is smaller. 
Example:

image/*; foo %s; test=/bin/false
image/jpeg; bar %s; test=/bin/true
image/*; baz %s; test=/bin/true

In this case, the image/jpeg entry should be returned, but both image/* entries 
get grouped together, so they would be evaluated first and the baz %s entry 
would be returned.

The API expects the result of getcaps() (a dict) to be passed to findmatch(), 
which makes it very hard to change the caps representation. The only way I can 
think of would be to change the representation to a dict subclass with extra 
semantics. Plain dict would still have to be supported for backwards 
compatibility, though.

--
nosy: +petri.lehtinen

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



[issue14977] mailcap does not respect precedence in the presence of wildcards

2012-08-17 Thread Petri Lehtinen

Changes by Petri Lehtinen pe...@digip.org:


--
keywords:  -easy

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



[issue11062] mailbox fails to round-trip a file to a Babyl mailbox

2012-08-16 Thread Petri Lehtinen

Petri Lehtinen added the comment:

Tests are now passing on Windows, too. Closing.

--
resolution:  - fixed
status: open - closed

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



[issue6484] No unit test for mailcap module

2012-08-16 Thread Petri Lehtinen

Petri Lehtinen added the comment:

Any reason why this hasn't been backported to 3.2 or 2.7?

--
nosy: +petri.lehtinen

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



[issue4253] Maildir dumpmessage on

2012-08-16 Thread Petri Lehtinen

Petri Lehtinen added the comment:

No reply in two years, closing.

--
nosy: +petri.lehtinen
resolution:  - invalid
status: open - closed

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



[issue11062] mailbox fails to round-trip a file to a Babyl mailbox

2012-08-15 Thread Petri Lehtinen

Petri Lehtinen added the comment:

This happens because of a bug in Babyl._install_message(). When adding a 
message from file, the *** EOOH *** line is written also after the second set 
of headers.

--
nosy: +petri.lehtinen

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



[issue11062] mailbox fails to round-trip a file to a Babyl mailbox

2012-08-15 Thread Petri Lehtinen

Changes by Petri Lehtinen pe...@digip.org:


--
resolution:  - fixed
stage: needs patch - committed/rejected
status: open - closed

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



[issue11062] mailbox fails to round-trip a file to a Babyl mailbox

2012-08-15 Thread Petri Lehtinen

Changes by Petri Lehtinen pe...@digip.org:


--
versions: +Python 2.7

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



[issue11062] mailbox fails to round-trip a file to a Babyl mailbox

2012-08-15 Thread Petri Lehtinen

Petri Lehtinen added the comment:

Yeah. Enabling the Babyl tests discovered yet another bug on a code path that 
wasn't excercised at all. I'll fix it.

--
assignee:  - petri.lehtinen
resolution: fixed - 

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



[issue15122] Add an option to always rewrite single-file mailboxes in-place.

2012-08-06 Thread Petri Lehtinen

Petri Lehtinen added the comment:

Thinking about this again, I guess the original design rationale was not to 
prepare for crashes, but for the ease of implementation. It's not generally 
possible to rewrite the mailbox fully in-place, because the messages are not 
loaded into memory. If the order of messages changes, for example, a message 
can be overwritten in the mailbox file, and its contents need to be read 
afterwards.

Mutt copes with this by writing the changes to a temporary file, and then 
copying them over to the original file. This is what we should also be doing.

--

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



[issue15232] email.generator.Generator doesn't mangle From lines in MIME preamble

2012-07-23 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Thanks. The news entry should probably say 'From ' instead of 'From'.

--

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



[issue5053] http.client.HTTPMessage.getallmatchingheaders() always returns []

2012-07-07 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

My 4) actually meant that it should always return []. This is what it currently 
does, so it could be spelled out clearly in the code.

IIRC, getallmatchingheaders() cannot be emulated one-to-one using get_all(), 
because it handles continuation lines differently. That's why I thought 
removing or deprecating without fixing it would be the best.

rfc822.Message.getallmatchingheaders() is documented in Python 2, so removing 
it could make it harder to port code from Python 2 to Python 3. On the other 
hand, it's broken, so having it removed could actually make things better by 
not introducing hard-to-find bugs.

All in all, I'm not sure what's the best thing to do.

--
nosy: +ezio.melotti
versions: +Python 3.3 -Python 3.1

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



[issue5053] http.client.HTTPMessage.getallmatchingheaders() always returns []

2012-07-07 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

The CGIHTTPRequestHandler fix and test would be the best thing to start with, 
though, as it's not related to the eventual fate of getallmatchingheaders().

--
stage:  - needs patch

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



[issue15222] mailbox.mbox writes without empty line after each message

2012-07-07 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

MDAs blindly write their message to the end of the user's mail spool file. So, 
if there's no newline at the end, the mailbox gets corrupted (the new message 
is joined with the previous one).

I tested with Postfix, but this probably happens for other MDA's too.

--

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



[issue15249] email.generator.BytesGenerator doesn't mangle From lines when non-ASCII bytes are present

2012-07-04 Thread Petri Lehtinen

New submission from Petri Lehtinen pe...@digip.org:

The _handle_text function of BytesGenerator writes the payload straight through 
if there surrogateescape sequences are present, and skips the From  mangling.

--
components: email
messages: 164641
nosy: barry, petri.lehtinen, r.david.murray
priority: normal
severity: normal
stage: needs patch
status: open
title: email.generator.BytesGenerator doesn't mangle From  lines when 
non-ASCII bytes are present
versions: Python 3.2, Python 3.3

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



[issue15249] email.generator.BytesGenerator doesn't mangle From lines when non-ASCII bytes are present

2012-07-04 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Attached a test case that fails.

--
keywords: +patch
Added file: http://bugs.python.org/file26258/issue115249_test.patch

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



[issue15222] mailbox.mbox writes without empty line after each message

2012-07-04 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Well, by appending newmail to the mailbox, you effectively break the 
next-to-last message by not inserting a newline after it. This can also be 
achieved by adding a message that doesn't end in a newline to the mbox (using 
the mailbox module).

The real bug is that mailbox doesn't insert an empty line after each message, 
which it should do even if the message doesn't end in a newline. This breaks 
appending new messages (either by cat message  mbox or by mailbox.py itself), 
and it might also break mbox parsing in other programs that search for starts 
of messages using \n\nFrom .

--
components: +email
nosy: +barry, r.david.murray

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



[issue11728] mbox parser incorrect behaviour

2012-07-03 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Some thoughts on doing clever tricks to enhance mbox parsing:

http://www.jwz.org/doc/content-length.html

--

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



[issue15122] Add an option to always rewrite single-file mailboxes in-place.

2012-07-02 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

This might be the only way to fix #1599254, see 
http://bugs.python.org/issue1599254#msg30590. If another program is waiting on 
the fcntl lock (and doesn't use dotlocking), as soon as mailbox.py closes the 
original file (to replace it with a new file) and releases the lock, the other 
program writes its message to the now deleted original file.

--

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



[issue15232] email.generator.Generator doesn't mangle From lines in MIME preamble

2012-07-01 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Hi and thanks for the report. It seems that this is a bug in 
email.generator.Generator, as it fails to mangle From  lines in the MIME 
preamble (after the headers, before the first --Boundary... line).

--
components: +Library (Lib)
nosy: +petri.lehtinen
stage:  - needs patch
title: maildir parsing can split up messages with 'From ' at the start of a 
line - email.generator.Generator doesn't mangle From  lines in MIME preamble
type:  - behavior
versions: +Python 2.7, Python 3.2, Python 3.3

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



[issue15222] mailbox.mbox writes without empty line after each message

2012-06-30 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

I'm afraid that's not enough details to do any fixing. I would need a concrete 
way to reproduce the issue.

--
status: open - pending

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



[issue9559] mailbox.mbox creates new file when adding message to mbox

2012-06-29 Thread Petri Lehtinen

Changes by Petri Lehtinen pe...@digip.org:


--
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

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



[issue15222] mailbox.mbox writes without end-of-line at the file end.

2012-06-29 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

I cannot reproduce this on 3.2 or 2.7. My mailboxes always have an ending 
newline if the last message also has it. Only if the last message doesn't end 
in a newline, there's no newline in the end of the mbox. Furthermore, if a 
message doesn't end with a newline, there's no blank line between that message 
and the next.

--
nosy: +petri.lehtinen
status: open - pending

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



[issue5346] mailbox._singlefileMailbox.flush doesn't preserve file rights

2012-06-29 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Fixed.

--
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

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



[issue15222] mailbox.mbox writes without empty line after each message

2012-06-29 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Since there's no empty line between the content of mail 2 and the From  line 
of mail 3, the body of mail 2 isn't really terminated by a newline. Reading the 
message confirms this:

 import mailbox
 mbox = mailbox.mbox('mbox')
 mbox[1].get_payload()
'The mail content of mail 2...'

However, according to RFC 4155 this is a bug, as each message in a mbox must be 
terminated by an empty line.

--
title: mailbox.mbox writes without end-of-line at the file end. - mailbox.mbox 
writes without empty line after each message
versions: +Python 2.7, Python 3.3

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



[issue9559] mailbox.mbox creates new file when adding message to mbox

2012-06-28 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Fixed. I removed the extra newlines.

--
resolution:  - fixed
status: open - closed

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



[issue9559] mailbox.mbox creates new file when adding message to mbox

2012-06-28 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

See #15122 for always modifying single-file mailboxes in-place.

--

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



[issue13886] readline-related test_builtin failure

2012-06-28 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

I had exactly the same error on 3.3b1 when running the test suite with 
randomized order.

--
nosy: +petri.lehtinen

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



[issue9559] mailbox.mbox creates new file when adding message to mbox

2012-06-28 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

The _pre_mailbox_hook may be called twice, like this:

babyl = mailbox.Babyl('new_file')
babyl.add('foo\n')
babyl.remove(0)
babyl.add('bar\n')

This only affects Babyl, that writes the mailbox header in _pre_mailbox_hook. 
The mailbox is corrupted on disk until flush() is called.

--
resolution: fixed - 
status: closed - open

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



[issue15214] list.startswith() and list.remove() fails to catch consecutive items in a list.

2012-06-27 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

This happens because you modify the list while iterating over it, which makes 
the loop not work as you expect. Essentially, when you remove the item that's 
currently being pointed to, the loop skips over the next item.

An idiomatic way to remove items from a list is to use a list comprehension to 
create a new list without the unwanted items:

item_list = [apple, bananna, blueberry, coconut]
new_list = [item for item in item_list if not item.startswith('b')]

--
nosy: +petri.lehtinen
resolution:  - invalid
stage:  - committed/rejected
status: open - closed

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



[issue7360] [mailbox] race: mbox may lose data with concurrent access

2012-06-26 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

I created #15122 for adding an option to rewrite the contents of single-file 
mailboxes in-place. Closing this issue as wontfix.

--
resolution:  - wont fix
stage:  - committed/rejected
status: open - closed
superseder:  - Add an option to always rewrite single-file mailboxes in-place.

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



[issue5346] mailbox._singlefileMailbox.flush doesn't preserve file rights

2012-06-26 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Attached a patch. It copies the mode of the original mailbox file to the new 
file on flush().

--
components: +email
keywords: +patch
nosy: +barry, r.david.murray
stage: test needed - patch review
versions: +Python 3.3 -Python 3.1
Added file: http://bugs.python.org/file26166/issue5346.patch

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



[issue9559] mailbox.mbox creates new file when adding message to mbox

2012-06-26 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Attached a patch that doesn't rewrite+rename if messages have only been added. 
In this case, flush() only syncs the mailbox file to make sure all changes have 
been written to disk.

David  Barry: what do you think about including this on bugfix releases? Could 
someone depend on the file being rewritten in all situations?

--
components: +email
keywords: +patch
nosy: +barry, r.david.murray
stage: needs patch - patch review
Added file: http://bugs.python.org/file26167/issue9559.patch

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



[issue11728] mbox parser incorrect behaviour

2012-06-25 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Actually, you're right. Sorry for overlooking the RFC. But that said, the RFC 
itself refers to the same manpage as a reference that's mostly authoritative 
for those variations that are otherwise only documented in anecdotal form. So 
I guess it's quite a good reference after all :)

In Appendix A, RFC 4155 defines a set of rules for a default mbox format that 
maximizes interoperability between different mbox implementations.

The important things in the RFC concerning this issue are:

* There MUST be an empty line after each message.

* The RFC does not specify any escape syntax for message body lines starting 
with From . It says: Recipient systems are expected to parse full separator 
lines as they are documented above.

Because the RFC states that there must be an empty line after each message, and 
it aims for maximum interoperability, I think we can assume that there always 
is an empty line there. But looking for \n\nFrom  is not enough for finding 
the starting points of messages. We should actually parse the whole separator 
line which consists of From , an email address (addr-spec in RFC 2822), a 
timestamp (in UNIX ctime format without timezone), and a newline character.

I think this should be the default mode for reading mbox files. See #13698 for 
adding support for other formats.

--
components: +email
nosy: +barry
resolution: invalid - 
stage: committed/rejected - 
status: closed - open

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



[issue13698] Mailbox module should support other mbox formats in addition to mboxo

2012-06-25 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

The default mode for reading mbox files should also be modified a bit to 
maximize the support fordifferent implementations. See #11728.

I think we should still use the mboxo format by default when writing, and the 
default format of RFC 4155 when reading. We could then add a format 
parameter to the mbox constructor to alter the writing and/or reading behavior 
to match a specific mbox format.

According to RFC 4155, the best reference for different mbox formats is 
http://qmail.org./man/man5/mbox.html.

--
components: +email
nosy: +barry

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



[issue13698] Mailbox module should support other mbox formats in addition to mboxo

2012-06-25 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

endolith wrote:
  - If the mailbox is written using the mboxrd format and read using
  - the mboxo format, lines that were meant to start with From 
  - are changed to From . This is a new type of corruption.
 
 Well, yes.  So the choices are:
 
 mboxrd as default: Sometimes results in corruption
 mboxo  as default: Always results in corruption

I don't think so. Assuming that mboxo (the current default) was used
to write the mailbox, both formats sometimes result in corruption.

mboxo as default: From  lines get written (and subsequently read) as
From .

mboxrd as default: From  lines were written as From  but are
read as From .

Furthermore, if Python's mailbox module is used to write the mbox file
and another software, that only supports mboxo, is used to read it
(e.g. mutt), having mboxrd as the default would case From  lines to
be written as From . These linew would then be read as From 
by the reading software.

So, I'd like to keep the default as is, and add a parameter to change
to mboxrd when it's OK for the use case at hand. We should also
clearly document that mboxrd is recommended as it never corrupts data
if used for both reading and writing.

 Is there a way to reliably detect the format of the file and produce
 an error if it seems to be reading it wrong?

 If not, maybe just include a function that guesses the format so the
 correct option can be found easily? If there are consecutive 
 quoted lines, like this, for instance:
 
 This is the body.
 From my point of view
 there are 3 lines.
 
 then it was probably encoded with mboxrd?  If instead you find:
 
 This is the body.
 From my point of view
 there are 3 lines.
 
 then it was probably encoded with mboxo?

It's not possible to automatically detect the format. Guessing like
you suggested is too fragile. It might work on some situations, but
wouldn't work on others.

If it was possible to detect the format by guessing, I'm sure RFC 4155
would mention that, as it aims for the best possible outcome for
reading any of the formats, without knowing which format is actually
in use.

--

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



[issue1599254] mailbox: other programs' messages can vanish without trace

2012-06-25 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

It seems to me that there are three separate issues here:

1) Concurrent access to a single-file mailbox will discard some messages even 
if locking is correctly used. This is demonstrated by mailbox-test.patch, which 
despite its age applies on top of 3.2 and fails (at least for me)

2) Detecting changes to mbox files is hard and should be improved.

3) When the TOC of an mbox is re-read, the message keys should probably be kept 
intact. Otherwise, the application would need to prepare for the fact that keys 
can change without notice in the middle of a loop, for example.

The first point is a serious bug that should be fixed somehow.

The second point has been discussed in greath lengths, but it strikes me that 
the mtime tracking has not been suggested. AFAIK, this is what most/all mbox 
readers do. The toc should be re-read when the mtime changes and/or is newer 
than atime.

The third point also sounds important, but might be tricky to implement.

--
nosy: +petri.lehtinen

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



[issue11728] mbox parser incorrect behaviour

2012-06-24 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

It seems to me that ^From  is the correct way to match the start of each  
message. This is also what the qmail manual page (linked in the previous 
message) says. So closing as invalid.

--
nosy: +petri.lehtinen
resolution:  - invalid
stage: test needed - committed/rejected
status: open - closed

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



[issue15121] devguide doesn't document all bug tracker components

2012-06-21 Thread Petri Lehtinen

New submission from Petri Lehtinen pe...@digip.org:

http://docs.python.org/devguide/triaging.html#components

The undocumented components are:
- None
- Cross-Build
- email

--
components: Devguide
messages: 163321
nosy: ezio.melotti, petri.lehtinen
priority: normal
severity: normal
status: open
title: devguide doesn't document all bug tracker components

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



[issue15122] Add an option to always rewrite single-file mailboxes in-place.

2012-06-21 Thread Petri Lehtinen

New submission from Petri Lehtinen pe...@digip.org:

This seems like a common feature request. Many people suffer from the fact that 
upon flush, the contents of single-file mailboxes are written into a new file 
which is then renamed over the old file.

For example: #1599254, #5346, #7359, #7360, #9559, 

The original design rationale was probably to prepare for crashes. When changes 
are made like this, a power loss, other sytem crash, or even a bug in the 
mailbox.py code in the middle of writing the mailbox, cannot destroy all the 
data in the mailbox file.

We could add a flag to the constructors of all single-file mailboxes that 
changes this behavior to in-place rewriting. This would of course need 
accompanying documentation that warns about that the same safety guarantees 
don't apply with this flag.

--
messages: 163322
nosy: petri.lehtinen
priority: normal
severity: normal
status: open
title: Add an option to always rewrite single-file mailboxes in-place.
type: enhancement
versions: Python 3.4

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



[issue15122] Add an option to always rewrite single-file mailboxes in-place.

2012-06-21 Thread Petri Lehtinen

Changes by Petri Lehtinen pe...@digip.org:


--
components: +email
nosy: +barry, r.david.murray

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



[issue13698] Mailbox module should support other mbox formats in addition to mboxo

2012-06-21 Thread Petri Lehtinen

Changes by Petri Lehtinen pe...@digip.org:


--
nosy: +petri.lehtinen
versions: +Python 3.4 -Python 3.3

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



[issue15122] Add an option to always rewrite single-file mailboxes in-place.

2012-06-21 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

I actually already researched mutt 1.5.21 (on Ubuntu), and it seems to 
overwrite the file in-place. At least the inode number doesn't change when I 
append and/or delete files from an mbox file and save it.

--

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



[issue15122] Add an option to always rewrite single-file mailboxes in-place.

2012-06-21 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Now I also tested rmail (the Emacs email client). It seems to write-and-rename, 
at least the inode number changes. It seems to even use the mboxo format 
nowadays (used to use Babyl).

--

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



[issue15122] Add an option to always rewrite single-file mailboxes in-place.

2012-06-21 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Alpine (the successor of pine) also seems to overwrite in-place, just like mutt.

--

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



[issue15122] Add an option to always rewrite single-file mailboxes in-place.

2012-06-21 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

I looked at the source code of mutt to see how it rewrites mbox files. It does 
roughly this:

1. Block some signals.

2. Lock the mbox file (with dotlock, fcntl and flock).

3. Create a temporary file in /tmp.

4. Write messages to the temporary file, from the point where the first change 
is up to the end of the mbox file. This saves a lot of writing when the first 
change is near the end of the file.

5. Write changes from the temporary file to the mbox file, modifying the mbox 
file in-place.

6. Truncate the mbox file to the correct length.

7. Unblock signals.

If writing the changes back to the mbox file fails, the temporary file is 
copied from /tmp to near the mbox file.

--

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



[issue13698] Mailbox module should support other mbox formats in addition to mboxo

2012-06-21 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

I'm a little concerned about backwards compatibility. Someone might get upset 
if extra 's start appearing in the messages when they read the mailbox 
contents with an application that uses the mboxo format.

A little analysis on the possible corruptions that happen with these formats:

- When the mailbox is both read and written using the mboxo format, lines 
starting with From  are changed to From .

- When the mailbox is both read and written using the mboxrd format, no 
corruption happens.

- If the mailbox is written using the mboxo format and read using the mboxrd 
format, lines that were meant to start with From  are changed to From . So 
we essentially get a sligthly different corruption.

- If the mailbox is written using the mboxrd format and read using the mboxo 
format, lines that were meant to start with From  are changed to From . 
This is a new type of corruption.

--

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



[issue15036] mailbox.mbox fails to pop two items in a row, flushing in between

2012-06-18 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Perfect, fixed.

--

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



[issue9559] mailbox.mbox creates new file when adding message to mbox

2012-06-18 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

This is actually not true. When calling add(), mbox (and MMDF and Babyl) append 
the message to the file without rewriting it.

It's the following flush() call that rewrites the whole mailbox contents. I 
think this could be changed to work correctly by not setting self._pending = 
True in _singlefileMailbox.add. This way, the file wouldn't be rewritten by 
flush() if messages are only appended.

OTOH, flush() should still fsync the mailbox file (if we want to ensure that 
the changes are really written to disk). This would probably require a new flag 
in addition to self._pending, to indicate that there are unsynced changes.

--
nosy: +petri.lehtinen

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



[issue1590744] mail message parsing glitch

2012-06-18 Thread Petri Lehtinen

Changes by Petri Lehtinen pe...@digip.org:


--
nosy: +petri.lehtinen

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



[issue7360] [mailbox] race: mbox may lose data with concurrent access

2012-06-18 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Can this be closed?

--
nosy: +petri.lehtinen

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



[issue5346] mailbox._singlefileMailbox.flush doesn't preserve file rights

2012-06-18 Thread Petri Lehtinen

Changes by Petri Lehtinen pe...@digip.org:


--
nosy: +petri.lehtinen

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



[issue7359] mailbox cannot modify mailboxes in system mail spool

2012-06-18 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Every program that accesses mailboxes in the system-wide mail spool directory 
needs to have write access to it. This is because dot-locking is achieved by 
creating additional files to that directory, and it must be used (in addition 
to fcntl() locking) to avoid messing up the mailboxes because of concurrent 
access.

In Debian, /var/mail is owned by root:mail with mode 2755, and every MUA is 
setgid mail. See the Debian Policy Manual section 11.6 for more information:


http://www.debian.org/doc/debian-policy/ch-customized-programs.html#s-mail-transport-agents

If you write a MUA or MTA using Python's mailbox module, your program needs to 
have write access to /var/mail. That's the only way to do it correctly. It also 
makes the mailbox module's renaming behavior possible.

--
nosy: +petri.lehtinen
resolution:  - invalid
stage:  - committed/rejected
status: open - closed

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



[issue15036] mailbox.mbox fails to pop two items in a row, flushing in between

2012-06-16 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Yes, this is what I tried to say. It's hard for me to find a good
wording, so what would you suggest?

I also noticed now that there's a typo in the commit messages. But
those cannot be fixed anymore.

--

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



[issue15061] hmac.secure_compare() leaks information about length of strings

2012-06-15 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

For example, Django uses time independent comparison to compare signatures of 
signed cookies. A signed cookie consists of a plain-text value followed by a 
signature.

An attacker wants to construct a cookie that has a malformed value and a valid 
signature for that value. Let's assume that a signature is a string of 16 hex 
characters.

If a short-cut comparison was used, the attacker would require at most 16 tries 
to find out the first character. He first tries the signature 000...0, then 
100...0, and so on until he notices that Django takes a slightly longer time 
to respond. Now he know what's the first character of the hash, let's assume 
it's 8. He then tries 8000...0, 810...0, and so on until he finds the 
second character. He continues this until he has the correct 16 characters. 
This takes at most 16 * 16 tries.

But because Django uses a constant-time comparison function, the attacker 
cannot guess one character at a time, and he needs 16 ** 16 tries.

In real world, 16 * 16 tries is not enough, of course. But repeating the same 
requests many times, the timing variations can be used to reveal which is the 
correct character in each step.

--
nosy: +petri.lehtinen

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



[issue15036] mailbox.mbox fails to pop two items in a row, flushing in between

2012-06-15 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

As I suspected, all single-file mailboxes(mbox, MMDF, Babyl) have this issue. 
Attached a patch with tests.

--
keywords: +patch
Added file: http://bugs.python.org/file26017/issue15036.patch

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



[issue15036] mailbox.mbox fails to pop two items in a row, flushing in between

2012-06-15 Thread Petri Lehtinen

Changes by Petri Lehtinen pe...@digip.org:


--
resolution:  - fixed
stage: needs patch - committed/rejected
status: open - closed

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



[issue15036] mailbox.mbox fails to pop two items in a row, flushing in between

2012-06-14 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

The fix seems to be very simple:

diff --git a/Lib/mailbox.py b/Lib/mailbox.py
index a677729..2be4c83 100644
--- a/Lib/mailbox.py
+++ b/Lib/mailbox.py
@@ -675,6 +675,7 @@ class _singlefileMailbox(Mailbox):
 new_file.write(buffer)
 new_toc[key] = (new_start, new_file.tell())
 self._post_message_hook(new_file)
+self._file_length = new_file.tell()
 except:
 new_file.close()
 os.remove(new_file.name)

I guess all single-file mailboxes have this issue, not only mbox. I'll still 
need to add tests when I have time.

--

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



[issue15036] mailbox.mbox fails to pop two items in a row, flushing in between

2012-06-08 Thread Petri Lehtinen

New submission from Petri Lehtinen pe...@digip.org:

test_mbox is an mbox mailbox with a few messages in it.

 import mailbox
 inbox = mailbox.mbox('test_mbox')
 inbox.lock()
 inbox.popitem()
(0, mailbox.mboxMessage instance at 0x7f78016bc680)
 inbox.flush()
 inbox.unlock()
 inbox.lock()
 inbox.popitem()
(1, mailbox.mboxMessage instance at 0x7f7801653320)
 inbox.flush()
Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/lib/python2.7/mailbox.py, line 633, in flush
(self._file_length, cur_len))
mailbox.ExternalClashError: Size of mailbox file changed (expected 141289, 
found 141147)

--
components: Library (Lib)
messages: 162528
nosy: petri.lehtinen
priority: normal
severity: normal
status: open
title: mailbox.mbox fails to pop two items in a row, flushing in between
versions: Python 2.7, Python 3.2, Python 3.3

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



[issue15036] mailbox.mbox fails to pop two items in a row, flushing in between

2012-06-08 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Actually, you don't even need to unlock() and lock() the mailbox  before the 
second popitem() and flush().

--

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



[issue15017] threading.Lock documentation conflict

2012-06-06 Thread Petri Lehtinen

New submission from Petri Lehtinen pe...@digip.org:

In the description of section 16.2.2. Lock objects:

If an attempt is made to release an unlocked lock, a RuntimeError
will be raised.

In the description of Lock.release():

When invoked on an unlocked lock, a ThreadError is raised.

Apparently, ThreadError is the correct exception.

--
assignee: petri.lehtinen
components: Documentation, Library (Lib)
keywords: easy
messages: 162401
nosy: petri.lehtinen
priority: normal
severity: normal
status: open
title: threading.Lock documentation conflict
versions: Python 2.7

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



[issue15017] threading.Lock documentation conflict

2012-06-06 Thread Petri Lehtinen

Changes by Petri Lehtinen pe...@digip.org:


--
versions: +Python 3.2, Python 3.3

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



[issue14502] Document better what happens on releasing an unacquired lock

2012-06-06 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

The docs of 2.7 and 3.2 still first say that RuntimeError is raised, and then 
that a ThreadError is raised:

...
If an attempt is made to release an unlocked lock, a RuntimeError
will be raised.

...

Lock.release()
...
When invoked on an unlocked lock, a ThreadError is raised.


In 2.7 and 3.2, ThreadError is not a RuntimeError, so this is wrong.

--
nosy: +petri.lehtinen
resolution: fixed - 
status: closed - open

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



[issue9544] xdrlib.Packer().pack_fstring throws a TypeError when called with a str()

2012-06-06 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Attached a patch against 3.2. It reflects the facts that pack_fstring and 
pack_fopaque are the same methd, and pack_string, pack_opaque and pack_bytes 
are the same method.

--
versions: +Python 3.2, Python 3.3 -Python 3.1

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



[issue9544] xdrlib.Packer().pack_fstring throws a TypeError when called with a str()

2012-06-06 Thread Petri Lehtinen

Changes by Petri Lehtinen pe...@digip.org:


Added file: http://bugs.python.org/file25849/issue9544.patch

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



[issue12354] packaging.pypi.simple docs use both client and crawler name, which might be confusing

2012-06-05 Thread Petri Lehtinen

Changes by Petri Lehtinen pe...@digip.org:


--
nosy:  -petri.lehtinen

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



[issue11694] xdrlib raises ConversionError in inconsistent way

2012-06-05 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

I see one obvious issue with the patch: The ConversionErrors it creates are 
passed the struct.error or TypeError instance as a parameter. The first 
argument of these exceptions would be better, i.e.

try:
   ...
except struct.error as e:
   raise ConversionError(e.args[0])

Furthermore, my ear thinks that raises_conversion_error would be a better name 
for the decorator than raising_conversion_error.

Anyway, I think the whole ConversionError is a bit problematic, as either 
TypeError or ValueError would be the most appropriate exception, depending on 
the situation. For example:

p = Packer()
p.pack_int('foo')  # should raise a TypeError
p.pack_int(2**100) # should raise a ValueError

This would be slightly harder to implement, though, as struct.error has exactly 
the same problem.

--

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



[issue9544] xdrlib.Packer().pack_fstring throws a TypeError when called with a str()

2012-06-01 Thread Petri Lehtinen

Changes by Petri Lehtinen pe...@digip.org:


--
nosy: +petri.lehtinen

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



[issue12354] packaging.pypi.simple docs use both client and crawler variable, which might be confusing

2012-06-01 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Can this be closed?

--
nosy: +petri.lehtinen

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



[issue12354] packaging.pypi.simple docs use both client and crawler variable, which might be confusing

2012-06-01 Thread Petri Lehtinen

Changes by Petri Lehtinen pe...@digip.org:


--
status: open - pending

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



[issue11685] possible SQL injection into db APIs via table names... sqlite3

2012-05-29 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

No SQL library that I know of provides a way to escape table names. The quoting 
functions are always meant to escape string parameters. This is true for 
sqlite3_mprintf(), too (the %q and %Q options).

If you build table names from user input, your database design is somehow 
flawed.

--
resolution:  - wont fix
stage:  - committed/rejected
status: open - closed

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



[issue12014] str.format parses replacement field incorrectly

2012-05-25 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

I added some comments on rietveld. These are only nit-picking about style and 
mostly reflect my personal taste, not show stoppers in any case.

--

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



[issue14863] Update docs of os.fdopen()

2012-05-24 Thread Petri Lehtinen

Changes by Petri Lehtinen pe...@digip.org:


--
resolution:  - fixed
status: open - closed

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



[issue12014] str.format parses replacement field incorrectly

2012-05-23 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Ben Wolfson wrote:
 Maybe, but the last time it went to python-dev (in December) there
 was little discussion at all, and the patches that exist now worked
 on the codebase as it existed then.

Maybe it's pointless to bring it up on python-dev then. I just thought
that people might feel strongly about this.

 Anyway, it seems as if progress is being made on PEP 420, so perhaps
 better to let Eric take a look before bringing it up again?

Let's wait for Eric's comments, as he implemented format() in the
first place.

--

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



[issue13445] Enable linking the module pysqlite with Berkeley DB SQL instead of SQLite

2012-05-23 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Ok. Closing as wontfix then.

--
resolution:  - wont fix
stage:  - committed/rejected
status: open - closed

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



[issue13934] sqlite3 test typo

2012-05-23 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

poq: I see you have submitted a few other patches to the tracker, too. For us 
to be able to use your patches, you should sign the PSF Contributor Agreement 
as described here: http://www.python.org/psf/contrib/.

--

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



[issue14862] os.__all__ is missing some names

2012-05-23 Thread Petri Lehtinen

Changes by Petri Lehtinen pe...@digip.org:


--
title: fdopen not listed in __all__ of os.py - os.__all__ is missing some names

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



[issue14862] os.__all__ is missing some names

2012-05-23 Thread Petri Lehtinen

Changes by Petri Lehtinen pe...@digip.org:


--
resolution:  - fixed
stage: needs patch - committed/rejected
status: open - closed

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



[issue14880] csv.reader and .writer use wrong kwargs notation in 2.7 docs

2012-05-22 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

I verified from the source that it should be **fmtparams also in 2.7. Make sure 
you change the description texts, too, to s/fmtparam/fmtparams/.

--
nosy: +petri.lehtinen

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



[issue14472] .gitignore is outdated

2012-05-22 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Fixed in default and 3.2 branches, which are quite similar. Thanks for the 
patch!

Closing now. Feel free to reopen if you want to provide a patch for the 2.7 
branch, too.

--
resolution:  - fixed
status: open - closed
versions: +Python 3.2, Python 3.3

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



[issue12014] str.format parses replacement field incorrectly

2012-05-22 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Ben,

As I've said, I think that we should go for the documented behavior with the 
addition of not allowing braces inside the format string (with the exception of 
format_spec).

So AFAICS, index_string would become

index_string  ::=  any source character except ] or { or } +

 Anyway, as far as I can tell the patches would have to be reworked in
 the light of recent changes anyway. I am willing to do this if there's
 actually interest. 

Are you still willing to rework the patches?

And as I said already earlier, it wouldn't hurt if this was taken to python-dev 
once more. If there's a good, working patch ready, it might make it easier to 
gain consensus.

--
versions:  -Python 3.1

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



[issue14075] argparse: unused method?

2012-05-22 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Nobody's really sure whether it's safe to remove, so let it be there. Leaving 
it can be justified by symmetry with _get_kwargs. Closing.

--
resolution:  - wont fix
stage:  - committed/rejected
status: open - closed

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



[issue13445] Enable linking the module pysqlite with Berkeley DB SQL instead of SQLite

2012-05-22 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Still waiting for the info about whether this can be done at run-time.

--
status: open - pending

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



[issue13934] sqlite3 test typo

2012-05-22 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Both patches LGTM.

--
nosy: +petri.lehtinen

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



[issue11685] possible SQL injection into db APIs via table names... sqlite3

2012-05-22 Thread Petri Lehtinen

Changes by Petri Lehtinen pe...@digip.org:


--
nosy: +petri.lehtinen

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



[issue14804] Wrong defaults args notation in docs

2012-05-21 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

The 3.x patch looks good to me.

What comes to the 2.7 patch, there's at least the problem with fmtparam in the 
csv module (should be **fmtparams instead of [, fmtparam]). And that's were I 
stopped reviewing, so there may also be other errors. Maybe the problem(s) 
should first be fixed on a case-by-case basis and then fix the style-only 
issues with one big patch.

--

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



[issue14870] Descriptions of os.utime() and os.utimensat() use wrong notation

2012-05-21 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

os.utime() uses the same notation:

   os.utime(path[, times, *, ns=(atime_ns, mtime_ns)])

--
nosy: +petri.lehtinen
title: os.utimensat's method description uses wrong notation - Descriptions of 
os.utime() and os.utimensat() use wrong notation

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



<    1   2   3   4   5   6   7   >