Commit Graph

90 Commits

Author SHA1 Message Date
Petri Lehtinen 25652884b4 #5346: Preserve permissions of mbox, MMDF and Babyl mailbox files on flush() 2012-06-29 15:12:54 +03:00
Petri Lehtinen 5b5619f717 #5346: Preserve permissions of mbox, MMDF and Babyl mailbox files on flush() 2012-06-29 15:10:41 +03:00
Petri Lehtinen dde8cb0899 #9559: Append data to single-file mailbox files if messages are only added
If messages were only added, a new file is no longer created and
renamed over the old file when flush() is called on an mbox, MMDF or
Babyl mailbox.
2012-06-28 13:56:14 +03:00
Petri Lehtinen f29435f9f0 #9559: Append data to single-file mailbox files if messages are only added
If messages were only added, a new file is no longer created and
renamed over the old file when flush() is called on an mbox, MMDF or
Babyl mailbox.
2012-06-28 13:53:23 +03:00
Petri Lehtinen a717d563d0 #15036: Make a repeated changes and flushes work with single-file mailboxes 2012-06-15 21:01:56 +03:00
Petri Lehtinen 02653f1b11 #15036: Make a repeated changes and flushes work with single-file mailboxes 2012-06-15 20:59:31 +03:00
R David Murray b019ee752a #12537: in mailbox avoid depending on knowledge of email package internals
Previously mailbox was copying a list of attributes from one message object to
another in order to "copy the message data".  This means that any time new
attributes were added to email.message.Message, mailbox broke.  Now instead it
copies all attributes from the source object to the target object, skipping
any mailbox-object-specific attributes to produce the same clean initial
state it was previously getting by copying only the "known" attributes.

David Lam assisted in the development of this patch.
2012-04-08 22:36:07 -04:00
R David Murray c988e24240 Remove redundancy in listing of all mailbox classes in test_mailbox. 2012-04-08 21:00:27 -04:00
R David Murray f998810deb Merge: Make test_mailbox runnable via python -m unittest. 2012-04-08 18:35:35 -04:00
R David Murray 317c8d257e Make test_mailbox runnable via python -m unittest. 2012-04-08 16:46:18 -04:00
R David Murray e2922835b0 Merge #14291: if a header has non-ascii unicode, default to CTE using utf-8
In Python2, if a unicode string was assigned as the value of a header,
email would automatically CTE encode it using the UTF8 charset.
This capability was lost in the Python3 translation, and this patch
restores it.

Patch by Ali Ikinci, assisted by R. David Murray.

I also added a fix for the mailbox test that was depending (with a comment
that it was a bad idea to so depend) on non-ASCII causing message_from_string
to raise an error.  It now uses support.patch to induce an error during
message serialization.
2012-03-14 03:03:27 -04:00
R David Murray 7441a7aedd #14291: if a header has non-ascii unicode, default to CTE using utf-8
In Python2, if a unicode string was assigned as the value of a header,
email would automatically CTE encode it using the UTF8 charset.
This capability was lost in the Python3 translation, and this patch
restores it.

Patch by Ali Ikinci, assisted by R. David Murray.

I also added a fix for the mailbox test that was depending (with a comment
that it was a bad idea to so depend) on non-ASCII causing message_from_string
to raise an error.  It now uses support.patch to induce an error during
message serialization.
2012-03-14 02:59:51 -04:00
Vinay Sajip 2f24d98df0 Closes #14158: merged test file resilience fix from 3.2. 2012-03-02 01:24:13 +00:00
Vinay Sajip f959618142 Closes #14158: improved resilience to test files left behind. 2012-03-02 01:01:13 +00:00
Charles-François Natali bf38315446 Followup to issue #11867: Use socketpair(), since FreeBSD < 8 doesn't really
support multiprocessing.Event.
2011-12-20 11:48:22 +01:00
Charles-François Natali 78ed83da46 Issue #11867: Make test_mailbox.test_lock_conflict deterministic (and fix a
race condition).
2011-12-19 12:18:55 +01:00
Charles-François Natali 29b15d11bb Followup to issue #11867: Use socketpair(), since FreeBSD < 8 doesn't really
support multiprocessing.Event.
2011-12-20 11:49:25 +01:00
Charles-François Natali bfaa79a982 Issue #11867: Make test_mailbox.test_lock_conflict deterministic (and fix a
race condition).
2011-12-19 12:19:52 +01:00
Petri Lehtinen 516d80530b Merge branch 3.2 2011-11-12 21:15:24 +02:00
Petri Lehtinen c153cd3d5a Update mailbox.Maildir tests
Remove a sleep to fix transient test failures. Use skewfactor of -3 to
make it work on systems that have 1 second precision for time.time().

Closes #11999
Refs #13254
2011-11-12 21:14:53 +02:00
Petri Lehtinen 8c481b6212 Fix Maildir initialization so that maildir contents are read correctly.
Closes #13254.
2011-11-05 09:46:10 +02:00
Petri Lehtinen 8c482ee955 Fix Maildir initialization so that maildir contents are read correctly.
Closes #13254.
2011-11-05 09:44:59 +02:00
Victor Stinner bf816223df Issue #12451: Add support.create_empty_file()
We don't need to create a temporary buffered binary or text file object just to
create an empty file.

Replace also os.fdopen(handle).close() by os.close(handle).
2011-06-30 23:25:47 +02:00
R David Murray 953510560f merge #11700: proxy object close methods can now be called multiple times 2011-06-17 22:25:14 -04:00
R David Murray c88bce1580 #11700: proxy object close methods can now be called multiple times
This makes them work like the close provided by regular file objects.
2011-06-17 22:24:05 -04:00
R David Murray 4c7d21e2b3 merge #11767: use context manager to close file in __getitem__ to prevent FD leak 2011-06-17 12:56:41 -04:00
R David Murray 05ff990401 #11767: use context manager to close file in __getitem__ to prevent FD leak
All of the other methods in mailbox that create message objects take care to
close the file descriptors they use, so it seems to make sense to have
__getitem__ do so as well.

Patch by Filip Gruszczyński.
2011-06-17 12:54:56 -04:00
R David Murray 46070ebddf #11999: sync based on comparing mtimes, not mtime to system clock 2011-05-06 22:26:27 -04:00
R David Murray 94b8ee3bff #11999: sync based on comparing mtimes, not mtime to system clock 2011-05-06 22:20:34 -04:00
R David Murray caed7fe0ff #11999: sync based on comparing mtimes, not mtime to system clock 2011-05-06 22:07:19 -04:00
R David Murray 79fe2a3462 Merge #9557: eliminate 3 seconds of static overhead from test_mailbox. 2011-03-25 16:20:16 -04:00
R David Murray 66a4e12da4 Merge #9557: eliminate 3 seconds of static overhead from test_mailbox. 2011-03-25 16:16:54 -04:00
R David Murray b9a428d57d #9557: eliminate 3 seconds of static overhead from test_mailbox.
This patch doesn't quite fix the 'run in a VM with Samba share'
timing problem, but it should at least make it better.
2011-03-25 16:03:47 -04:00
Marc-André Lemburg 8f36af7a4c Normalize the encoding names for Latin-1 and UTF-8 to
'latin-1' and 'utf-8'.

These are optimized in the Python Unicode implementation
to result in more direct processing, bypassing the codec
registry.

Also see issue11303.
2011-02-25 15:42:01 +00:00
R. David Murray fc14114ca9 #11116: roll back on error during add so mailbox isn't left corrupted. 2011-02-11 22:47:17 +00:00
R. David Murray b7deff1ddc #9124: mailbox now accepts binary input and uses binary internally
Although this patch contains API changes and is rather weighty for an
RC phase, the mailbox module was essentially unusable without the patch
since it would produce UnicodeErrors when handling non-ascii input
at arbitrary and somewhat mysterious places, and any non-trivial amount
of email processing will encounter messages with non-ascii bytes.
The release manager approved the patch application.

The changes allow binary input, and reject non-ASCII string input early
with a useful message instead of failing mysteriously later.  Binary
is used internally for reading and writing the mailbox files.  StringIO
and Text file input are deprecated.

Initial patch by Victor Stinner, validated and expanded by R. David Murray.
2011-01-30 06:21:28 +00:00
Brett Cannon 653238a88d Silence some ResourceWarning in test_mailbox by using file context managers.
Also call super().tearDown() where appropriate.
2010-10-30 00:13:00 +00:00
Brian Curtin 5acec04db5 Implement #7944. Use `with` throughout the test suite. 2010-10-13 02:29:46 +00:00
Benjamin Peterson 21896a330a Merged revisions 77952,78030,78102,78104,78107,78206,78216,78296-78297,78328,78331-78332,78336,78339,78343,78378-78379,78415,78559,78717,78791 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r77952 | mark.dickinson | 2010-02-03 10:50:14 -0600 (Wed, 03 Feb 2010) | 1 line

  Fix test_inspect.py data to match recent change to inspect_fodder.py (r77942).
........
  r78030 | benjamin.peterson | 2010-02-06 14:14:10 -0600 (Sat, 06 Feb 2010) | 1 line

  check type_getattro for correctness in a descriptor corner case
........
  r78102 | andrew.kuchling | 2010-02-07 19:35:35 -0600 (Sun, 07 Feb 2010) | 1 line

  Move distutils into its own subsection; add various items
........
  r78104 | andrew.kuchling | 2010-02-08 07:22:24 -0600 (Mon, 08 Feb 2010) | 1 line

  Add two items; move a subsection
........
  r78107 | antoine.pitrou | 2010-02-08 14:25:47 -0600 (Mon, 08 Feb 2010) | 3 lines

  Clarify and correct description for ccbench and iobench.
........
  r78206 | r.david.murray | 2010-02-16 11:55:26 -0600 (Tue, 16 Feb 2010) | 3 lines

  Make the references to Popen in the description of Call
  and check_call into links.
........
  r78216 | andrew.kuchling | 2010-02-18 08:16:48 -0600 (Thu, 18 Feb 2010) | 1 line

  Add various items
........
  r78296 | andrew.kuchling | 2010-02-21 20:08:45 -0600 (Sun, 21 Feb 2010) | 1 line

  Re-word
........
  r78297 | andrew.kuchling | 2010-02-21 20:29:10 -0600 (Sun, 21 Feb 2010) | 1 line

  #7076: mention SystemRandom class near start of the module docs; reword change description for clarity.  Noted by Shawn Ligocki.
........
  r78328 | jack.diederich | 2010-02-22 12:17:16 -0600 (Mon, 22 Feb 2010) | 1 line

  fixes issue #7530, serve_forever()
........
  r78331 | andrew.kuchling | 2010-02-22 12:38:23 -0600 (Mon, 22 Feb 2010) | 1 line

  Fix comment typo
........
  r78332 | andrew.kuchling | 2010-02-22 12:42:07 -0600 (Mon, 22 Feb 2010) | 2 lines

  #7627: MH.remove() would fail if the MH mailbox was locked;
  it would call _unlock_file() and pass it a closed file object.  Noted by Rob Austein.
........
  r78336 | jack.diederich | 2010-02-22 13:55:22 -0600 (Mon, 22 Feb 2010) | 1 line

  fixes issue #1522237, bad init check in _threading_local
........
  r78339 | jack.diederich | 2010-02-22 15:27:38 -0600 (Mon, 22 Feb 2010) | 1 line

  * fix issue#7476
........
  r78343 | andrew.kuchling | 2010-02-22 16:48:41 -0600 (Mon, 22 Feb 2010) | 10 lines

  #2560: remove an unnecessary 'for' loop from my_fgets() in Parser/myreadline.c.
  Noted by Joseph Armbruster; patch by Jessica McKellar.

  The original code was 'for (;;) {...}', where ... ended
  with a 'return -2' statement and did not contain a 'break' or 'continue'
  statement.  Therefore, the body of the loop is always executed once.

  Once upon a time there was a 'continue' in the loop, but it was removed in
  rev36346, committed by mwh on Wed Jul 7 17:44:12 2004.
........
  r78378 | jack.diederich | 2010-02-23 11:23:30 -0600 (Tue, 23 Feb 2010) | 1 line

  fixup markup error
........
  r78379 | jack.diederich | 2010-02-23 13:34:06 -0600 (Tue, 23 Feb 2010) | 1 line

   issue#6442 use in operator instead of has_key
........
  r78415 | dirkjan.ochtman | 2010-02-23 22:00:52 -0600 (Tue, 23 Feb 2010) | 1 line

  Issue #7733: add explicit reference in asyncore docs.
........
  r78559 | andrew.kuchling | 2010-03-01 13:45:21 -0600 (Mon, 01 Mar 2010) | 1 line

  #7637: update discussion of minidom.unlink() and garbage collection
........
  r78717 | benjamin.peterson | 2010-03-05 21:13:33 -0600 (Fri, 05 Mar 2010) | 1 line

  settscdump is definitely an implementation detail
........
  r78791 | andrew.kuchling | 2010-03-08 06:00:39 -0600 (Mon, 08 Mar 2010) | 1 line

  Add various items
........
2010-03-21 22:03:03 +00:00
Ezio Melotti e96159335f Merged revisions 77727 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r77727 | ezio.melotti | 2010-01-24 18:58:36 +0200 (Sun, 24 Jan 2010) | 1 line

  use assert[Not]IsInstance where appropriate
........
2010-01-24 19:26:24 +00:00
Antoine Pitrou 868b578929 Merged revisions 76055 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r76055 | antoine.pitrou | 2009-11-02 12:36:51 +0100 (lun., 02 nov. 2009) | 13 lines

  Merged revisions 76034,76054 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r76034 | antoine.pitrou | 2009-11-01 22:29:33 +0100 (dim., 01 nov. 2009) | 3 lines

    This should finally fix #6896. Let's watch the buildbots.
  ........
    r76054 | antoine.pitrou | 2009-11-02 12:34:27 +0100 (lun., 02 nov. 2009) | 3 lines

    Since r76034 was successful, add a NEWS entry for it.
  ........
................
2009-11-02 11:40:19 +00:00
Antoine Pitrou 03f13445c9 Merged revisions 76034,76054 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r76034 | antoine.pitrou | 2009-11-01 22:29:33 +0100 (dim., 01 nov. 2009) | 3 lines

  This should finally fix #6896. Let's watch the buildbots.
........
  r76054 | antoine.pitrou | 2009-11-02 12:34:27 +0100 (lun., 02 nov. 2009) | 3 lines

  Since r76034 was successful, add a NEWS entry for it.
........
2009-11-02 11:36:51 +00:00
Georg Brandl 194da4a7da Merged revisions 74126,74130-74131,74149,74155,74157,74180-74183,74398 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k

................
  r74126 | alexandre.vassalotti | 2009-07-21 02:39:03 +0200 (Di, 21 Jul 2009) | 14 lines

  Merged revisions 73871 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r73871 | alexandre.vassalotti | 2009-07-06 22:17:30 -0400 (Mon, 06 Jul 2009) | 7 lines

    Grow the allocated buffer in PyUnicode_EncodeUTF7 to avoid buffer overrun.

    Without this change, test_unicode.UnicodeTest.test_codecs_utf7 crashes in
    debug mode. What happens is the unicode string u'\U000abcde' with a length
    of 1 encodes to the string '+2m/c3g-' of length 8. Since only 5 bytes is
    reserved in the buffer, a buffer overrun occurs.
  ........
................
  r74130 | alexandre.vassalotti | 2009-07-21 02:57:50 +0200 (Di, 21 Jul 2009) | 2 lines

  Add ignore rule for the Doc/tools/jinga2/ directory.
................
  r74131 | alexandre.vassalotti | 2009-07-21 04:51:58 +0200 (Di, 21 Jul 2009) | 13 lines

  Merged revisions 73683,73786 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r73683 | georg.brandl | 2009-06-29 10:44:49 -0400 (Mon, 29 Jun 2009) | 1 line

    Fix error handling in PyCode_Optimize, by Alexander Schremmer at EuroPython sprint.
  ........
    r73786 | benjamin.peterson | 2009-07-02 18:56:16 -0400 (Thu, 02 Jul 2009) | 1 line

    condense with assertRaises
  ........
................
  r74149 | ezio.melotti | 2009-07-21 22:37:52 +0200 (Di, 21 Jul 2009) | 9 lines

  Merged revisions 74148 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r74148 | ezio.melotti | 2009-07-21 23:18:27 +0300 (Tue, 21 Jul 2009) | 1 line

    #6536 fixed typo
  ........
................
  r74155 | alexandre.vassalotti | 2009-07-22 04:24:49 +0200 (Mi, 22 Jul 2009) | 2 lines

  Issue #6242: Fix deallocator of io.StringIO and io.BytesIO.
................
  r74157 | alexandre.vassalotti | 2009-07-22 05:07:33 +0200 (Mi, 22 Jul 2009) | 2 lines

  Issue #6241: Better type checking for the arguments of io.StringIO.
................
  r74180 | ezio.melotti | 2009-07-22 23:17:14 +0200 (Mi, 22 Jul 2009) | 9 lines

  Merged revisions 74179 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r74179 | ezio.melotti | 2009-07-23 00:08:49 +0300 (Thu, 23 Jul 2009) | 1 line

    #6423 has_key -> in
  ........
................
  r74181 | alexandre.vassalotti | 2009-07-22 23:27:53 +0200 (Mi, 22 Jul 2009) | 6 lines

  Clean up test_curses.

  By using __stdout__ directly, test_curses caused regrtest.py
  to duplicate the output of some test results.
................
  r74182 | alexandre.vassalotti | 2009-07-22 23:29:01 +0200 (Mi, 22 Jul 2009) | 2 lines

  Use assertGreater instead of assertTrue(x > y).
................
  r74183 | alexandre.vassalotti | 2009-07-23 01:27:17 +0200 (Do, 23 Jul 2009) | 4 lines

  Specialize assertTrue checks when possible.

  We should get slightly more helpful failure messages with this change.
................
  r74398 | georg.brandl | 2009-08-13 11:16:39 +0200 (Do, 13 Aug 2009) | 1 line

  #6694: fix old function names.
................
2009-08-13 09:34:05 +00:00
Georg Brandl ab91fdef1f Merged revisions 73715 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k

........
  r73715 | benjamin.peterson | 2009-07-01 01:06:06 +0200 (Mi, 01 Jul 2009) | 1 line

  convert old fail* assertions to assert*
........
2009-08-13 08:51:18 +00:00
Alexandre Vassalotti b27a1d29d2 Specialize assertTrue checks when possible.
We should get slightly more helpful failure messages with this change.
2009-07-22 23:27:17 +00:00
Benjamin Peterson c9c0f201fe convert old fail* assertions to assert* 2009-06-30 23:06:06 +00:00
Andrew M. Kuchling fa8153401a Merged revisions 72213 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r72213 | andrew.kuchling | 2009-05-02 15:17:28 -0400 (Sat, 02 May 2009) | 3 lines

  #1607951: Make mailbox.Maildir re-read the directories less frequently.
  This is done by recording the current time -1sec, and not re-reading unless
  the directory mod. times are >= the recorded time.
........
2009-05-03 02:52:20 +00:00
R. David Murray 548ac41079 In 3k this becomes an items() call.
Merged revisions 71046 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r71046 | r.david.murray | 2009-04-02 10:05:35 -0400 (Thu, 02 Apr 2009) | 4 lines

  Add missing iteritems() call to the for loop in mailbox.MH.get_message().

  Fixes issue2625.
........
2009-04-02 19:44:43 +00:00
Georg Brandl 6aa2d1fec7 Merged revisions 65459,65472,65481,65518,65536,65581,65609,65637,65641,65644-65645 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r65459 | gregory.p.smith | 2008-08-04 00:13:29 +0000 (Mon, 04 Aug 2008) | 4 lines

  - Issue #1857: subprocess.Popen.poll gained an additional _deadstate keyword
    argument in python 2.5, this broke code that subclassed Popen to include its
    own poll method.  Fixed my moving _deadstate to an _internal_poll method.
........
  r65472 | andrew.kuchling | 2008-08-04 01:43:43 +0000 (Mon, 04 Aug 2008) | 3 lines

  Bug 3228: Explicitly supply the file mode to avoid creating executable files,
  and add corresponding tests.
  Possible 2.5 backport candidate
........
  r65481 | gregory.p.smith | 2008-08-04 07:33:37 +0000 (Mon, 04 Aug 2008) | 22 lines

  Adds a sanity check to avoid a *very rare* infinite loop due to a corrupt tls
  key list data structure in the thread startup path.

  This change is a companion to r60148 which already successfully dealt with a
  similar issue on thread shutdown.

  In particular this loop has been observed happening from this call path:
   #0  in find_key ()
   #1  in PyThread_set_key_value ()
   #2  in _PyGILState_NoteThreadState ()
   #3  in PyThreadState_New ()
   #4  in t_bootstrap ()
   #5  in pthread_start_thread ()

  I don't know how this happens but it does, *very* rarely.  On more than
  one hardware platform.  I have not been able to reproduce it manually.
  (A flaky mutex implementation on the system in question is one hypothesis).

  As with r60148, the spinning we managed to observe in the wild was due to a
  single list element pointing back upon itself.
........
  r65518 | mark.dickinson | 2008-08-04 21:30:09 +0000 (Mon, 04 Aug 2008) | 7 lines

  Issue #1481296: (again!) Make conversion of a float NaN to an int or
  long raise ValueError instead of returning 0.  Also, change the error
  message for conversion of an infinity to an integer, replacing 'long' by
  'integer', so that it's appropriate for both long(float('inf')) and
  int(float('inf')).
........
  r65536 | andrew.kuchling | 2008-08-05 01:00:57 +0000 (Tue, 05 Aug 2008) | 1 line

  Bug 3228: take a test from Niels Gustaebel's patch, and based on his patch, check for having os.stat available
........
  r65581 | guido.van.rossum | 2008-08-07 18:51:38 +0000 (Thu, 07 Aug 2008) | 3 lines

  Patch by Ian Charnas from issue 3517.
  Add F_FULLFSYNC if it exists (OS X only so far).
........
  r65609 | antoine.pitrou | 2008-08-09 17:22:25 +0000 (Sat, 09 Aug 2008) | 3 lines

  #3205: bz2 iterator fails silently on MemoryError
........
  r65637 | georg.brandl | 2008-08-11 09:07:59 +0000 (Mon, 11 Aug 2008) | 3 lines

  - Issue #3537: Fix an assertion failure when an empty but presized dict
    object was stored in the freelist.
........
  r65641 | jesse.noller | 2008-08-11 14:28:07 +0000 (Mon, 11 Aug 2008) | 2 lines

  Remove the fqdn call for issue 3270
........
  r65644 | antoine.pitrou | 2008-08-11 17:21:36 +0000 (Mon, 11 Aug 2008) | 3 lines

  #3134: shutil referenced undefined WindowsError symbol
........
  r65645 | jesse.noller | 2008-08-11 19:00:15 +0000 (Mon, 11 Aug 2008) | 2 lines

  Fix the connection refused error part of issue 3419, use errno module instead of a static list of possible connection refused messages.
........
2008-08-12 08:35:52 +00:00
Benjamin Peterson ee8712cda4 #2621 rename test.test_support to test.support 2008-05-20 21:35:26 +00:00