Commit Graph

3586 Commits

Author SHA1 Message Date
Raymond Hettinger e6c470f255 SF bug #1770766: weakref proxy has incorrect __nonzero__ behavior. 2005-03-27 03:04:54 +00:00
Walter Dörwald 09a3f2cc2f Add tests for tuple, list and UserList that initialize the object from
various iterables.

(Copied from test_deque.py as suggested by Jim Jewett in SF bug #1166274)
2005-03-22 22:43:28 +00:00
Walter Dörwald c448a91ee8 Fix typo. 2005-03-22 11:22:38 +00:00
Walter Dörwald 7355e8133d Add list tests that ensure that remove() removes the first occurrence.
(Copied from test_deque.py as suggested by Jim Jewett in SF bug #1166274)
2005-03-21 21:31:47 +00:00
Raymond Hettinger d73202c596 Apply remove's mutation test after every equality test. 2005-03-19 00:00:51 +00:00
Raymond Hettinger 4aec61e0fc Add a remove() method to collections.deque objects. 2005-03-18 21:20:23 +00:00
Raymond Hettinger bea3f6f5c7 Bug #1163325: "special" decimals aren't hashable 2005-03-15 04:59:17 +00:00
Walter Dörwald 729c31f5c3 Reset internal buffers when seek() is called. This fixes SF bug #1156259. 2005-03-14 19:06:30 +00:00
Johannes Gijsbers a5855d5ace Patch #1159931/bug #1143895: inspect.getsource failed when functions,
etc., had comments after the colon, and some other cases. This patch
take a simpler approach that doesn't rely on looking for a ':'. Thanks
Simon Percivall!
2005-03-12 16:37:11 +00:00
Raymond Hettinger f77d0334f3 Revised the itertools quantifier recipes to match the performance of the
new builtins.
2005-03-11 22:17:30 +00:00
Raymond Hettinger 96229b1918 Add two new functions, any() and all(). 2005-03-11 06:49:40 +00:00
Raymond Hettinger 26e512a04f Test partial() with bound/unbound methods. 2005-03-11 06:48:49 +00:00
Brett Cannon 01668a1ab9 Fix test for socket.getfqdn() to also include the name returned by
socket.gethostname() in the check for a valid return.

Also clarified docs (official and docstring) that the value from gethostname()
is returned if gethostbyaddr() doesn't do the job.
2005-03-11 00:04:17 +00:00
Raymond Hettinger 984f9bb714 operator.itemgetter() and operator.attrgetter() now support extraction
of multiple fields.  This provides direct support for sorting by
multiple keys.
2005-03-09 16:38:48 +00:00
Martin v. Löwis e2713becd8 Build with --disable-unicode again. Fixes #1158607.
Will backport to 2.4.
2005-03-08 15:03:08 +00:00
Martin v. Löwis b60ae99601 Convert file names of posix.access according to the file system encoding. 2005-03-08 09:10:29 +00:00
Raymond Hettinger c8b6d1bd8c Make functional.partial() more closely match the spec by emulating
some useful features of regular functions:

* Made weak referencable.
* Allow attribute access so a user can set __name__, __doc__, etc.
2005-03-08 06:14:50 +00:00
Greg Ward 50682d0f78 SF #818006: merge from release24-maint branch: add useful read-only
attributes to oss_audio_device object: 'closed', 'name', and 'mode'.
2005-03-07 01:41:11 +00:00
Martin v. Löwis 78be7df9e4 Patch #918101: Add tarfile open mode r|* for auto-detection of the
stream compression; add, for symmetry reasons, r:* as a synonym of r.
2005-03-05 12:47:42 +00:00
Brett Cannon 653a5adcca Tweak test_communicate_stderr so that it works when run under a pydebug build. 2005-03-05 06:40:52 +00:00
Greg Ward 40407943b7 SF #1149508: ensure textwrap handles hyphenated numbers correctly,
eg. "2004-03-04" is not broken across lines.  (Merged from 2.4 branch.)
2005-03-05 02:53:17 +00:00
Peter Astrand f7f1bb7ff5 Only run extensive subprocess tests if -usubprocess to regrtest is specified. Fixes #1124637 2005-03-03 20:47:37 +00:00
Peter Astrand cbac93c229 Added three more testcases: Using communicate with only one of
stdin/stdout/stderr redirected.
2005-03-03 20:24:28 +00:00
Raymond Hettinger b67cc80bb9 SF bug #1155938: Missing None check for __init__(). 2005-03-03 16:45:19 +00:00
Martin v. Löwis 6ce7ed23d0 Revert previous checkin on getargs 'L' code. Try to convert all
numbers in PyLong_AsLongLong, and update test suite accordingly.
Backported to 2.4.
2005-03-03 12:26:35 +00:00
Martin v. Löwis 7fe60c0a0a Patches #749830, #1144555: allow UNIX mmap size to default to current
file size.
2005-03-03 11:22:44 +00:00
Martin v. Löwis c5574e809b Patch #1117454: Remove code to special-case cookies without values
in LWPCookieJar. Backported to 2.4.
2005-03-03 10:57:37 +00:00
Martin v. Löwis 4ea3eade51 Patch #1117339: Add cookielib special name tests.
Backported to 2.4.
2005-03-03 10:48:12 +00:00
Martin v. Löwis ff232d7230 Clear internal call error in 'L' format. Fixes #723201.
Backported to 2.4.
2005-03-03 09:24:38 +00:00
Martin v. Löwis df24153f65 Patch #1107973: tarfile.ExFileObject iterators. 2005-03-03 08:17:42 +00:00
Brett Cannon e94e74a8e1 Make test__locale more fine-grained. Now test localeconv and nl_langinfo
individually as tests.

Also improved output when the test fails.
2005-03-01 03:15:50 +00:00
Raymond Hettinger 9c323f8de4 SF patch #941881: PEP 309 Implementation (Partial Function Application).
Combined efforts of many including Peter Harris, Hye-Shik Chang,
Martin v. Löwis, Nick Coghlan, Paul Moore, and Raymond Hettinger.
2005-02-28 19:39:44 +00:00
Martin v. Löwis c2a0ac20b7 Patch #1049151: adding bool support to xdrlib.py.
Also add xdrlib._test into the test suite.
2005-02-24 20:22:10 +00:00
Raymond Hettinger afd842f5b2 Teach the peepholer to fold unary operations on constants.
Afterwards, -0.5 loads in a single step and no longer requires a runtime
UNARY_NEGATIVE operation.
2005-02-20 12:46:54 +00:00
Raymond Hettinger 57e7447c44 * Beef-up tests for str.count().
* Speed-up str.count() by using memchr() to fly between first char matches.
2005-02-20 09:54:53 +00:00
Raymond Hettinger 7cbf1bcb3e * Beef-up testing of str.__contains__() and str.find().
* Speed-up "x in y" where x has more than one character.

The existing code made excessive calls to the expensive memcmp() function.
The new code uses memchr() to rapidly find a start point for memcmp().
In addition to knowing that the first character is a match, the new code
also checks that the last character is a match.  This significantly reduces
the incidence of false starts (saving memcmp() calls and making quadratic
behavior less likely).

Improves the timings on:
    python -m timeit -r7 -s"x='a'*1000" "'ab' in x"
    python -m timeit -r7 -s"x='a'*1000" "'bc' in x"

Once this code has proven itself, then string_find_internal() should refer
to it rather than running its own version.  Also, something similar may
apply to unicode objects.
2005-02-20 04:07:08 +00:00
Walter Dörwald af3b39a182 Add support for negative indices in UserString.MutableString.__setitem__
and UserString.MutableString.__delitem__.
2005-02-18 13:22:43 +00:00
Walter Dörwald 1fd4db9c6c Fix copy & paste error. 2005-02-17 22:31:28 +00:00
Walter Dörwald 7f79152929 Add tests for the methods added by UserString.MutableString. 2005-02-17 22:03:31 +00:00
Martin v. Löwis 5510f65f5a Avoid using items() in environ.update(). Fixes #1124513.
Will backport to 2.4.
2005-02-17 21:23:20 +00:00
Walter Dörwald 3040b19976 Add a basic test for UserString.MutableString. 2005-02-17 18:51:48 +00:00
Michael W. Hudson ee319f66ab Fix
[ 1124295 ] Function's __name__ no longer accessible in restricted mode

which I introduced with a bit of mindless copy-paste when making
__name__ writable.  You can't assign to __name__ in restricted mode,
which I'm going to pretend was intentional :)
2005-02-17 10:37:21 +00:00
Tim Peters f0db38dbf8 Whitespace normalization. 2005-02-15 21:50:12 +00:00
Michael W. Hudson f058858347 Test that SystemExits are handled properly by the exit machinery. I
broke the "raise SystemExit(46)" case when doing new-style exceptions,
but I'd much rather have found out here than in test_tempfile (growl).
2005-02-15 15:26:11 +00:00
Michael W. Hudson a1fb4c891f Exceedingly minor tweak. 2005-02-15 15:22:37 +00:00
Fred Drake 22c0706a58 fix decoding in _stringify to not depend on the default encoding
(closes SF bug #1115989)
2005-02-11 17:59:08 +00:00
Brett Cannon 64d904b715 Remove set conversion optimization test (backed out of Python/compile.c in rev.
2.344).
2005-02-10 20:40:29 +00:00
Fred Drake ba613c3410 accept datetime.datetime instances when marshalling;
dateTime.iso8601 elements still unmarshal into xmlrpclib.DateTime objects
2005-02-10 18:33:30 +00:00
Andrew M. Kuchling bfd7d6a0ea Fix typo 2005-02-10 13:24:50 +00:00
Walter Dörwald a9620d1e2b Fix stupid typo: Don't read from a writer. 2005-02-08 10:10:01 +00:00
Raymond Hettinger 7fcb7869ba Adopt Skip's idea to optimize lists of constants in the context
of a "in" or "not in" test.
2005-02-07 19:32:38 +00:00
Raymond Hettinger a164574937 Transform "x in (1,2,3)" to "x in frozenset([1,2,3])".
Inspired by Skip's idea to recognize the throw-away nature of sequences
in this context and to transform their type to one with better performance.
2005-02-06 22:05:42 +00:00
Walter Dörwald 1f1d252f51 Add a test for UTF-16 reading where the byte sequence doesn't start with
a BOM.
2005-02-04 14:15:34 +00:00
Martin v. Löwis 1d11de6dbd Revert os.py 1.75, and directly implement update.
Fixes #1110478 and #1100235.
2005-01-29 13:29:23 +00:00
Raymond Hettinger 9feb267caf Do not fold a constant if a large sequence will result.
Saves space in the presence of code like: (None,)*10000
2005-01-26 12:50:05 +00:00
Martin v. Löwis 4d394dfebb Truncate st_?time before comparing it with ST_?TIME in the tests. 2005-01-23 09:19:22 +00:00
Walter Dörwald 1083c248df Add a slice test with high < low. 2005-01-21 21:16:51 +00:00
Guido van Rossum 5a8a03784e Use descriptors. 2005-01-16 00:25:31 +00:00
Guido van Rossum fee7b93c60 Use decorators. 2005-01-16 00:21:28 +00:00
Tim Peters 608c2fff69 Whitespace normalization. 2005-01-13 17:37:38 +00:00
Skip Montanaro 0af3ade6aa Add strptime() constructor to datetime class. Thanks to Josh Spoerri for
the changes.
2005-01-13 04:12:31 +00:00
Andrew McNamara 7f2053eff3 Add counting of source iterator lines to the reader object - handy for
user error messages (otherwise difficult to do without instrumenting
the source).
2005-01-12 11:17:16 +00:00
Andrew McNamara 0f0599ddc1 When quoting=QUOTE_NONNUMERIC, the reader now casts unquoted fields
to floats.
2005-01-12 09:45:18 +00:00
Andrew McNamara 5d45a8dc22 Fix logic problem in quoting=csv.QUOTE_ALL, quotechar=None check, add test. 2005-01-12 08:16:17 +00:00
Andrew McNamara c89f284df8 When using QUOTE_NONNUMERIC, we now test for "numericness" with
PyNumber_Check, rather than trying to convert to a float.  Reimplemented
writer - now raises exceptions when it sees a quotechar but neither
doublequote or escapechar are set. Doublequote results are now more
consistent (eg, single quote should generate """", rather than "",
which is ambiguous).
2005-01-12 07:44:42 +00:00
Andrew McNamara 31d8896ee2 Rename csv.set_field_limit to csv.field_size_limit (since it both sets and
gets).
2005-01-12 03:45:10 +00:00
Andrew McNamara af1e312b3b Improve test coverage fractionally. 2005-01-12 01:55:21 +00:00
Andrew McNamara e4d05c4f93 Set an upper limit on the size of the field buffer, raise an exception
when this limit is reached. Limit defaults to 128k, and is changed
by module set_field_limit() method. Previously, an unmatched quote
character could result in the entire file being read into the field
buffer, potentially exhausting virtual memory.
2005-01-11 07:32:02 +00:00
Raymond Hettinger a422c34b70 SF 1098985: set objects cannot be marshalled 2005-01-11 03:03:27 +00:00
Andrew McNamara 7130ff5eb9 Replace python-coded validation of csv dialect with a call to the C
dialect type (which has a better idea of what is and isn't valid).
2005-01-11 02:22:47 +00:00
Andrew McNamara 8c94b42f31 No longer attempt to instantiate python classes describing dialects. This
was done because we were previously performing validation of the dialect
from python, but this is now down within the C module. Also, the method
we were using to detect classes did not work with new-style classes.
2005-01-11 02:18:36 +00:00
Andrew McNamara 86625972a1 Allow dialect-describing keywords to be supplied to register_dialect,
record objects of internal dialect type, rather than instances of
python objects.
2005-01-11 01:28:33 +00:00
Walter Dörwald 9fa0946771 Fix and test for SF bug #1098990: codec readline() splits lines apart. 2005-01-10 12:01:39 +00:00
Andrew McNamara 36a7691c2d Fix parsing of csv files with escapes (escape character previously would be
left in stream).
2005-01-10 01:04:40 +00:00
Johannes Gijsbers 41e4faa82b Patch #712317: In URLs such as http://www.example.com?query=spam, treat '?' as
a delimiter. Previously, the 'network location' (<authority> in RFC 2396) would
become 'www.example.com?query=spam', while RFC 2396 does not allow a '?' in
<authority>. See bug #548176 for further discussion.
2005-01-09 15:29:10 +00:00
Johannes Gijsbers a3beee185c Clean up tests by reusing functions from other modules:
* replace deltree with shutil.rmtree()
* replace mkdirs with os.makedirs()
* fold touchfile into GlobTests.mktemp()
2005-01-08 13:28:54 +00:00
Johannes Gijsbers 836f5433f7 Patch #943206:
`glob.glob()` currently calls itself recursively to build a list of matches of
the dirname part of the pattern and then filters by the basename part. This is
effectively BFS. ``glob.glob('*/*/*/*/*/foo')`` will build a huge list of all
directories 5 levels deep even if only a handful of them contain a ``foo``
entry. A generator-based recusion would never have to store these list at once
by implementing DFS. This patch converts the `glob` function to an `iglob`
recursive generator . `glob()` now just returns ``list(iglob(pattern))``.

I also cleaned up the code a bit (reduced duplicate `has_magic()` checks and
created a second `glob0` helper func so that the main loop need not be
duplicated).

Thanks to Cherniavsky Beni for the patch!
2005-01-08 13:13:19 +00:00
Tim Peters 711906e0c2 threading._DummyThread.__init__(): document obscure new code.
test_threading.test_foreign_thread():  new test does a basic check that
"foreign" threads can using the threading module, and that they create
a _DummyThread instance in at least one use case.  This isn't a very
good test, since a thread created by thread.start_new_thread() isn't
particularly "foreign".
2005-01-08 07:30:42 +00:00
Tim Peters 84d548994e Converted to a unittest. Added checks that the bounded semaphore actually
does what it's supposed to do.
2005-01-08 06:03:17 +00:00
Raymond Hettinger 922b3e2098 Remove test for BINARY_DIVIDE. 2005-01-07 18:34:56 +00:00
Tim Peters 5a9fb3c415 Whitespace normalization. 2005-01-07 16:01:32 +00:00
Andrew McNamara 1196cf185c Improved the implementation of the internal "dialect" type. The new
implementation features better error reporting, and better compliance
with the PEP.
2005-01-07 04:42:45 +00:00
Raymond Hettinger c34f8673a1 Teach the peephole optimizer to fold simple constant expressions. 2005-01-02 06:17:33 +00:00
Peter Astrand 454f76711c New subprocess utility function: check_call. Closes #1071764. 2005-01-01 09:36:35 +00:00
Walter Dörwald ee1d24703f Add a test that checks the basic functionality of every encoding. 2004-12-29 16:04:38 +00:00
Andrew M. Kuchling 3b585b30c0 [Bug #1083110] calling .flush() on decompress objects causes a segfault due to an uninitialized pointer: fixes the problem and adds a test case 2004-12-28 20:10:48 +00:00
Armin Rigo a174813113 Dima Dorfman's patch for coercion/comparison of C types (patch #995939), with
a minor change after the coercion, to accept two objects not necessarily of
the same type but with the same tp_compare.
2004-12-23 22:13:13 +00:00
Fred Drake 7c404a4bf7 add __file__ to the globals available for tests loaded via DocFileSuite;
this is useful for locating supporting data files, just as it is in Python
modules
2004-12-21 23:46:34 +00:00
Walter Dörwald e57d7b179a The changes to the stateful codecs in 2.4 resulted in StreamReader.readline()
trying to return a complete line even if a size parameter was given (see
http://www.python.org/sf/1076985). This leads to buffer overflows with long
source lines under Windows if e.g. cp1252 is used as the source encoding.
This patch reverts the behaviour of readline() to something that behaves more
like Python 2.3: If a size parameter is given, read() is called only once.

As a side effect of this, readline() now supports all types of linebreaks
supported by unicode.splitlines().

Note that the tokenizer is still broken and it's possible to provoke segfaults
(see http://www.python.org/sf/1089395).
2004-12-21 22:24:00 +00:00
Armin Rigo 2ccea17856 Any call to marshal.dumps() with the new optional argument 'version' just
immediately segfaults, due to a typo!  This was obviously never tested...
Added a test for it, and also fixed the documentation.
2004-12-20 12:25:57 +00:00
Brett Cannon 94eaee6d49 Skip test_imp if threading is not available.
Closes bug #1083645.  Thanks Detlef Vollmann.
2004-12-18 21:06:55 +00:00
Raymond Hettinger 7e71fa5cfa Bug #1083645
* The decimal module wouldn't load on builds without threads.
2004-12-18 19:07:19 +00:00
Raymond Hettinger b0900e6a21 SF #1085304: Make array.array pickle-able 2004-12-16 16:23:40 +00:00
Walter Dörwald 29ddfba3d8 Fix copy & paste error in comments. 2004-12-14 21:28:07 +00:00
Johannes Gijsbers 1542f34c42 Patch #1011890: fix inspect.getsource breaking with line-continuation &
more. Thanks to Simon Percivall!

The patch makes changes to inspect.py in two places:

* the pattern to match against functions at line 436 is
modified: lambdas should be matched even if not
preceded by whitespace, as long as "lambda" isn't part
of another word.

* the BlockFinder class is heavily modified. Changes are:
- checking for "def", "class" or "lambda" names
before setting self.started to True. Then checking the
same line for word characters after the colon (if the
colon is on that line). If so, and the line does not
end with a line continuation marker, raise EndOfBlock
immediately.
- adding self.passline to show that the line is to be
included and no more checking is necessary on that
line. Since a NEWLINE token is not generated when a
line continuation marker exists, this allows getsource
to continue with these functions even if the following
line would not be indented.

Also add a bunch of
'quite-unlikely-to-occur-in-real-life-but-working-anyway' tests.
2004-12-12 16:46:28 +00:00
Johannes Gijsbers cb9015dc08 Patch #736962: port test_inspect to unittest. As part of this, move out
the fodder modules to separate files to get rid of the imp.load_source()
trickery.
2004-12-12 16:20:22 +00:00
Johannes Gijsbers 6b220b0355 Use os.geteuid() for checking whether we are root, as suggested by
Michael Hudson.
2004-12-12 15:52:57 +00:00
Tim Peters 7f06187d31 Whitespace normalization. 2004-12-07 21:17:46 +00:00
Johannes Gijsbers b8b09d0513 SF bug #1076467: don't run test_on_error as root, as the permission
errors don't get provoked that way. Also add a bunch of cross-references
to bugs.
2004-12-06 20:50:15 +00:00
Brett Cannon c8aa848ece Have test_mkalias_relative check that sys.prefix already exists; otherwise test
is pointless.

Also add a note to the docs for the 'test' package that test cases should check
first that any conditions needed in the operating system are met before having
a test run.

Closes bug #1077302.  THanks, Ian Holsman.
2004-12-06 06:08:59 +00:00
Raymond Hettinger c7979f16ec Removed deprecated tzparse module. 2004-12-05 11:38:18 +00:00
Raymond Hettinger b2594050ea Added optional None arguments to itertools.islice(). 2004-12-05 09:25:51 +00:00
Raymond Hettinger 4ebe364277 Remove the deprecated statcache module. 2004-12-05 04:55:14 +00:00
Raymond Hettinger 1bc82f891c Removed deprecated method arguments from the shelve module. 2004-12-05 03:58:17 +00:00
Raymond Hettinger 3b0c7c20a1 SF patch #1077353: add key= argument to min and max
(First draft of patch contributed by Steven Bethard.)
2004-12-03 08:30:39 +00:00
Raymond Hettinger 4901a1f267 Add key= argument to heapq.nsmallest() and heapq.nlargest(). 2004-12-02 08:59:14 +00:00
Peter Astrand 738131d391 Raise TypeError if bufsize argument is not an integer. Patch 1071755, slightly modified. 2004-11-30 21:04:45 +00:00
Raymond Hettinger e1defa4175 Fix argument order in pure python version of nsmallest() and nlargest(). 2004-11-29 05:54:48 +00:00
Raymond Hettinger 605ed02483 SF bug #1071588 coercing decimal to int doesn't work between -1 and 1 2004-11-24 07:28:48 +00:00
Brett Cannon 3684c8771e Have testLoadTkFailure() skip on cygwin since Tcl/Tk on cygwin renders to the
Windows GDI directly and thus does not need a DISPLAY environment variable.

Thanks Jason Tishler.
2004-11-24 03:01:36 +00:00
Johannes Gijsbers 8e6f2ded30 Bug #1071513: don't test on Cygwin, as chmod doesn't work reliably there
(http://www.cygwin.com/faq/faq_3.html#SEC41).

Also check whether onerror has actually been called so this test will
fail on assertion instead of on trying to chmod a non-existent file.
2004-11-23 09:27:27 +00:00
Brett Cannon 08febebf96 Add 'linux2' as one of the platforms that does not use the echo service as one
of the test possiblities for testGetServBy().
2004-11-20 21:10:07 +00:00
Peter Astrand 2224be64dc Remove tempfile after use in test_call_string.
In test_args_string, remove the tempfile before assertEqual.
2004-11-17 20:06:35 +00:00
Tim Peters bbc0d4409c SF bug 1065388: calendar day/month name lookup too slow
__getitem__() methods:  compute only the new spellings needed to satisfy
the given indexing object.  This is purely an optimization (it should
have no effect on visible semantics).
2004-11-13 16:18:32 +00:00
Martin v. Löwis fba7369824 Patch #1050475: Fix various x86_64 build issues
regrtest.py: skip rgbimg and imageop as they are not built on 64-bit systems.
_tkinter.c: replace %.8x with %p for printing pointers.
setup.py: add lib64 into the library directories.
2004-11-13 11:13:35 +00:00
Walter Dörwald aee4da6b83 Add options to regrtest.py to make it possible to specify where to put
the coverage files when -T is used.
2004-11-12 18:51:27 +00:00
Peter Astrand 195404ff90 Use os.chdir/os.getcwd instead of os.path.realpath, to support Tru64
TEMP dirs with {memb} strings. Fixes #1063571.
2004-11-12 15:51:48 +00:00
Just van Rossum 2dae7646c3 On second thought: "Errors should never pass silently", so barf when a
string contains control chars that are illegal for XML
2004-11-12 09:36:12 +00:00
Just van Rossum 48ecaccf9e testing control chars and non-dict root objects 2004-11-12 08:34:32 +00:00
Raymond Hettinger 952f8808b2 SF patch #1062279: deque pickling problems
(Contributed by Dima Dorfman.)

* Support pickling of dictionaries in instances of deque subclasses.
* Support pickling of recursive deques.
2004-11-09 07:27:35 +00:00
Raymond Hettinger 15056a5202 SF 1062353: set pickling problems
Support automatic pickling of dictionaries in instance of set subclasses.
2004-11-09 07:25:31 +00:00
Tim Peters 50c6bdb1d6 test_doctest.py test_pdb_set_trace_nested(): A new test from Jim Fulton
showing that doctest's pdb.set_trace() support was dramatically broken.

doctest.py _OutputRedirectingPdb.trace_dispatch():  Return a local trace
function instead of (implicitly) None.  Else interaction with pdb was
bizarre, noticing only 'call' events.  Amazingly, the existing set_trace()
tests didn't care.
2004-11-08 22:07:37 +00:00
Michael W. Hudson e0b855fac9 test for fixedness of bug #1057835.
(thanks to Raymond for the prod).
2004-11-08 16:46:02 +00:00
Martin v. Löwis d6eb3523f6 Stop printing listdir bytestring output, as the precise list of strings
returned depends on the filesystem encoding.
2004-11-07 20:01:56 +00:00
Martin v. Löwis cd24699256 Try a different filename if the Latin-1 file name cannot
be represented in the file system. Fixes #989338.
2004-11-07 19:57:35 +00:00
Tim Peters 00afb07490 Whitespace normalization. 2004-11-07 04:52:29 +00:00
Tim Peters 90cf212cef Essentially SF patch 1061679: add missing __all__ to pickletools.py.
Harmless.
2004-11-06 23:45:48 +00:00
Skip Montanaro 599bd5e1e1 Fix bug 1052242. Also includes rewrite of test case using unittest and
avoiding use of popen.
2004-11-04 04:31:30 +00:00
Raymond Hettinger 5dec096e6a Maintain peepholer's cumlc invariant by updating the running total
everytime a LOAD_CONSTANT is encountered, created, or overwritten.

Added two tests to cover cases affected by the patch.
2004-11-02 04:20:10 +00:00
Raymond Hettinger f7010bed89 * Bumped up the sleep() delay to four seconds so this test will run
reliably on WinME with FAT32.
* Native speaker rewrite of the comment block.
* Removed unnecessary backslashes from the multi-line function defintions.
2004-11-01 22:27:14 +00:00
Walter Dörwald bb9c739806 Add error checks for the bz2, cStringIO and operator modules.
Add function names to various PyArg_ParseTuple calls in bz2module.c.
2004-11-01 17:10:19 +00:00
Hye-Shik Chang 4a8d851910 Bug #1057993: Use sleep() always instead of os.utime() possibly broken
in some platforms.
2004-11-01 08:26:09 +00:00
Barry Warsaw 8c72eae237 SF patch #1056967, changes the semantics of Template.safe_substitute() to not
raise a ValueError for dangling delimiters (the delimiter itself is returned).
2004-11-01 03:52:43 +00:00
Tim Peters 4590c00e89 test_on_error(): Rewrite so it works on WinXP too. Unsure about 95/98/ME. 2004-11-01 02:40:52 +00:00
Johannes Gijsbers ef5ffc4765 Bug #1048941: shutil.rmtree error handling was always broken
Rewrite rmtree again, this time without os.walk(). Error handling had been
broken since Python 2.3, and the os.walk() version inherited this.
2004-10-31 12:05:31 +00:00
Tim Peters ead8b7ab30 SF 1055820: weakref callback vs gc vs threads
In cyclic gc, clear weakrefs to unreachable objects before allowing any
Python code (weakref callbacks or __del__ methods) to run.

This is a critical bugfix, affecting all versions of Python since weakrefs
were introduced.  I'll backport to 2.3.
2004-10-30 23:09:22 +00:00
Armin Rigo 89a39461bf Wrote down the invariants of some common objects whose structure is
exposed in header files.  Fixed a few comments in these headers.

As we might have expected, writing down invariants systematically exposed a
(minor) bug.  In this case, function objects have a writeable func_code
attribute, which could be set to code objects with the wrong number of
free variables.  Calling the resulting function segfaulted the interpreter.
Added a corresponding test.
2004-10-28 16:32:00 +00:00
Walter Dörwald 063e1e846d Trigger a few error cases in Modules/_codecsmodule.c. 2004-10-28 13:04:26 +00:00
Brett Cannon 14adbe77b5 Fix bug of implementation of algorithm for calculating the date from year, week
of the year, and day of the week.  Was not taking into consideration properly
the issue of when %U is used for the week of the year but the year starts on
Monday.

Closes bug #1045381 again.
2004-10-28 04:49:21 +00:00
Hye-Shik Chang 7afa64e260 Add a comment explains why we should modify mtime here. 2004-10-27 03:12:05 +00:00
Tim Peters 1816d79bac Removed newly redundant embedded import. 2004-10-27 02:44:10 +00:00
Tim Peters 10d59f3fa1 Whitespace normalization. 2004-10-27 02:43:25 +00:00
Tim Peters f1af9c0896 Paper over bug 1054615 by passing sane values to os.utime().
The underlying bug still exists, but also existed in 2.3.4:
import.c's load_source_module() returns NULL if
PyOS_GetLastModificationTime() returns -1, but
PyOS_GetLastModificationTime() doesn't set any exception when it returns
-1, and neither does load_source_module() when it gets back -1.  This
leads to "SystemError: NULL result without error in PyObject_Call"
on an import that fails in this way.
2004-10-27 02:33:15 +00:00
Greg Ward 48aa84b24d Update optparse module and test suite to Optik 1.5a2. 2004-10-27 02:20:04 +00:00
Just van Rossum fc93e17598 - Added tests for the string load/dump function.
- Added a chunk of plist data as generated by Cocoa's NSDictionary and
  verify we output the same (including formatting)
- Changed the "literal" plist code to match the raw test data
2004-10-26 11:02:08 +00:00
Hye-Shik Chang 182ac85147 SF #737473: Show up-to-date source code in tracebacks always.
And add an optional argument 'filename' to linecache.checkcache()
to enable checking caches per-file.
2004-10-26 09:16:42 +00:00
Raymond Hettinger 23109ef11e SF bug #1053819: Segfault in tuple_of_constants
Peepholer could be fooled into misidentifying a tuple_of_constants.
Added code to count consecutive occurrences of LOAD_CONST.
Use the count to weed out the misidentified cases.
Added a unittest.
2004-10-26 08:59:14 +00:00
Raymond Hettinger 561fbf138d SF bug #1054139: serious string hashing error in 2.4b1
_PyString_Resize() readied strings for mutation but did not invalidate
the cached hash value.
2004-10-26 01:52:37 +00:00
Tim Peters 8ceefc5a56 Whitespace normalization. 2004-10-25 03:19:41 +00:00
Raymond Hettinger 9047c8f73d SF bug #1048870: call arg of lambda not updating 2004-10-24 00:10:06 +00:00
Peter Astrand c19ccc9f11 Removed test_close_fds, because it's too unreliable. We simply cannot
know that the newly-started Python process only has 3 filedescriptors
open. Fixes bug 1048808.
2004-10-21 19:28:34 +00:00
Andrew M. Kuchling d4f2552ef8 Add test case for bug #1017553 2004-10-20 11:47:01 +00:00
Brett Cannon 8abcc5d533 Add support for %U and %W to contribute to calculating the date when the year
and day of the week are specified.

Closes bug #1045381.
2004-10-18 01:37:57 +00:00
Hye-Shik Chang af5c7cff56 SF #1048865: Fix a trivial typo that breaks StreamReader.readlines() 2004-10-17 23:51:21 +00:00
Raymond Hettinger a9f6092904 Fix and test weak referencing of itertools.tee objects. 2004-10-17 16:40:14 +00:00
Neal Norwitz 6627a96705 Invalid patterns to substitute and safe_substitute would crash since pattern
is not a local variable.  Add a test case.
2004-10-17 16:27:18 +00:00
Tim Peters 1dbf2434d5 remove_stderr_debug_decorations(): Always try the substitution. Else
this test failed under the combination of passing -O to a debug-build
Python.  Now all 4 of those pass ({debug, release} x {-O, no -O}).
2004-10-14 04:16:54 +00:00
Neal Norwitz 64fa74df21 Get test to pass on amd64 (opteron). This is pretty hacky, but
rangeobject.c has an #ifdef that is reached only when LONG_MAX != INT_MAX
2004-10-14 03:46:18 +00:00
Jim Fulton 7d428788e1 Fixed a small bug. doctest didn't handle unicode docstrings containing
non-ascii characters.
2004-10-13 14:15:32 +00:00
Fredrik Lundh 9e29fc584c Don't spend quite as much time looking for leaks on Windows, where
it's rather expensive to create new processes.
2004-10-13 07:54:54 +00:00
Fredrik Lundh 59c0559554 normalize case when comparing directory names (problem reported by
"Khalid A. B." on python-dev)
2004-10-13 06:55:40 +00:00
Martin v. Löwis f7e74b789d Add a comment explaining -kb. 2004-10-13 05:29:39 +00:00
Tim Peters 3761e8dd66 New helper remove_stderr_debug_decorations(). This test passes in a
debug build on Windows now.  More applications of the helper may be needed
on non-Windows platforms.
2004-10-13 04:07:12 +00:00
Tim Peters 29b6b4f7c7 Kill several problems at once: test_poll() failed sometimes for me.
Turns out the mysterious "expected output" file contained exactly N dots,
because test_poll() has a loop that *usually* went around N times,
printing one dot on each loop trip.  But there's no guarantee of that,
because the exact value of N depended on the vagaries of scheduling
time.sleep()s across two different processes.  So stopped printing dots,
and got rid of the expected output file.  Add a loop counter instead,
and verify that the loop goes around at least a couple of times.  Also
cut the minimum time needed for this test from 4 seconds to 1.
2004-10-13 03:43:40 +00:00
Tim Peters 4052fe5a9b test_stdout_none(): Don't print "banana" to the screen in the middle
of the test.  It's testing stdout in a different process, so it has to
print something, but I didn't find "banana" to be self-explanatory.
2004-10-13 03:29:54 +00:00
Tim Peters 876c43245e Windows test_creationflags() test: print msg to stderr informing the
tester that a DOS box is expected to flash.  Slash the sleep from 2
seconds to a quarter second (why would we want to wait 2 seconds just
to stare at a DOS box?).
2004-10-13 03:21:35 +00:00
Tim Peters f73cc9714f XXX about extreme expense of test_no_leaking() on Windows. I'm not sure
what this is trying to do.  If it's necessary for it to create > 1000
processes, it should be controlled by a new resource and not run by
default on Windows.
2004-10-13 03:14:40 +00:00
Tim Peters 7b759da1b8 Experience with Zope2's tests showed it's a Bad Idea to make unittest
display a test's docstring as "the name" of the test.  So changed most
test docstrings to comments, and removed the clearly useless ones.  Now
unittest reports the actual names of the test methods.
2004-10-12 22:29:54 +00:00
Tim Peters 3b01a70f76 Wrap long lines. 2004-10-12 22:19:32 +00:00
Tim Peters e718f615b8 Whitespace normalization. 2004-10-12 21:51:32 +00:00
Fredrik Lundh 5b3687df2e Added Peter Astrand's subprocess module. 2004-10-12 15:26:28 +00:00
Michael W. Hudson 29589a06f6 Open source files in universal newlines mode. 2004-10-11 15:34:31 +00:00
Brett Cannon 4f35c71543 Locale data that contains regex metacharacters are now properly escaped.
Closes bug #1039270.
2004-10-06 02:11:37 +00:00
Tim Peters ab9b32c077 Whitespace normalization. 2004-10-03 18:35:19 +00:00
David Goodger 1cbf206d32 SF bug #997050: Document, test, & check for non-string values in ConfigParser. Moved the new string-only restriction added in rev. 1.65 to the SafeConfigParser class, leaving existing ConfigParser & RawConfigParser behavior alone, and documented the conditions under which non-string values work. 2004-10-03 15:55:09 +00:00
David Goodger 68a1abdade SF bug #1017864: ConfigParser now correctly handles default keys, processing them with ``ConfigParser.optionxform`` when supplied, consistent with the handling of config file entries and runtime-set options. 2004-10-03 15:40:25 +00:00
Just van Rossum 16c3e08931 use new readPlist() and writePlist() functions 2004-10-02 14:06:18 +00:00
Armin Rigo 974d757af1 Upon insertion, if memory runs out, the deque was left in a corrupted state.
deque_item(): a performance bug: the linked list of blocks was followed
from the left in most cases, because the test (i < (deque->len >> 1)) was
after "i %= BLOCKLEN".

deque_clear(): replaced a call to deque_len() with deque->len; not sure what
this call was here for, nor if all compilers under the sun would inline it.

deque_traverse(): I belive that it could be called by the GC when the deque
has leftblock==rightblock==NULL, because it is tracked before the first block
is allocated (though closely before).  Still, a C extension module subclassing
deque could provide its own tp_alloc that could trigger a GC collection after
the PyObject_GC_Track()...

deque_richcompare(): rewrote to cleanly check for end-of-iterations instead of
relying on deque.__iter__().next() to succeed exactly len(deque) times -- an
assumption which can break if deques are subclassed.  Added a test.

I wonder if the length should be explicitely bounded to INT_MAX, with
OverflowErrors, as in listobject.c.  On 64-bit machines, adding more than
INT_MAX in the deque will result in trouble.  (Note to anyone/me fixing
this: carefully check for overflows if len is close to INT_MAX in the
following functions: deque_rotate(), deque_item(), deque_ass_item())
2004-10-02 13:59:34 +00:00
Tim Peters 10c7e86454 deque_traverse(): If the deque had one block, and its rightindex was
BLOCKLEN-1, this assert-failed in a debug build, or went wild with a
NULL pointer in a release build.  Reported on c.l.py by Stefan Behnel.
2004-10-01 02:01:04 +00:00
Raymond Hettinger 7b46f6b2a5 Add tests for syntax errors. 2004-09-30 22:29:03 +00:00
Raymond Hettinger 49c522be80 Expand scope to include general mapping protocol tests.
Many of these tests are redundant, but this will ensure
that the mapping protocols all stay in sync.
Also, added a test for dictionary subclasses.
2004-09-30 15:07:29 +00:00
Walter Dörwald 59b23e8b80 Add missing test_dict.py from patch #736962. 2004-09-30 13:46:00 +00:00
Raymond Hettinger 5ea7e31076 Improve test coverage. 2004-09-30 07:47:20 +00:00
Raymond Hettinger ff5dc0ee77 Improve test coverage. 2004-09-29 11:40:50 +00:00
Raymond Hettinger bcab2b25f9 Improve test coverage. 2004-09-29 08:03:17 +00:00
Edward Loper 7d88a58e85 Reverted the addition of a NORMALIZE_NUMBERS option, per Tim Peter's
request.  Tim says that "correct 'fuzzy' comparison of floats cannot
be automated."  (The motivation behind adding the new option
was verifying interactive examples in Python's latex documentation;
several such examples use numbers that don't print consistently on
different platforms.)
2004-09-28 05:50:57 +00:00
Raymond Hettinger 4cda01e260 * Increase test coverage.
* Have groupby() be careful about decreffing structure members.
2004-09-28 04:45:28 +00:00
Edward Loper aec3c9b54f Added a new NORMALIZE_NUMBERS option, which causes number literals in
the expected output to match corresponding number literals in the
actual output if their values are equal (to ten digits of precision).
2004-09-28 04:29:57 +00:00
Raymond Hettinger 6429a4727e Use Py_CLEAR(). Add unrelated test. 2004-09-28 01:51:35 +00:00
Raymond Hettinger 855d9a985b Plug a leak and beef-up test coverage. 2004-09-28 00:03:54 +00:00
Raymond Hettinger 630e5355b5 Rename test for comparision errors. 2004-09-27 23:11:35 +00:00
Raymond Hettinger 63251781d1 Beef-up tests for greater coverage and refcount checking. 2004-09-27 22:48:40 +00:00
Armin Rigo 9f90439817 Patch #1011240: SystemError generated by struct.pack('P', 'foo'). 2004-09-27 19:27:51 +00:00
Raymond Hettinger ffdb8bb99c Use floor division operator. 2004-09-27 15:29:05 +00:00
Raymond Hettinger aa241e0149 Checkin Tim's fix to an error discussed on python-dev.
Also, add a testcase.

Formerly, the list_extend() code used several local variables to remember
its state across iterations.  Since an iteration could call arbitrary
Python code, it was possible for the list state to be changed.  The new
code uses dynamic structure references instead of C locals.  So, they
are always up-to-date.

After list_resize() is called, its size has been updated but the new
cells are filled with NULLs.  These needed to be filled before arbitrary
iteration code was called; otherwise, that code could attempt to modify
a list that was in a semi-invalid state.  The solution was to change
the ob->size field back to a value reflecting the actual number of valid
cells.
2004-09-26 19:24:20 +00:00
Tim Peters 5a59d88e89 Whitespace normalization. 2004-09-24 23:16:41 +00:00
Johannes Gijsbers 3981511070 Port test_unpack to doctest (patch #736962). 2004-09-24 21:36:52 +00:00
Neil Schemenauer 6bc937cfd2 Add yet more tests for buffer(). 2004-09-24 19:18:42 +00:00
Neil Schemenauer 29302a7867 Add a few more tests for the buffer() object. 2004-09-24 15:35:15 +00:00
Tim Peters 1cc37380b2 Whitespace normalization. 2004-09-24 04:36:47 +00:00
Tim Peters 307fa78107 SF bug #513866: Float/long comparison anomaly.
When an integer is compared to a float now, the int isn't coerced to float.
This avoids spurious overflow exceptions and insane results.  This should
compute correct results, without raising spurious exceptions, in all cases
now -- although I expect that what happens when an int/long is compared to
a NaN is still a platform accident.

Note that we had potential problems here even with "short" ints, on boxes
where sizeof(long)==8.  There's #ifdef'ed code here to handle that, but
I can't test it as intended.  I tested it by changing the #ifdef to
trigger on my 32-bit box instead.

I suppose this is a bugfix candidate, but I won't backport it.  It's
long-winded (for speed) and messy (because the problem is messy).  Note
that this also depends on a previous 2.4 patch that introduced
_Py_SwappedOp[] as an extern.
2004-09-23 08:06:40 +00:00
Raymond Hettinger 4533f1fb7f Improve three recipes in the itertools docs. 2004-09-23 07:27:39 +00:00
Phillip J. Eby 7ec642a4d2 Fix for SF bug #1029475 : reload() doesn't work with PEP 302 loaders. 2004-09-23 04:37:36 +00:00
Raymond Hettinger 2c31a058eb SF patch #1031667: Fold tuples of constants into a single constant
Example:
>>> import dis
>>> dis.dis(compile('1,2,3', '', 'eval'))
  0           0 LOAD_CONST               3 ((1, 2, 3))
              3 RETURN_VALUE
2004-09-22 18:44:21 +00:00
Raymond Hettinger ce96d8b684 Bug #1030125: rfc822 __iter__ problem
Add iteration support to the Message class.
2004-09-22 17:17:32 +00:00
Edward Loper 4ae900f43b - Changed SampleClass docstrings to test docstring parsing a little
more thouroughly.
2004-09-21 03:20:34 +00:00
Edward Loper 052d0cd291 - Added "testfile" function, a simple function for running & verifying
all examples in a given text file. (analagous to "testmod")
- Minor docstring fixes.
- Added module_relative parameter to DocTestFile/DocTestSuite, which
  controls whether paths are module-relative & os-independent, or
  os-specific.
2004-09-19 17:19:33 +00:00
Edward Loper 0273f5b6b2 In DocFileTest:
- Fixed bug in handling of absolute paths.
  - If run from an interactive session, make paths relative to the
    directory containing sys.argv[0] (since __main__ doesn't have
    a __file__ attribute).
2004-09-18 20:27:04 +00:00
Tim Peters 528ca53b74 SF bug #1028306: date-datetime comparison
Treat comparing a date to a datetime like a mixed-type comparison.
2004-09-16 01:30:50 +00:00
Tim Peters c74298a72b Whitespace normalization. 2004-09-16 00:09:19 +00:00
Brett Cannon 0a1af4aeb0 Remove tabs. 2004-09-15 23:26:23 +00:00
Martin v. Löwis 9996828caa Patch #1026986: Add OpenBSD 3.5 and 3.6 to list of broken systems. 2004-09-15 06:02:54 +00:00
Martin v. Löwis 74a249e1a9 Strip square brackets from IPv6 address. 2004-09-14 21:45:36 +00:00
Skip Montanaro cae14d2714 missed the obvious test case and corresponding fix 2004-09-14 17:55:21 +00:00
Skip Montanaro 10e6e0e61a Search from the end of the host/port combination to find the colon which
separates ip address from the port to accommodate ipv6 addresses.
2004-09-14 16:32:02 +00:00
Raymond Hettinger 6d191113a6 Fix small bugs in Template code.
* The parameterization of "delimiter" was incomplete.
* safe_substitute's code for braced delimiters should only be executed
  when braced is not None.
* Invalid pattern group names now raise a ValueError.  Formerly, the
  convert code would fall off the end and improperly return None.

Beefed-up tests.

* Test delimiter override for all paths in substitute and safe_substitute.
* Alter unittest invocation to match other modules (now it itemizes the
  tests as they are run).
2004-09-14 02:34:08 +00:00
Raymond Hettinger 23f1241dc6 SF #1027105: HardwareRandom should be renamed OSRandom
Renamed the new generator at Trevor's recommendation.
The name HardwareRandom suggested a bit more than it
delivered (no radioactive decay detectors or such).
2004-09-13 22:23:21 +00:00
Barry Warsaw 3e773fb622 The 4th group is now 'invalid' instead of 'bogus'. 2004-09-13 20:53:27 +00:00
Barry Warsaw c7cd20c8c6 Added a test for # positional arguments > 1. 2004-09-13 15:24:43 +00:00
Tim Peters 958cc89037 exclude_empty: make the default True for DocTestFinder, and introduce it
with default False for testmod().  The real point of introducing this was
so that output from doctest.master.summarize() would be the same as in
2.3, and doctest.master in 2.4 is a backward-compatability hack used only
by testmod().
2004-09-13 14:53:28 +00:00
Barry Warsaw 302bd589ad Add tests for keyword arguments and combining mapping and keyword arguments. 2004-09-13 14:35:59 +00:00
Edward Loper 32ddbf7fab Added new parameter exclude_empty to DocTestFinder.__init__, which
controls whether tests are included for objects with empty docstrings.
Defaults to True, to match the behavior of Python 2.3.
2004-09-13 05:47:24 +00:00
Tim Peters c56847878e DocTestFinder._find(): for tests derived from a module __test__ global,
doctest always promised to stick "__test__" in the name.  That got
broken.  Now it's fixed again.
2004-09-13 01:07:12 +00:00
Tim Peters 0e9980f75a Whitespace normalization. 2004-09-12 03:49:31 +00:00
Johannes Gijsbers d60e92a48d Document not-completely-obvious behavior in a test. 2004-09-11 21:26:21 +00:00
Tim Peters 17b56379e1 Recover from inspect.getmodule() changes. It returns a module for
functions and methods now, including functions defined inside doctests
in test_doctest.py's recursive doctest'ing.
2004-09-11 17:33:27 +00:00
Barry Warsaw 12827c1fa9 Many updates to PEP 292 templates. Summary:
- Template no longer inherits from unicode.

- SafeTemplate is removed.  Now Templates have both a substitute() and a
  safe_substitute() method, so we don't need separate classes.  No more
  __mod__() operator.

- Adopt Tim Peter's idea for giving Template a metaclass, which makes the
  delimiter, the identifier pattern, or the entire pattern easy to override
  and document, while retaining efficiency of class-time compilation of the
  regexp.

- More informative ValueError messages which will help a user narrow down the
  bogus delimiter to the line and column in the original string (helpful for
  long triple quoted strings).
2004-09-10 03:08:08 +00:00
Fred Drake 75d9a62fe0 add tests that make sure buffer boundaries are handled properly for SGML comments
(see SF patch #901369)
2004-09-08 22:57:01 +00:00
Brett Cannon 85ae1a69b6 Remove usage of locale.getlocale in favor or setlocale(LC_NUMERIC, None) .
Also added a comment about why the code is bother to see what setlocale thinks
the set locale is.

Closes bug #1023798.
2004-09-08 02:02:41 +00:00
Walter Dörwald 69652035bc SF patch #998993: The UTF-8 and the UTF-16 stateful decoders now support
decoding incomplete input (when the input stream is temporarily exhausted).
codecs.StreamReader now implements buffering, which enables proper
readline support for the UTF-16 decoders. codecs.StreamReader.read()
has a new argument chars which specifies the number of characters to
return. codecs.StreamReader.readline() and codecs.StreamReader.readlines()
have a new argument keepends. Trailing "\n"s will be stripped from the lines
if keepends is false. Added C APIs PyUnicode_DecodeUTF8Stateful and
PyUnicode_DecodeUTF16Stateful.
2004-09-07 20:24:22 +00:00
Jeremy Hylton 566d934745 compiler.transformer: correct lineno attribute when possible
SF patch #1015989

The basic idea of this patch is to compute lineno attributes for all AST nodes.  The actual
implementation lead to a lot of restructing and code cleanup.

The generated AST nodes now have an optional lineno argument to constructor.  Remove the
top-level asList(), since it didn't seem to serve any purpose.  Add an __iter__ to ast nodes.
Use isinstance() instead of explicit type tests.

Change transformer to use the new lineno attribute, which replaces three lines of code with one.
Use universal newlines so that we can get rid of special-case code for line endings.  Use
lookup_node() in a few more frequently called, but simple com_xxx methods().  Change string
exception to class exception.
2004-09-07 15:28:01 +00:00
Brett Cannon 2ad68e69b9 Ported test__locale to unittest. 2004-09-06 23:30:27 +00:00
Raymond Hettinger 658717ed11 SF #1022953: binascii.a2b_hqx("") raises SystemError
Several functions adopted the strategy of altering a full lengthed
string copy and resizing afterwards.  That would fail if the initial
string was short enough (0 or 1) to be interned.  Interning precluded
the subsequent resizing operation.

The solution was to make sure the initial string was at least two
characters long.

Added tests to verify that all binascii functions do not crater when
given an empty string argument.
2004-09-06 22:58:37 +00:00
Raymond Hettinger c1c43cad63 Fulfill Martin's request to use try/except rather than a "look before
you leap" approach.  Makes the early call to os.urandom() unnecessary.
2004-09-05 00:00:42 +00:00
Raymond Hettinger c4536a1dea Teach a test about the different kinds of functions. 2004-09-04 23:53:20 +00:00
Raymond Hettinger b871763156 SF bug #1022010: Import random fails
* Complete the previous patch by making sure that the MachineRandom
  tests are only run when the underlying resource is available.
2004-09-04 20:13:29 +00:00
Raymond Hettinger ed20ad8473 Change the strategy for coping with time intensive tests from
"all or none" to "all or some".

This provides much greater test coverage without eating much time.
It also makes it more likely that routine regression testing will
unearth bugs.
2004-09-04 20:09:13 +00:00
Tim Peters 1fbf9c5ec1 Added IGNORE_EXCEPTION_DETAIL comparison option. The need is explained
in the new docs.

DocTestRunner.__run:  Separate the determination of the example outcome
from reporting that outcome, to squash brittle code duplication and
excessive nesting.
2004-09-04 17:21:02 +00:00
Gustavo Niemeyer 0506c64086 Fixing bug #817234, which made SRE get into an infinite loop on
empty final matches with finditer(). New test cases included
for this bug and for #581080.
2004-09-03 18:11:59 +00:00
Gustavo Niemeyer a01a2ee933 Applying modified version of patch #1018386, which fixes
some escaping bugs in SRE.
2004-09-03 17:06:10 +00:00
Tim Peters 3b2cdad4fd Whitespace normalization. 2004-09-01 13:10:32 +00:00
Andrew M. Kuchling 010b887cf6 Missed some occurrences of test_mpz 2004-08-31 13:45:22 +00:00
Andrew M. Kuchling a7313d0543 Remove test output for rotor, xreadline 2004-08-31 13:41:04 +00:00
Andrew M. Kuchling 7297da8a35 Remove test for mpz 2004-08-31 13:29:28 +00:00
Andrew M. Kuchling 163f800095 Remove tests for mpz, rotor, xreadlines 2004-08-31 13:29:03 +00:00
Andrew M. Kuchling 33ad28b68d Use multi-line import 2004-08-31 11:38:12 +00:00
Anthony Baxter 1a4ddaecc7 SF patch #1007189, multi-line imports, for instance:
"from blah import (foo, bar
baz, bongo)"
2004-08-31 10:07:13 +00:00
Tim Peters daec961e09 Changed Karatsuba cutoff to match current reality. 2004-08-30 23:18:23 +00:00
Johannes Gijsbers ae882f7984 Patch #941486: add os.path.lexists(). Also fix bug #940578 by using lexists in glob.glob. 2004-08-30 10:19:56 +00:00
Raymond Hettinger 356a4599ac Teach the random module about os.urandom().
* Use it for seeding when it is available.
* Provide an alternate generator based on it.
2004-08-30 06:14:31 +00:00