Commit Graph

3396 Commits

Author SHA1 Message Date
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