Commit Graph

6632 Commits

Author SHA1 Message Date
Guido van Rossum 4bf1254342 Undocumented feature: MHMailbox sets the msg object's _mh_msgno
attribute to the (stringized) message number (if this attribute is
settable).  This is useful so users of this class can report the
correct message number (e.g. when classifying spam).

Also added a blank line before the first method of each class.
2002-09-12 05:08:00 +00:00
Guido van Rossum d560ace3a7 I don't think it's safe to use map.iteritems() in the various poll
routines.  I got some errors "dictionary changed size during
iteration" when running ZEO tests on machine while doing heavy
forground work in another window, and thinking about it, I believe
that it should be okay if readable() or writable() modifies the map.

I also finally made all the spacing conform to the Python style guide:
no space between a function/method name and the following left
parenthesis (fixed lots of occurrences), spaces around assignment
operators (fixed a few, always of the form "map=..."), and a blank
line between the class statement and the first method definition (a
few).
2002-09-12 04:57:29 +00:00
Barry Warsaw 78170048f9 Bump to 2.3.1 to pick up the missing file. 2002-09-12 03:44:50 +00:00
Guido van Rossum c8060a68ff The list(xrange(sys.maxint / 4)) test blew up on 64-bit platforms.
Because ob_size is a 32-bit int but sys.maxint is LONG_MAX which is a
64-bit value, there's no way to make this test succeed on a 64-bit
platform.  So just skip it when sys.maxint isn't 0x7fffffff.

Backport candidate.
2002-09-11 18:32:30 +00:00
Guido van Rossum 4061cbee9c Patch suggested by Hamish Lawson: add an __iter__() that returns
iter(self.keys()).
2002-09-11 18:20:34 +00:00
Jeremy Hylton fcd7353863 Use distutils.debug.DEBUG instead of distutils.core.DEBUG.
Note that distutils.core.DEBUG still works if client code uses it, but
the core code avoids circular references by using distutils.debug.
2002-09-11 16:31:53 +00:00
Jeremy Hylton 5f6228ed46 Define DEBUG in a separate module to resolve circular references. 2002-09-11 16:28:52 +00:00
Michael W. Hudson 02ff6a9952 A slight change to SET_LINENO-less tracing.
This makes things a touch more like 2.2.  Read the comments in
Python/ceval.c for more details.
2002-09-11 15:36:32 +00:00
Michael W. Hudson 519a342d79 Bunch more tests. 2002-09-11 14:47:51 +00:00
Barry Warsaw fbcde75c70 get_payload(): Document that calling it with no arguments returns a
reference to the payload.
2002-09-11 14:11:35 +00:00
Mark Hammond 51a0ae3f97 Ignore IOError exceptions when writing the message. 2002-09-11 13:22:35 +00:00
Barry Warsaw ccd9e75b18 test_both(): I believe this was a typo: m is only defined if no
exception occurred so it should only be closed in the else clause.
Without this change we can an UnboundLocalError on Linux:

Traceback (most recent call last):
  File "Lib/test/test_mmap.py", line 304, in ?
    test_both()
  File "Lib/test/test_mmap.py", line 208, in test_both
    m.close()
UnboundLocalError: local variable 'm' referenced before assignment
2002-09-11 02:56:42 +00:00
Barry Warsaw 1a5b9562d6 test_quote_unquote(): Added a test for the rfc822.unquote() patch
(adapted from Quinn Dunkan's mimelib SF patch #573204).
2002-09-11 02:32:57 +00:00
Barry Warsaw 4e09d5c6d6 unquote(): Didn't properly de-backslash-ify. This patch (adapted from
Quinn Dunkan's mimelib SF patch #573204) fixes the problem.
2002-09-11 02:32:14 +00:00
Barry Warsaw bc6edac8df test_utils_quote_unquote(): Test for unquote() properly
de-backslash-ifying.
2002-09-11 02:31:24 +00:00
Barry Warsaw 184d55a897 rfc822.unquote() doesn't properly de-backslash-ify in Python prior to
2.3.  This patch (adapted from Quinn Dunkan's SF patch #573204) fixes
the problem and should get ported to rfc822.py.
2002-09-11 02:22:48 +00:00
Guido van Rossum ef1b41ba0a At Jim Fulton's request, increase the maxstring value of _saferepr to
a more reasonable value.

Backport candidate.
2002-09-10 21:57:14 +00:00
Tim Peters 1b5112ac97 I left some debugging junk in here; removed it. Also replaced a few
more instances of the bizarre "del f; del m" ways to spell .close() (del
won't do any good here under Jython, etc).
2002-09-10 21:19:55 +00:00
Tim Peters 4f4f4d70af A few days ago a test was added here to ensure that creating an mmap
with a size larger than the underlying file worked on Windows.  It
does <wink>.  However, merely creating an mmap that way has the side
effect of growing the file on disk to match the specified size.  A
*later* test assumed that the file on disk was still exactly as it was
before the new "size too big" test was added, but that's no longer true.
So added a hack at the end of the "size too big" test to truncate the
disk file back to its original size on Windows.
2002-09-10 20:49:15 +00:00
Barry Warsaw 034b47acfe _parsebody(): Instead of raising a BoundaryError when no start
boundary could be found -- in a lax parser -- the entire body is
assigned to the message payload.
2002-09-10 16:14:56 +00:00
Barry Warsaw b1c1de3805 Import _isstring() from the compatibility layer.
_handle_text(): Use _isstring() for stringiness test.

_handle_multipart(): Add a test before the ListType test, checking for
stringiness of the payload.  String payloads for multitypes means a
message with broken MIME chrome was parsed by a lax parser.  Instead
of raising a BoundaryError in those cases, the entire body is assigned
to the message payload (but since the content type is still
multipart/*, the Generator needs to be updated too).
2002-09-10 16:13:45 +00:00
Barry Warsaw 356afac41f _isstring(): Factor out "stringiness" test, e.g. for StringType or
UnicodeType, which is different between Python 2.1 and 2.2.
2002-09-10 16:09:06 +00:00
Barry Warsaw 45d9bde6c1 _ascii_split(): Don't lstrip continuation lines. Closes SF bug #601392. 2002-09-10 15:57:29 +00:00
Barry Warsaw 24d45df3f2 test_splitting_first_line_only_is_long(): New test for SF bug #601392,
broken wrapping of long ASCII headers.
2002-09-10 15:46:44 +00:00
Barry Warsaw dad90c202a A sample message with broken MIME boundaries. 2002-09-10 15:43:30 +00:00
Andrew M. Kuchling df453fd026 The .preprocess() method didn't work, because it didn't add the input file
to the command-line arguments.  Fix this by adding the source filename.
2002-09-09 12:16:58 +00:00
Andrew M. Kuchling 4013cbd06b Include an empty body when checking for a header file
(Bugfix candidate for 2.2, and likely 2.1 as well)
2002-09-09 12:10:00 +00:00
Martin v. Löwis 2412853f8e Fix escaping of non-ASCII characters. 2002-09-09 06:17:05 +00:00
Raymond Hettinger 57e79459fa shutil.copyfile(src,dst) was clobbering the file when the src and dst were
the same.   Added check to verify the two names are not the same.  Does not
check the actual files to see if there is a symbolic link.

Closes SF bug 490165 and Tzot's patch 604600.
2002-09-08 20:43:59 +00:00
Jeremy Hylton d750036b20 A little refactoring.
Add read(), write(), and readwrite() helper functions to shorten poll
functions.  Use get() instead of try/except KeyError for lookup.
XXX How could the lookup ever fail?

Remove module-level DEBUG flag.

Use iteritems() instead of items() when walking the socket map.

Reformat the functions I touched so that are consistently Pythonic.
2002-09-08 00:14:54 +00:00
Neal Norwitz 522076d1d6 Try to get test to pass on Windows 2002-09-07 05:56:21 +00:00
Raymond Hettinger 05212fc7f3 Change UserDict to IterableUserDict 2002-09-07 04:48:03 +00:00
Jack Jansen 522e7694ed Skip UDP testing for MacPython (for now), it hangs. This may be due to
GUSI/Threading interaction, I'm not sure, but I don't have the time to fix this right now.
2002-09-06 21:57:50 +00:00
Raymond Hettinger ca2f537e32 Have os.environ() inherit from the iterable version of UserDict.
Closes SF bug 605731.
2002-09-06 19:36:31 +00:00
Walter Dörwald 9ab7dd4d5b Add a test case that checks that the proper exception is raises
when the replacement from an encoding error callback is itself
unencodable.
2002-09-06 17:21:40 +00:00
Walter Dörwald 5ccaf8f129 Apply diff3.txt (plus additional documentation)
from SF patch http://www.python.org/sf/554192

This adds two new functions to mimetypes:
guess_all_extensions() which returns a list of all known
extensions for a mime type, and add_type() which adds one
mapping between a mime type and an extension.
2002-09-06 16:15:58 +00:00
Barry Warsaw e99e2f53e7 test_set_param(), test_del_param(): Test RFC 2231 encoding support by
Oleg Broytmann in SF patch #600096.  Whitespace normalized by Barry.
2002-09-06 03:56:26 +00:00
Barry Warsaw 3c25535dc8 _formatparam(), set_param(): RFC 2231 encoding support by Oleg
Broytmann in SF patch #600096.  Specifically, the former function now
encodes the triplets, while the latter adds optional charset and
language arguments.
2002-09-06 03:55:04 +00:00
Barry Warsaw 470288c54e test_mondo_message(): "binary" is not a legal content type, so with
the previous RFC 2045, $5.2 repair to get_content_type() this
subpart's type will now be text/plain.
2002-09-06 03:41:27 +00:00
Barry Warsaw 58fb61cce5 test_replace_header(): New test for Message.replace_header(). 2002-09-06 03:39:59 +00:00
Barry Warsaw 229727fa07 replace_header(): New method given by Skip Montanaro in SF patch
#601959.  Modified slightly by Barry (who added the KeyError in case
the header is missing.
2002-09-06 03:38:12 +00:00
Neal Norwitz b567392bbf SF bug # 585792, Invalid mmap crashes Python interpreter
Raise ValueError if user passes a size to mmap which is larger
than the file.
2002-09-05 21:48:07 +00:00
Neal Norwitz 609ba81cdb SF # 555779, import user doesn't work with CGIs 2002-09-05 21:08:25 +00:00
Kurt B. Kaiser 63857a454d M PyShell.py
M RemoteDebugger.py
M ScriptBinding.py

Restart the execution server with a clean environment and execute the
active module from scratch upon activation of Run/F5.

Add functionality to PyShell.py to restart the execution server in a new
subprocess.  The server makes a connection to the Idle client which sends a
block of code to be executed.

Modify ScriptBinding.py to restart the subprocess upon Run/F5, assuming that
an execution is not currently in progress.  Remove Import Module functionality,
not required now that the code is executed in a clean environment.

If the Debugger is active, also restart the subprocess side of the split
debugger.  Add functionality to RemoteDebugger.py to support this.

At this time breakpoints will be lost in the subprocess if Run/F5 is activated.
A subsequent checkin of PyShell.py will implement reloading of the breakpoints
into the subprocess debugger.  I'm keeping this separate as the design may
change.
2002-09-05 02:31:20 +00:00
Raymond Hettinger 342456d5d2 smptlib did not handle empty addresses.
The problem was that it expected rfc822.parseaddr() to return None
upon a parse failure.  The actual, documented return value for a
parse failure is (None, None).

Closes SF bug 602029.
2002-09-05 01:14:07 +00:00
Walter Dörwald 5c1ee17742 Change the unicode.translate docstring to document that
Unicode strings (with arbitrary length) are allowed
as entries in the unicode.translate mapping.

Add a test case for multicharacter replacements.

(Multicharacter replacements were enabled by the
PEP 293 patch)
2002-09-04 20:31:32 +00:00
Guido van Rossum 472c5229c4 Delete the %c test from test_date_time() untill Brett Cannon has time
to fix it.  (It fails when the day of the month is a 1-digit number,
because %c produces space+digit there, while strptime seems to expect
zero+digit somehow.)
2002-09-03 21:10:10 +00:00
Jeremy Hylton d4c472c3e2 Move code for reading chunked responses in helper function,
along with some small changes (e.g. use of +=).
2002-09-03 20:49:06 +00:00
Guido van Rossum 602d45194c Add a custom __str__ method to KeyError that applies repr() to the
missing key.  (Also added a guard to SyntaxError__str__ to prevent
calling PyString_Check(NULL).)
2002-09-03 20:24:09 +00:00
Jeremy Hylton d229b3ae04 SF bug [ 600488 ] Robustness tweak to httplib.py
If the transfer-encoding is unknown, ignore it.  Suggested by Tom
Emerson.
2002-09-03 19:24:24 +00:00