Commit Graph

7925 Commits

Author SHA1 Message Date
Guido van Rossum 93fe564217 _slotnames(): this is a fairly expensive calculation. Cache the
outcome as __slotnames__ on the class.  (Like __slots__, it's not safe
to ask for this as an attribute -- you must look for it in the
specific class's __dict__.  But it must be set using attribute
notation, because __dict__ is a read-only proxy.)
2003-02-03 19:46:54 +00:00
Andrew M. Kuchling 2de97d398d [Bug #676292] BaseHTTPServer incorrectly parses protocol; fix by Andrew Dalke
* Treat major, minor numbers of HTTP version as separate integers
   * Fix errors if version string is "HTTP/1.2.3" or even simply "BLAH".
   * send_error() checks if 'self.command' is a
     HEAD.  However, if there's an error parsing the first line of the
     HTTP request the self.command wasn't set yet; force
     self.command to be initialized to None.
2003-02-03 19:11:18 +00:00
Guido van Rossum 868ecc22ab _slotnames(): exclude __dict__ and __weakref__; these aren't real
slots even though they can be listed in __slots__.
2003-02-03 18:10:09 +00:00
Guido van Rossum 795ea89cb5 Support keyword argument 'bin', with a pending deprecation warning. 2003-02-03 16:59:48 +00:00
Tim Peters 31f119ebdb Proper testing of proto 2 in part requires checking that the new opcodes
are actually getting generated.  Add helpered method
ensure_opcode_in_pickle to do a correct job checking for that.  Changed
test_long1(), test_long4(), and test_short_tuples() to use it.
2003-02-03 16:20:13 +00:00
Guido van Rossum 7aa56c9a7f test_float_overflow(): make shuge (added last week) a little less
huge.  On older Linux systems, the C library's strtod() apparently
gives up before seeing the end of the string when it sees so many
digits that it thinks the result must be Infinity.  (It is wrong, BTW
-- there could be an "e-10000" hiding behind 10,000 digits.)  The
shorter shuge still tests what it's testing, without relying on
strtod() doing a super job.
2003-02-03 15:25:01 +00:00
Andrew M. Kuchling 8ca202e395 Bug #676273: Rewrite paragraph in module docstring 2003-02-03 15:21:15 +00:00
Fred Drake 9a0db07c2f test_support.requires(): Instead of raising TestSkipped, raise a new
exception, ResourceDenied.  This is used to distinguish between tests that
are skipped for other reasons (platform support, missing data, etc.) from
those that are skipped because a "resource" has not been enabled.  This
prevents those tests from being reported as unexpected skips for the
platform; those should only be considered unexpected skips if the resource
were enabled.
2003-02-03 15:19:30 +00:00
Greg Ward 4c6c9c42fb Add __all__ (suggested by Raymond Hettinger).
Rename 'whitespace' global to '_whitespace' -- it's not part of the
public interface.
2003-02-03 14:46:57 +00:00
Walter Dörwald 7a2d7a74fc Remove test_b1 and test_b2 from the list of tests
that are no real tests, because test_b1 and
test_b2 no longer exist. (Spotted by Raymond Hettinger)
2003-02-03 11:54:39 +00:00
Just van Rossum ca3fec7162 patch #664131, fix config command on OSX and Linux 2003-02-03 11:43:54 +00:00
Michael W. Hudson 35a92ce9da Fix bug
[ 676342 ] after using pdb readline does not work correctly

using Michael Stone's patch so the completer functionality of
cmd is only setup between preloop and postloop.
2003-02-03 11:04:27 +00:00
Gregory P. Smith bc2adef898 fix for use on python 2.1 2003-02-03 04:19:40 +00:00
Guido van Rossum 49992f9d25 cPickle now implements enough of protocol 2 to enable all
cross-pickling tests.
2003-02-03 01:32:33 +00:00
Walter Dörwald 7f3ed74643 Fix typos. 2003-02-02 23:08:27 +00:00
Jack Jansen cc94764c67 Getting rid of macfs usage and almost all FSSpecs. Untested on MacOS9. 2003-02-02 23:03:50 +00:00
Tim Peters 1d63c9f151 cPickle support for TUPLE[123]. Incidentally plugged several undetected
overflow holes in Pdata_grow().
2003-02-02 20:29:39 +00:00
Just van Rossum 9af6968b90 jeez, now I know why I shouldn't even _want_ to learn sh. 2003-02-02 18:56:37 +00:00
Tim Peters 3c67d795ef Implemented proto 2 NEWTRUE and NEWFALSE in cPickle. 2003-02-02 17:59:11 +00:00
Tim Peters 70b02d79f9 Beefed up the tests by putting in more "for proto in protocols:" outer
loops.  Renamed DATA and BINDATA to DATA0 and DATA1.  Included
disassemblies, but noted why we can't test them.  Added XXX comment to
cPickle about a mysterious comment, where pickle and cPickle diverge
in how they number PUT indices.
2003-02-02 17:26:40 +00:00
Tim Peters 4190fb8429 Add cPickle support for PROTO. Duplicated PROTO/LONG1/LONG4 code in
the hitherto unknown (to me) noload() cPickle function, which is (a)
something we don't test at all, and (b) pickle.py doesn't have.
2003-02-02 16:09:05 +00:00
Raymond Hettinger 1ecfb73c26 One more use of ifilter() 2003-02-02 16:07:53 +00:00
Raymond Hettinger a3a53180c0 SF patch #678899: Save time and memory by using itertools in sets module. 2003-02-02 14:27:19 +00:00
Tim Peters bf2674be0e long(string, base) now takes time linear in len(string) when base is a
power of 2.  Enabled the tail end of test_long() in pickletester.py
because it no longer takes forever when run from test_pickle.py.
2003-02-02 07:51:32 +00:00
Tim Peters ee1a53cbb1 cPickle.c: Full support for the new LONG1 and LONG4. Added comments.
Assorted code cleanups; e.g., sizeof(char) is 1 by definition, so there's
no need to do things like multiply by sizeof(char) in hairy malloc
arguments.  Fixed an undetected-overflow bug in readline_file().

longobject.c:  Fixed a really stupid bug in the new _PyLong_NumBits.

pickle.py:  Fixed stupid bug in save_long():  When proto is 2, it
wrote LONG1 or LONG4, but forgot to return then -- it went on to
append the proto 1 LONG opcode too.
Fixed equally stupid cancelling bugs in load_long1() and
load_long4():  they *returned* the unpickled long instead of pushing
it on the stack.  The return values were ignored.  Tests passed
before only because save_long() pickled the long twice.

Fixed bugs in encode_long().

Noted that decode_long() is quadratic-time despite our hopes,
because long(string, 16) is still quadratic-time in len(string).
It's hex() that's linear-time.  I don't know a way to make decode_long()
linear-time in Python, short of maybe transforming the 256's-complement
bytes into marshal's funky internal format, and letting marshal decode
that.  It would be more valuable to make long(string, 16) linear time.

pickletester.py:  Added a global "protocols" vector so tests can try
all the protocols in a sane way.  Changed test_ints() and test_unicode()
to do so.  Added a new test_long(), but the tail end of it is disabled
because it "takes forever" under pickle.py (but runs very quickly under
cPickle:  cPickle proto 2 for longs is linear-time).
2003-02-02 02:57:53 +00:00
Tim Peters 5bd2a79b22 The C pickle now knows how to deal with a proto= argument. Assorted
code cleanups, and purged more references to text-vs-binary modes.
2003-02-01 16:45:06 +00:00
Just van Rossum a212c5c37f removed bizarre construct, no idea why it was there... 2003-02-01 10:29:45 +00:00
Just van Rossum 2aa09566c5 icon support by Robin Dunn, closes patch #678218 2003-02-01 08:34:46 +00:00
Tim Peters b57f8f02ba There's no good reason for datetime objects to expose __getstate__()
anymore either, so don't.  This also allows to get rid of obscure code
making __getnewargs__ identical to __getstate__ (hmm ... hope there
wasn't more to this than I realize!).
2003-02-01 02:54:15 +00:00
Raymond Hettinger 874d9bcbe5 Neaten ref count test. 2003-02-01 02:33:45 +00:00
Tim Peters 1f1b2d2e68 Removed all uses of the out-of-favor __safe_for_unpickling__ magic
attr, and copy_reg.safe_constructors.
2003-02-01 02:16:37 +00:00
Raymond Hettinger 96ef8115dd Move itertools module from the sandbox and into production. 2003-02-01 00:10:11 +00:00
Tim Peters 96940c971c Changed the tests to stop using __setstate__(). __setstate__() no
longer needs to be public, and shoudn't be public because all datetime
objects are immutable.  The Python implementation has changed
accordingly, but still need to change the C implementation.
2003-01-31 21:55:33 +00:00
Thomas Heller 9582794c17 Pass the preprocessor options also to the resource compiler
when compiling .RC files.

From Robin Dunn, fixes SF # 669198.
2003-01-31 20:40:15 +00:00
Guido van Rossum cf356fd865 Add extension management to __all__. 2003-01-31 20:34:07 +00:00
Guido van Rossum 7eff63abce Change the default protocol back to 0.
Add a feature suggested by Tim: a negative protocol value means to use
the largest protocol value supported.
2003-01-31 19:42:31 +00:00
Guido van Rossum 25cb7dfb0f Another extension to reduce(). It can return a 4- or 5-tuple now.
The 4th item can be None or an iterator yielding list items, which are
used to append() or extend() the object.  The 5th item can be None or
an iterator yielding a dict's (key, value) pairs, which are stuffed
into the object using __setitem__.

Also (as a separate, though related, feature) add "batching" for list
and dict items.  If you pickled a dict or list with a million items in
the past, it would push a million items onto the stack.  It now pushes
only 1000 items at a time on the stack, using repeated APPENDS or
SETITEMS opcodes.  (For lists, I hope that using many short extend()
calls doesn't exhibit quadratic behavior.)
2003-01-31 18:53:21 +00:00
Jeremy Hylton 4f0dcc9a9a Provide __module__ attributes for functions defined in C and Python.
__module__ is the string name of the module the function was defined
in, just like __module__ of classes.  In some cases, particularly for
C functions, the __module__ may be None.

Change PyCFunction_New() from a function to a macro, but keep an
unused copy of the function around so that we don't change the binary
API.

Change pickle's save_global() to use whichmodule() if __module__ is
None, but add the __module__ logic to whichmodule() since it might be
used outside of pickle.
2003-01-31 18:33:18 +00:00
Michael W. Hudson 01eb85cc03 I believe this fixes
[ 669692 ] pdb user_call breakage

What an odd interface!  I guess I should have read the docstring, though.
2003-01-31 17:48:29 +00:00
Walter Dörwald 2e0b18af30 Change the treatment of positions returned by PEP293
error handers in the Unicode codecs: Negative
positions are treated as being relative to the end of
the input and out of bounds positions result in an
IndexError.

Also update the PEP and include an explanation of
this in the documentation for codecs.register_error.

Fixes a small bug in iconv_codecs: if the position
from the callback is negative *add* it to the size
instead of substracting it.

From SF patch #677429.
2003-01-31 17:19:08 +00:00
Guido van Rossum f7f4517fae Pass the object to save_reduce(), so the memoize() call can go into
save_reduce(), before the state is pickled.  This makes it possible
for an object to be referenced from its own (mutable) state.
2003-01-31 17:17:49 +00:00
Guido van Rossum d053b4b416 Add a magical feature to save_reduce so that __reduce__ can cause
NEWOBJ to be generated.
2003-01-31 16:51:45 +00:00
Tim Peters 4b23f2b44b It's Official: for LONG1/LONG4, a "byte count" of 0 is taken as a
shortcut meaning 0L.  This allows LONG1 to encode 0L in two bytes
total.
2003-01-31 16:43:39 +00:00
Guido van Rossum c1265bd9a6 Make StringIO its own iterator, similar to real files.
(This should also be done to cStringIO.)
2003-01-31 16:04:15 +00:00
Kurt B. Kaiser 8cd0def10d M PyShell.py
M rpc.py

SF Bug 676398 Doesn't handle non-built-in exceptions
1. Move exception formatting to the subprocess; allows subclassing of
   exceptions, including subclasses created in the shell without
   introducing excessive complexity in the RPC mechanism.
2. Provide access to linecache from subprocess to support this.
2003-01-31 05:06:43 +00:00
Neal Norwitz d17406830c Fix typo 2003-01-31 04:04:23 +00:00
Tim Peters 91149821d3 Linear-time implementations of {encode,decode}_long. 2003-01-31 03:43:58 +00:00
Barry Warsaw 1a17704ff1 typo in comment 2003-01-31 03:30:09 +00:00
Neil Schemenauer 1e6ada0533 Give people who run "pydoc re" a clue. 2003-01-31 00:35:58 +00:00
Guido van Rossum 177e41a117 Change the approach to pickling to use __reduce__ everywhere. Most
classes have a __reduce__ that returns (self.__class__,
self.__getstate__()).  tzinfo.__reduce__() is a bit smarter, calling
__getinitargs__ and __getstate__ if they exist, and falling back to
__dict__ if it exists and isn't empty.
2003-01-30 22:06:23 +00:00
Tim Peters e14295cf5f pickle.py has a few doctest'ed internal functions, so run their tests. 2003-01-30 21:27:37 +00:00
Walter Dörwald b4ff1113ca Check whether the choosen encoding requires byte swapping
for this iconv() implementation in the init function.

For encoding: use a byteswapped version of the input if
neccessary.

For decoding: byteswap every piece returned by iconv()
if neccessary (but not those pieces returned from the
callback)

Comment out test_sane() in the test script, because
whether this works depends on whether byte swapping
is neccessary or not (an on Py_UNICODE_SIZE)
2003-01-30 19:55:28 +00:00
Tim Peters 2b93c4c708 Updated the INST/OBJ docs, to say they really are (almost) identical
in 2.3.
2003-01-30 16:35:08 +00:00
Tim Peters d01c1e91c4 load_inst(), load_obj(): Put the bulk of these into a common new
_instantiate() method.
2003-01-30 15:41:46 +00:00
Tim Peters 43277d64eb dis(): Simplified stack emulation a bit. 2003-01-30 15:02:12 +00:00
Guido van Rossum 9b40e804c7 There was a subtle big in save_newobj(): it used self.save_global(t)
on the type instead of self.save(t).  This defeated the purpose of
NEWOBJ, because it didn't generate a BINGET opcode when t was already
memoized; but moreover, it would generate multiple BINPUT opcodes for
the same type!  pickletools.dis() doesn't like this.

How I found this?  I was playing with picklesize.py in the datetime
sandbox, and noticed that protocol 2 pickles for multiple objects were
in fact larger than protocol 1 pickles!  That was suspicious, so I
decided to disassemble one of the pickles.

This really needs a unit test, but I'm exhausted.  I'll be late for
work as it is. :-(
2003-01-30 06:37:41 +00:00
Guido van Rossum 4fba220f4a Slight code rearrangement to avoid testing getstate twice. 2003-01-30 05:41:19 +00:00
Guido van Rossum 45486176ea In save_newobj(), if an object's __getnewargs__ and __getstate__ are
the same function, don't save the state or write a BUILD opcode.  This
is so that a type (e.g. datetime :-) can support protocol 2 using
__getnewargs__ while also supporting protocol 0 and 1 using
__getstate__.  (Without this, the state would be pickled twice with
protocol 2, unless __getstate__ is defined to return None, which
breaks protocol 0 and 1.)
2003-01-30 05:39:04 +00:00
Raymond Hettinger 0e449234bf SF patch 672098: Three __contains__ implementations
Contributed by Jp Calderone.
2003-01-30 00:56:33 +00:00
Guido van Rossum ba884f3d22 Use %c rather than chr() to turn some ints into chars. 2003-01-29 20:14:23 +00:00
Tim Peters c1c2b3e0e2 dis(): This had a problem with proto 0 pickles, in that POP sometimes
popped a MARK, but without stack emulation the disassembler couldn't
know that, and subsequent indentation got hosed.

Now the disassembler does do enough stack emulation to catch this.  While
I was at it, also added lots of sanity checks for other stack operations,
and correct use of the memo.  This goes (I think) a long way toward being
a "pickle verifier" now too.
2003-01-29 20:12:21 +00:00
Guido van Rossum 5d9113d8be Implement appropriate __getnewargs__ for all immutable subclassable builtin
types.  The special handling for these can now be removed from save_newobj().
Add some testing for this.

Also add support for setting the 'fast' flag on the Python Pickler class,
which suppresses use of the memo.
2003-01-29 17:58:45 +00:00
Guido van Rossum d3590f937f Only log a message and chmod() when the mode isn't already what we
want it to be.  Log both the old and new mode.
2003-01-29 16:58:31 +00:00
Jack Jansen 6afc5e02fa - The mac-specific tests should also be run on darwin.
- Added test_aepack to the mac/darwin specific tests.
2003-01-29 16:24:16 +00:00
Skip Montanaro 5445594e20 minor grammar tweaks 2003-01-29 15:41:33 +00:00
Michael W. Hudson 5e83b7a9cc Teach the parsermodule about floor division. Fixes
[ 676521 ] parser module validation failure

bugfix candidate.
2003-01-29 14:20:23 +00:00
Jack Jansen 090da4b626 Moved aepack test code to the test suite. 2003-01-29 10:41:18 +00:00
Jack Jansen 0502d89b49 Some objects could have uninitialized attributes. Fixed. 2003-01-29 10:39:19 +00:00
Jack Jansen cbdffcee62 test_macfs found an error on the first day of its existence: round trips for date values to FSSpec.{Get,Set}Dates didn't work in MacPython-OS9. Fixed. 2003-01-29 09:56:56 +00:00
Guido van Rossum ecb1104342 Document the demise of all pretenses of safety, and the difference
between cPickle and pickle.py regarding __safe_for_unpickling__ before
Python 2.3.
2003-01-29 06:24:30 +00:00
Guido van Rossum 586c9e813c Declare Protocol 2 as implemented. 2003-01-29 06:16:12 +00:00
Guido van Rossum 255f3ee0a5 Support for extension codes. (By accident I checked in the tests first.) 2003-01-29 06:14:11 +00:00
Guido van Rossum 0322d0ff13 Test all three EXT opcodes, and move these tests into
TempAbstractPickleTests, because they don't work with cPickle yet.
2003-01-29 06:12:46 +00:00
Tim Peters 2c60f7a136 Whitespace normalization. 2003-01-29 03:49:43 +00:00
Tim Peters c0c12b5707 pickle: Comment repair.
pickletools:  Import decode_long from pickle instead of duplicating it.
2003-01-29 00:56:17 +00:00
Tim Peters ecd79eb7db Expect test_macostools and test_macfs to get skipped whenever
sys.platform != mac.  Likewise expect test_win{reg,sound} to get skipped
on non-win32 platforms.
2003-01-29 00:35:32 +00:00
Jack Jansen addc5859db Test aliases too. 2003-01-28 23:54:05 +00:00
Jack Jansen 2b88dec606 Converted to not use macfs whenever possible. 2003-01-28 23:53:40 +00:00
Tim Peters 47a6b13988 Temporary hacks to arrange that the pickle tests relying on protocol 2
only get run by test_pickle.py now (& not by test_cpickle.py).  This
should be undone when protocol 2 is implemented in cPickle too.
test_cpickle should pass again.
2003-01-28 22:34:11 +00:00
Guido van Rossum 4e2491dbb1 Add a comment about how some built-in types should grow a
__getnewargs__ method.
2003-01-28 22:31:25 +00:00
Guido van Rossum b26a97aa50 Get rid of __safe_for_unpickling__ and safe_constructors.
Also tidied up a few lines, got rid of apply(), added a comment.
2003-01-28 22:29:13 +00:00
Tim Peters dcaa24e503 Renamed "bin" arguments to "proto". Note that this test currently
fails, for reasons unrelated to this patch.
2003-01-28 22:26:28 +00:00
Guido van Rossum c8d6ef5cd6 Add a test for a list subclass with a __dict__ as well as slots. 2003-01-28 22:02:31 +00:00
Guido van Rossum ac5b5d2e8b Instead of bad hacks trying to worm around the inherited
object.__reduce__, do a getattr() on the class so we can explicitly
test for it.  The reduce()-calling code becomes a bit more regular as
a result.

Also add support slots: if an object has slots, the default state is
(dict, slots) where dict is the __dict__ or None, and slots is a dict
mapping slot names to slot values.  We do a best-effort approach to
find slot names, assuming the __slots__ fields of classes aren't
modified after class definition time to misrepresent the actual list
of slots defined by a class.
2003-01-28 22:01:16 +00:00
Jack Jansen 28827e2406 Don't import Nav. It isn't needed, and importing it doesn't work in a
non-windowing Python.
2003-01-28 21:40:36 +00:00
Jack Jansen 10882f6fcb Finally created the first two tests for MacPython modules: macfs and
macostools.
2003-01-28 21:39:28 +00:00
Guido van Rossum fe8d84d5ae Comment out a test that was anticipating SF patch 661536 -- but that
isn't checked in yet. :-(
2003-01-28 20:39:49 +00:00
Guido van Rossum 3d8c01b31c The default __reduce__ on the base object type obscured any
possibility of calling save_reduce().  Add a special hack for this.
The tests for this are much simpler now (no __getstate__ or
__getnewargs__ needed).
2003-01-28 19:48:18 +00:00
Neal Norwitz abcb0c03ad Fix SF bug# 676155, RuntimeWarning with tp_compare
Check return value of PyLong_AsDouble(), it can return an error.
2003-01-28 19:21:24 +00:00
Guido van Rossum 54fb192508 Move the NEWOBJ-generating code to a separate function, and invoke it
after checking for __reduce__.
2003-01-28 18:22:35 +00:00
Guido van Rossum 533dbcf250 Some experimental support for generating NEWOBJ with proto=2, and
fixed a bug in load_newobj().
2003-01-28 17:55:05 +00:00
Guido van Rossum 53b39d2e70 Verify treatment of unary minus on negative numbers SF bug #660455. 2003-01-28 17:48:21 +00:00
Barry Warsaw f71de3e9a0 Everything worked in both the distutils distro and in Python 2.3cvs,
so merge from the bsddb-bsddb3-schizo-branch back to the trunk.
2003-01-28 17:20:44 +00:00
Tim Peters a6ae9a2128 save_empty_tuple(): Comment on why we can't get rid of this. 2003-01-28 16:58:41 +00:00
Tim Peters 82ca59e002 save_dict(): Added a comment about the control flow NealN missed. 2003-01-28 16:47:59 +00:00
Tim Peters 13a25fb8e6 _is_string_secure(): This method is no longer used; removed it. (It
was used before string-escape codecs were added to the core.)
2003-01-28 16:42:22 +00:00
Guido van Rossum bc64e22ed6 Made save() fit on a page, while adding comments. (I moved some type
checks to save_reduce(), which can also be called from a subclass.)

Also tweaked some more comments.
2003-01-28 16:34:19 +00:00
Tim Peters ad5a771fae Got rid of the _quotes global. Used only once, and is trivial. 2003-01-28 16:23:33 +00:00
Tim Peters 55762f5f80 Use raw-mode docstring whenever there's an escape code in an example --
they're easier to read this way.
2003-01-28 16:01:25 +00:00
Guido van Rossum 03e35327f2 _dis_test should be a raw string now that it contains \x escapes. 2003-01-28 15:37:13 +00:00
Tim Peters d0f7c86a20 dis(): Not all opcodes are printable anymore, so print the repr
of the opcode character instead (but stripping the quotes).

Added a proto 2 test section for the canonical recursive-tuple case.
Note that since pickle's save_tuple() takes different paths depending on
tuple length now, beefier tests are really needed (but not in pickletools);
the "short tuple" case tried here was actually broken yesterday, and it's
subtle stuff so needs to be tested.
2003-01-28 15:27:57 +00:00
Guido van Rossum 1be3175992 Add a few comments. Change the way the protocol is checked (it must
be one of 0, 1 or 2).

I should note that the previous checkin also added NEWOBJ support to
the unpickler -- but there's nothing yet that generates this.
2003-01-28 15:19:53 +00:00
Guido van Rossum 3a41c61dd4 Rename all variables 'object' to 'obj' to avoid conflicts with the
type 'object'.  Also minor docstring tweakage, and rearranged a few
lines in save().
2003-01-28 15:10:22 +00:00
Guido van Rossum 570283584a Fix one disassembly output now that empty tuples are no longer
memoized in text mode.  Fixed some variable names in the disassembler
doctest.
2003-01-28 15:09:10 +00:00
Guido van Rossum cbe2dbddda Don't memoize the empty tuple in protocol 0. 2003-01-28 14:40:16 +00:00
Tim Peters d97da80dd5 save_tuple(): So long as the charter is rewriting for clarity, the snaky
control flow had to be simplified.
2003-01-28 05:48:29 +00:00
Tim Peters ff57bff16e save_tuple(): I believe the new code for TUPLE{1,2,3} in proto 2 was
incorrect for recursive tuples.  Tried to repair; seems to work OK, but
there are no checked-in tests for this yet.
2003-01-28 05:34:53 +00:00
Tim Peters 81098ac1c8 Comments. 2003-01-28 05:12:08 +00:00
Tim Peters fdc03462b3 Now that proto2 is defined, replaced XXX blocks with text about it.
Also moved the proto2 opcode descriptors into the sections they fit (like
TUPLE{1,2,3} in the group of tuple-building opcodes; etc).
2003-01-28 04:56:33 +00:00
Guido van Rossum 7d97d31a1b OK, this is really the last one tonight!
NEWFALSE and NEWTRUE.
2003-01-28 04:25:27 +00:00
Guido van Rossum 025bc2fe6c Shouldn't test short tuples with all items equal -- one potential bug
would be that the tuple is reversed on unpickling, and we should catch
that. :-)

Goodnight -- that's it for toniht!
2003-01-28 04:20:02 +00:00
Guido van Rossum 44f0ea5f73 More protocol 2: TUPLE1, TUPLE2, TUPLE3.
Also moved the special case for empty tuples from save() to save_tuple().
2003-01-28 04:14:51 +00:00
Guido van Rossum 9d32bb1708 Rename 'bin' arg to 'proto'. Keep the default at 0 lest the tests
change in meaning.
2003-01-28 03:51:53 +00:00
Tim Peters 3b769835ca save_inst(): Rewrote to have only one branch on self.bin. Also got rid
of my recent XXX comment, taking a (what appears to be vanishingly small)
chance and calling self.memoize() instead.
2003-01-28 03:51:36 +00:00
Guido van Rossum d6c9e63af9 First baby steps towards implementing protocol 2: PROTO, LONG1 and LONG4. 2003-01-28 03:49:52 +00:00
Tim Peters d95c2df3a9 Fixed odd whitespace after "if", which I believe I introduced long ago. 2003-01-28 03:41:54 +00:00
Tim Peters 8fda7bc48d save_int(): Fixed two new off-by-1 glitches. 2003-01-28 03:40:52 +00:00
Guido van Rossum e0b904232f Add a comment explaining that struct.pack() beats marshal.dumps(), but
marshal.loads() beats struct.unpack()!  Possibly because the latter
creates a one-tuple. :-(
2003-01-28 03:17:21 +00:00
Guido van Rossum 5c938d00a1 Got rid of mdumps; I timed it, and struct.pack("<i", x) is more than
40% faster than marshal.dumps(x)[1:]!  (That's not counting the
module attribute lookups, which can be avoided in either case.)
2003-01-28 03:03:08 +00:00
Tim Peters f558da0f90 save_tuple(): Minor rewriting, and added a comment about the subtlety
created by recursive tuples.
2003-01-28 02:09:55 +00:00
Tim Peters 209ad95b00 load_appends(): replaced .append() loop with an .extend(). 2003-01-28 01:44:45 +00:00
Tim Peters c23d18a955 Comments. 2003-01-28 01:41:51 +00:00
Tim Peters 064567e41a save_dict(): Untangled most of the bin-vs-not-bin logic. Also used
iteritems() instead of materializing a (possibly giant) list of the
items.
2003-01-28 01:34:43 +00:00
Tim Peters 21c18f0bf5 save_list(): Rewrote, to untangle the proto 0 from the proto 1 cases.
The code is much easier to follow now, and I bet it's faster too.
2003-01-28 01:15:46 +00:00
Tim Peters 22dc6f4f7a save_list(): removed unused local "d". 2003-01-28 01:07:48 +00:00
Tim Peters 58d7846e68 save_list(): removed unused local "memo". 2003-01-28 01:07:10 +00:00
Tim Peters bd1cdb9227 save_pers(): Switched the order of cases, to get rid of a "not", and to
make the bin-vs-not-bin order consistent with what other routines try to
do (they almost all handle the bin case first).
2003-01-28 01:03:10 +00:00
Tim Peters 518df0dae4 Several routines appeared to inline the guts of memoize(), possibly for
some notion of low-level efficiency.  Undid that, but left one routine
alone:  save_inst() claims it has a reason for not using memoize().
I don't understand that comment, so added an XXX comment there.
2003-01-28 01:00:38 +00:00
Tim Peters b32a8317d7 save(): Fiddled the control flow to put the normal case where it
belongs.  This is a much smaller change than it may appear:  the bulk
of the function merely got unindented by one level.
2003-01-28 00:48:09 +00:00
Tim Peters c9d7c4a656 Added XXX about save()'s special-casing of tuples -- I don't get it. 2003-01-28 00:43:26 +00:00
Tim Peters 22987e3cbd save_bool(): simplified. 2003-01-28 00:26:14 +00:00
Tim Peters cbd0a32d09 Repaired grammar in new comment. 2003-01-28 00:24:43 +00:00
Tim Peters b377f8ac3e clear_memo(): Repaired grammar in docstring. 2003-01-28 00:23:36 +00:00
Tim Peters e105478a0c Added one-line comments to the proto 2 opcodes. 2003-01-28 00:22:12 +00:00
Neal Norwitz 784a3f53a8 Use proper function name in exception messages 2003-01-28 00:20:41 +00:00
Tim Peters fdb8cfab08 Removed the new LONG2 opcode: it's extravagant. If LONG1 isn't enough,
then the embedded argument consumes at least 256 bytes.  The difference
between a 3-byte prefix (LONG2 + 2 bytes) and a 5-byte prefix (LONG4 +
4 bytes) is at worst less than 1%.  Note that binary strings and binary
Unicode strings also have only "size is 1 byte, or size is 4 bytes?"
flavors, and I expect for the same reason.  The only place a 2-byte
thingie was used was in BININT2, where the 2 bytes make up the *entire*
embedded argument (and now EXT2 also does this); that's a large savings
over 4 bytes, because the total opcode+argument size is so small in
the BININT2/EXT2 case.

Removed the TAKEN_FROM_ARGUMENT "number of bytes" code, and bifurcated it
into TAKEN_FROM_ARGUMENT1 and TAKEN_FROM_ARGUMENT4.  Now there's enough
info in ArgumentDescriptor objects to deduce the # of bytes consumed by
each opcode.

Rearranged the order in which proto2 opcodes are listed in pickle.py.
2003-01-28 00:13:19 +00:00
Tim Peters bdbe74183c Documented the 2's-comp business for the new long opcodes. 2003-01-27 23:54:04 +00:00
Tim Peters 5eed340267 Whitespace normalization. 2003-01-27 23:51:36 +00:00
Tim Peters 217e571a19 decode_long(): Simplified the "is it negative?" test. 2003-01-27 23:51:11 +00:00
Guido van Rossum f29d3d6011 Begin the change from 'binary vs. text mode' to 'protocol 0, 1, 2'.
The protocol now defaults to 1.  Protocol 2 is still unimplemented.
2003-01-27 22:47:53 +00:00
Guido van Rossum 5a2d8f5e9a Begin documenting protocol 2. 2003-01-27 21:44:25 +00:00
Tim Peters bb38e306ae Added some comments. 2003-01-27 21:25:41 +00:00
Tim Peters e46b73f5b3 memoize(): Reworded the docs to try to disentangle the Pickler's memo
dict from the Unpickler's memo (which is a different beast!).
2003-01-27 21:22:10 +00:00
Tim Peters bbf63cd05c Using marshal functions to pack & unpack 1-byte ints is an obscure &
expensive way to spell chr() and ord().
2003-01-27 21:15:36 +00:00
Tim Peters 22a449aacc Added a brief comment to each pickle opcode declaration. 2003-01-27 20:16:36 +00:00
Guido van Rossum a72ded9bc8 Remove a stray quote. 2003-01-27 19:40:47 +00:00
Tim Peters 1996e23054 Repaired comment. 2003-01-27 19:38:34 +00:00
Tim Peters d916cf4ec7 stringnl_noescape_pair(): changed the reader to separate the two
component strings by a blank instead of a period.  Guido pointed
out that the component strings (at least the first one) can be
dotted already.  find_class() is overridable too, so only God knows
all the possibilities that make sense to someone.
2003-01-27 19:01:47 +00:00
Tim Peters 8ecfc8ef9d Moving pickletools.py from the sandbox into the std library. I started
this over the weekend, and it made faster & better progress than I
expected -- it's already useful <wink>.
2003-01-27 18:51:48 +00:00
Tim Peters 40e1ce4d73 Repaired spelling of "test_iconv_codecs" in various expected-skip lists. 2003-01-27 16:45:03 +00:00
Andrew M. Kuchling 6ffdaab808 Remove the recently-added get_distutil_options(), and just
have two tuples listing the legal keywords for setup() and Extension()
2003-01-27 16:30:36 +00:00
Walter Dörwald bf5170793c Fix comment typos 2003-01-27 15:57:14 +00:00
Martin v. Löwis ca87aefe83 Patch #670715: Universal Unicode Codec for POSIX iconv. 2003-01-27 11:28:52 +00:00
Kurt B. Kaiser 7e17289868 Update for release.
Modified Files:
 	INSTALL.txt NEWS.txt idlever.py
2003-01-27 02:40:20 +00:00
Kurt B. Kaiser e66675b85c Whitespace normalization.
Modified Files:
 	Bindings.py configHandler.py configHelpSourceEdit.py
2003-01-27 02:36:18 +00:00
Kurt B. Kaiser d9db3a6713 Update. 2003-01-26 20:37:01 +00:00
Jack Jansen db5ab80411 Path to default location for Python output has changed. 2003-01-26 20:33:46 +00:00
Jack Jansen 2b3ce3ba3f FSRef and EasyDialogs pathname support was pretty much broken in MacPython-OS9. Fixed. 2003-01-26 20:22:41 +00:00
Neal Norwitz f4cdb474b6 amk pointed out that syslog may use UDP or TCP sockets.
Update to try UDP, if that fails, try TCP.
2003-01-26 16:15:24 +00:00
Martin v. Löwis 692d292c63 Test that True can be copied. 2003-01-26 11:32:44 +00:00
Martin v. Löwis 9789aefa61 Patch #670715: Universal Unicode Codec for POSIX iconv. 2003-01-26 11:30:36 +00:00
Martin v. Löwis afef4eefa8 Require PyXML 0.8.2. 2003-01-26 10:36:33 +00:00
Martin v. Löwis f8de21c51b Merge with PyXML 1.3:
Add support for the DOM Level 3 (draft) DOMImplementationSource interface
to the xml.dom and xml.dom.minidom modules.  Note API issue: the draft spec
says to return null when there is no suitable implementation, while the
Python getDOMImplementation() function raises ImportError (minor).
2003-01-26 09:04:35 +00:00
Martin v. Löwis 041411a1c7 Merge with PyXML 1.34: Correct typo. Fixes #674700. 2003-01-26 09:01:30 +00:00
Martin v. Löwis 995359cbe8 Merge with PyXML 1.82:
Correct various typos. Fixes #674700.
Set newly created attribute via setNamedItem.
2003-01-26 08:59:32 +00:00
Kurt B. Kaiser eb9637ef7d M ScriptBinding.py
M config-extensions.def
M help.txt

1. Run Script  -->  Run Module
2. Update IDLE Help file and do more work on format.
2003-01-26 04:17:16 +00:00
Neal Norwitz d89c406cb4 SF #642974, logging SysLogHandler proto type wrong
Syslog uses UDP (SOCK_DGRAM)
2003-01-26 02:14:23 +00:00
Martin v. Löwis 8afd7571a1 Patch #636005: Filter unicode into unicode. 2003-01-25 22:46:11 +00:00
Martin v. Löwis fd6aaa17d1 Synchronize with PyXML's 1.33: Import missing modules. 2003-01-25 22:02:52 +00:00
Martin v. Löwis aa5af8dce2 Merge PyXML 1.11-1.26:
Re-arrange the imports into "Python normal form."
Add test of the getUserData() / setUserData() methods, including the
NODE_CLONED callback.

Added support for renameNode() and getInterface().
Changed Node.unlink() so an unlinked node is not rendered completely
unusable by setting childNodes to None.
Element.removeAttributeNode() is slightly less destructive.

Added test for the wholeText attribute.

Added a test for Text.replaceWholeText().

Fixed to properly create Element in test of user data

Rename a local variable so it makes sense when viewed as a sequence.
Unlink a few documents when we're done with them.

Added tests to define the behavior of the cloneNode() and importNode()
mehods, especially in the "difficult" cases of document and
document-type nodes.

Filled in a few more of the other cloneNode() tests.

NodeList.item() does not exist before Python 2.2, since it requires being
able to create subtypes of list.  Use the subscript syntax instead.

Added a test that minidom documents can be pickled and unpickled.
Closes SF bug #609641.

Fill in an empty test, making sure we get the whitespace right for the
data attribute of a processing instruction.

Added checks for a few more invariants for processing instructions.

testProcessingInstruction():  The length attribute of the NodeList
    interface is not implemented for Python 2.0, 2.1, so only use
    len() to test the length.

testSchemaType():  New test, testing just the minimum of schemaType
    support; this is different from the test_xmlbuilder version of the
    test since it doesn't rely on using a specific builder, and the
    builders support different levels of DTD support.

Add tests for the removeNamedItem() and removeNamedItemNS() methods of
the NamedNodeMap instances found on Element nodes.
These do not pass; the fix will be committed shortly.

Added support for the DOM Level 3 (draft) Element.setIdAttribute*() methods.

Do more to avoid creating new Attr nodes, so that attributes do not lose
their ID-ness when set using setIdAttribute*().
2003-01-25 21:39:09 +00:00
Kurt B. Kaiser bc2861313c M PyShell.py
M RemoteDebugger.py
M rpc.py

Fix the incorrect shell exception tracebacks generated when running
under debugger control:

1. Use rpc.SocketIO.asynccall() instead of remotecall() to handle the
   IdbProxy.run() command.
2. Add a 'shell' attribute to RemoteDebugger.IdbProxy to allow setting
   of ModifiedInterpreter's active_seq attribute from RemoteDebugger code.
3. Cleanup PyShell.ModifiedInterpreter.runcode() and remove ambiguity
   regarding use of begin/endexecuting().
4. In runcode() and cleanup_traceback() use 'console' instead of 'file' to
   denote the entity to which the exception traceback is printed.
5. Enhance cleanup_traceback() so if the traceback is pruned entirely away
   (the error is in IDLE internals) it will be displayed in its entirety
   instead.
6. ModifiedInterpreter.runcode() now prints ERROR RPC returns to both
   console and __stderr__.
7. Make a small tweak to the rpc.py debug messages.
2003-01-25 21:33:40 +00:00
Martin v. Löwis 7c3c4669b7 Import UserDataHandler from PyXML. 2003-01-25 17:11:07 +00:00
Martin v. Löwis b5698faa9d Import NodeFilter from DOM2 Traversal/Range. 2003-01-25 17:07:03 +00:00
Martin v. Löwis 3f1b5288e5 Merge with PyXML 1.28:
Wrap a lot of long lines.
Clean up a handler for expat.error.

If a lexical handler is set, make sure we call the startDTD() and
endDTD().  If the lexical handler is unset (by setting it to None),
remove the handlers from the underlying pyexpat parser object.
Closes SF bug #485584.

In namespaces mode, make sure we set up the qnames dictionary
correctly for the AttributesNSImpl instance passed to the
start-element-handler.
Closes SF bug #563399.

Support skippedEntity. Fixes #665486.
2003-01-25 16:51:50 +00:00
Martin v. Löwis 9ea67889dc Import from PyXML 1.10. 2003-01-25 15:29:56 +00:00
Martin v. Löwis 787354c3b9 Merge with PyXML 1.80:
Basic minidom changes to support the new higher-performance builder, as
described: http://mail.python.org/pipermail/xml-sig/2002-February/007217.html

Use True/False where appropriate.

isSupported():  Implemented from DOM Level 2.

Support a variety of things from the DOM Level 3 draft, integrate with
the xml.dom.xmlbuilder module for the new Document and
DOMImplementation methods.

Support the NODE_CLONED callback for the UserDataHandler set using
setUserData().

Add Entity and Notation nodes to minidom.
Add __getitem__() to ReadOnlySequentialNamedNodeMap to match NamedNodeMap.
TupleType was used without being defined; rename to _TupleType and define.

Add magic so that instances of the NamedNodeMap (and its read-only cousin)
take a bit less memory in the new-style world of Python 2.2/2.3.  Now, the
assignments to __slots__ actually work.  ;-)

Add support for the Text.wholeText attribute.
Document.createCDATASection():  Do not pass unsupported arg to CDATASection
constructor.

Implemented Text.replaceWholeText().

Updated minidom interfaces to work better with current 4Suite XPath and Xslt.
* Added childNodes to class Attr
* Added localName and prefix to all Nodes
* Added specified on class Attr
* Changed DOMImplementation.createDocument to all creating a document with no document element and
a
Null doctype
* Changed CharacterData__setattr__ to keep nodeValue and data in synch
* fixed typo of ownerDoc in createDocumentFragment
* Changed Comment to inherit from CharacterData
* Allowed mutation of name on PIs
* Added importNode and rewrote cloneNode so both use same code base
* Changed EmptyNodeList to be a list not a tuple

Use a table-driven DOMImplementation.hasFeature().
Shorten lines longer than 80 characters.

Rename CloneNode to _clone_node (better naming consistency within the
module).

When defining localName as a property, the defproperty() call is
needed for each class that defined _get_localName(), otherwise only
the first version is used for Python 2.2 and newer.

Node.insertBefore():  When the reference node is not found, raise the
    exception defined by the DOM specification.

Attr._set_value():  Added setter that does the right thing.

Childless.removeChild():  Raise the exception defined by the
    specification, even though it seem less than intuitive.

_clone_node():  Access nodeType constants so we actually find them.
    Add support for document fragments.

Node.removeChild(), .replaceChild():
    Fix exception raised when a reference node is not found.

CharacterData._set_data():  Update the nodeValue attribute as well as
    the data attribute.

Entity.attributes, .childNodes:  Added these attributes.

Document.removeChild():  Raise the right exception when the node being
    removed is not a child of this node.

Element.removeAttributeNode():  Raise the right exception when the
    node isn't present on this element.  Don't unlink the node unless
    it is present.

Added support for the following methods and accessors:
    Node._get_childNodes(), Attr._get_specified(), Attr._set_prefix(),
    NamedNodeMap.has_key(), .getNamedItem(), .getNamedItemNS(),
    .removeNamedItem(), .removeNamedItemNS(),
    ProcessingInstruction._get_data(), ._get_target(), ._set_data(),
    ._set_target(), CharacterData.__len__(),
    Document.getElementById().

Add many more of the _get_*() accessors.

Convert internal helpers to use a more consistent naming convention.

Remove unused definition of _nssplit(); there can be only one!

Move the Identified mixin up so it can be used by one more class.

Remove comment about NamedNodeMap.__getitem__(); the API won't be
changing now!  Way too late for that.

Preliminary support for getElementById() for DOMs built with
xml.dom.expatbuilder.
Not necessarily very efficient, but it works, and is still fast for Document
instances that do not have the ID information.

DOMImplementation.createDocument():  Don't forget to add the
    DocumentType node to the tree.  This appearantly was lost in the
    previous release.

DocumentType.writexml():  New function.

Implement the final determination on the behaviors of importNode() and
cloneNode() with regard to Document and DocumentType nodes.

When cloning and importing, call the UserDataHandler with the right
operation, not just blindly use NODE_CLONED.

parse(), parseString():  When called with parser=None, use
xml.dom.expatbuilder instead of xml.dom.pulldom, to get a performance
boost (the main point of expatbuilder).

Fix for calling parse / parseString with a given parser instance;
the else-paths were ignored when refactoring the function signatures;
pychecker found that error instantly, BTW (hint, hint)

Added pickle support for NamedNodeMap, ReadOnlySequentialNamedNodeMap,
and ElementInfo. Closes SF bug #609641.

In _clone_node for elements, fixed arguments for getAttributeNodeNS

At least make sure the DOM API won't allow you to modify the child
node list of an entity node (since entity ndoes are supposed to be
readonly).

Add support for the DOM Level 3 (draft) DOMImplementationSource interface
to the xml.dom and xml.dom.minidom modules.  Note API issue: the draft spec
says to return null when there is no suitable implementation, while the
Python getDOMImplementation() function raises ImportError (minor).

Implement the DOM Level 3 Attr.isId property.
Refactor the lookup of the ElementInfo objects.

Implement the schemaType attribute for Element and Attr nodes.
Defined by the (draft) DOM Level 3 specification.

getElementById():  Support caching of IDs found.  This implementation is
    sufficient for DOM Level 2 compliance, but additional changes will be
    needed to support the setIdAttribute() and setIdAttributeNS() methods
    in DOM Level 3.

Add support for Text.isWhitespaceInElementContent (draft Level 3).

NamedNodeMap.removeNamedItem(), .removeNamedItemNS():
    Pass the new tests:  Return the removed node, or raise NotFoundErr
    if there was no matching node.

When changing attributes via a NamedNodeMap, update the ID-cache
appropriately.

Added support for the DOM Level 3 (draft) Element.setIdAttribute*() methods.

setAttributeNode():  Be more careful about not calling
    removeAttributeNode() twice for a single node.

Do more to avoid creating new Attr nodes, so that attributes do not lose
their ID-ness when set using setIdAttribute*().

Work harder to avoid calls to Attr.__setattr__() and
CharacterData.__setattr__().

Attr.unlink():
    Implement everything directly instead of calling to the base
    class, which does several things that aren't needed for Attr
    nodes.

Change some remaining assignments that caused __setattr__() to be
called when it can be avoided.  expatbuilder can now perform DOM
construction without __setattr__() interferance in common cases.

Remove unused _make_parent_nodes logic.
2003-01-25 15:28:29 +00:00
Martin v. Löwis fc5fec7735 Import expatbuilder, minicompat from PyXML. 2003-01-25 15:11:07 +00:00
Kurt B. Kaiser 0a0e6c3b5e 1. Eliminate putrequest(): only used in asynccall(), merge it there.
2. Add additional debugging statements and enhance others.
3. Clarify comments.
4. Move SocketIO.nextseq class attribute to beginning of class.
2003-01-25 03:26:35 +00:00
Tim Peters 8d81a012ef date and datetime comparison: when we don't know how to
compare against "the other" argument, we raise TypeError,
in order to prevent comparison from falling back to the
default (and worse than useless, in this case) comparison
by object address.

That's fine so far as it goes, but leaves no way for
another date/datetime object to make itself comparable
to our objects.  For example, it leaves Marc-Andre no way
to teach mxDateTime dates how to compare against Python
dates.

Discussion on Python-Dev raised a number of impractical
ideas, and the simple one implemented here:  when we don't
know how to compare against "the other" argument, we raise
TypeError *unless* the other object has a timetuple attr.
In that case, we return NotImplemented instead, and Python
will give the other object a shot at handling the
comparison then.

Note that comparisons of time and timedelta objects still
suffer the original problem, though.
2003-01-24 22:36:34 +00:00
Jeremy Hylton 3422c99de1 Raise PicklingError when __reduce__() fails, and
add memoize() helper function to update the memo.

The first element of the tuple returned by __reduce__() must be a
callable.  If it isn't the Unpickler will raise an error.  Catch this
error in the pickler and raise the error there.

The memoize() helper also has a comment explaining how the memo
works.  So methods can't use memoize() because the write funny codes.
2003-01-24 19:29:52 +00:00
Barry Warsaw 234d9a9eb3 rmtree(): Make implementation agree with documentation (both latex and
docstring).  Even if ignore_errors was true, an exception would occur
if path didn't exist.
2003-01-24 17:36:15 +00:00
Barry Warsaw 7fc2cca7d9 A very minimal start to a test of the shutil module. 2003-01-24 17:34:13 +00:00
Guido van Rossum bcb0e20091 Change the mode of scripts in the build/scripts* directory to
executable.
2003-01-24 14:56:52 +00:00
Tim Peters 2a44a8d332 SF bug 660872: datetimetz constructors behave counterintuitively (2.3a1).
This gives much the same treatment to datetime.fromtimestamp(stamp, tz) as
the last batch of checkins gave to datetime.now(tz):  do "the obvious"
thing with the tz argument instead of a senseless thing.
2003-01-23 20:53:10 +00:00
Tim Peters 10cadce41e Reimplemented datetime.now() to be useful. 2003-01-23 19:58:02 +00:00
Jeremy Hylton 250684ddd8 Use lightweight introspection instead of the inspect module hammer.
Removing locking are findCaller() calls as the implementation using
sys._getframe() is thread-safe.

Changes reviewed by Vinay.
2003-01-23 18:29:29 +00:00
Jeremy Hylton ba60319a78 Fix for SF bug 661340: test_httplib fails on the mac.
The test no longer produces output with \r\n in it.
2003-01-23 18:02:20 +00:00
Tim Peters 52dcce24e2 Bringing the code and test suite into line with doc and NEWS changes
checked in two days agao:

Refactoring of, and new rules for, dt.astimezone(tz).

dt must be aware now, and tz.utcoffset() and tz.dst() must not return None.
The old dt.astimezone(None) no longer works to change an aware datetime
into a naive datetime; use dt.replace(tzinfo=None) instead.

The tzinfo base class now supplies a new fromutc(self, dt) method, and
datetime.astimezone(tz) invokes tz.fromutc().  The default implementation
of fromutc() reproduces the same results as the old astimezone()
implementation, but tzinfo subclasses can override fromutc() if the
default implementation isn't strong enough to get the correct results
in all cases (for example, this may be necessary if a tzinfo subclass
models a time zone whose "standard offset" (wrt UTC) changed in some
year(s), or in some variations of double-daylight time -- the creativity
of time zone politics can't be captured in a single default implementation).
2003-01-23 16:36:11 +00:00
Skip Montanaro 9a7c96a2bc add support for Python's bool type to xmlrpclib - patch # 559288 2003-01-22 18:17:25 +00:00
Jack Jansen 32417e7dc1 Tweaked time conversion to work in MacPython-OS9. 2003-01-22 14:04:18 +00:00
Martin v. Löwis 70c3dda2fb Convert booleans to integers in IntVar.set. Fixes #671741.
Return booleans from _tkinter.getboolean.
Convert booleans to Tcl booleans in AsObj.
2003-01-22 09:17:38 +00:00
Raymond Hettinger 51f3f1b7dc SF patch #667730: More DictMixin
Sebastien Keim pointed out that iterkeys and __contains__ require
their own definitions so their behavior will update when the
underlying method is subclassed.
2003-01-22 01:39:06 +00:00
Kurt B. Kaiser 981344567f Make Alt-Key-2 the Zoom Height binding for ClassBrowser and PathBrowser,
consistent with the Edit/Shell windows.
2003-01-22 00:31:09 +00:00
Kurt B. Kaiser 4cc5ef5dbe M Bindings.py
M PyShell.py
M config-keys.def
M configHandler.py

1. Clear any un-entered characters from input line before printing the
   restart boundary.
2. Restore the Debug menu: There are now both Shell and Debug menus.
3. Add Control-F6 keybinding to Restart Shell.
4. Clarify PyShell.cancel_check() comment.
5. Update doc string for Bindings.py and re-format the file slightly.
2003-01-22 00:23:23 +00:00
Jack Jansen 374c43574a Added DepracationWarnings to the old Standard File calls. 2003-01-21 22:58:39 +00:00
Jack Jansen e1c4f0b200 Tuples and lists don't have a copy() method (yet?). 2003-01-21 22:57:53 +00:00
Guido van Rossum 2a1d51602b Fix from Vinaj for the "writing to closed file" errors. SF 670390. 2003-01-21 21:05:22 +00:00
Jack Jansen 01524d0462 Implemented StandardGetFile and friends with the new EasyDialogs file
dialogs.
2003-01-21 15:31:16 +00:00
Jack Jansen cb100d16e3 Oops, this file wasn't 8-bit-clean yet. Fixed. 2003-01-21 15:30:21 +00:00
Jack Jansen 3032fe6b21 Spell out the arguments to AskFileForOpen and friends, so help() gives useful
help.
2003-01-21 14:38:32 +00:00
Andrew M. Kuchling 3875281980 Fix example in a docstring to not use 'file' as a variable name 2003-01-21 14:19:21 +00:00
Jack Jansen 08a7a0d60b Use new file dialogs in GetArgv() 2003-01-21 13:56:34 +00:00
Kurt B. Kaiser 2da75faa87 1. Restore the rest of Python IDLE setup.py Rev 1.4 (Python SF 634078)
(Loewis) which uses 'SRCDIR' (if available) in package dir path.
2. Merge Python IDLE setup.py Rev 1.5 (Loewis) to allow installation
   from the build directory. IDLEfork SF Patch 668998 (Loewis)
2003-01-21 04:42:50 +00:00
Skip Montanaro b3b22f3a29 flesh out open() docstring 2003-01-21 01:53:09 +00:00
Tim Peters 327098a613 New rule for tzinfo subclasses handling both standard and daylight time:
When daylight time ends, an hour repeats on the local clock (for example,
in US Eastern, the clock jumps from 1:59 back to 1:00 again).  Times in
the repeated hour are ambiguous.  A tzinfo subclass that wants to play
with astimezone() needs to treat times in the repeated hour as being
standard time.  astimezone() previously required that such times be
treated as daylight time.  There seems no killer argument either way,
but Guido wants the standard-time version, and it does seem easier the
new way to code both American (local-time based) and European (UTC-based)
switch rules, and the astimezone() implementation is simpler.
2003-01-20 22:54:38 +00:00
Kurt B. Kaiser 0b743441a6 ...and the old pyclbr.py faked Function instances with Class instances
which had empty method and super attributes.  ClassBrowser.IsExpandable()
could not handle the missing attributes.  SF Bug 667787.
2003-01-20 04:49:37 +00:00
Walter Dörwald ea4250df7d Add comments and remove duplicate tests. 2003-01-20 02:34:07 +00:00
Walter Dörwald e28be59686 Port test_userdict.py to PyUnit. From SF patch #662807,
with additional tests for setdefault(), pop() and popitem().
2003-01-19 23:26:59 +00:00
Walter Dörwald 28256f276e Port test_unicode.py to PyUnit and add tests for error
cases and a few methods. This increases code coverage
in Objects/unicodeobject.c from 81% to 85%.
(From SF patch #662807)
2003-01-19 16:59:20 +00:00
Walter Dörwald 919497ea74 Combine test_b1.py and test_b2.py into test_builtin.py,
port the tests to PyUnit and add many tests for error
cases. This increases code coverage in Python/bltinmodule.c
from 75% to 92%. (From SF patch #662807, with
assert_(not fcmp(x, y)) replaced with assertAlmostEqual(x, y)
where possible)
2003-01-19 16:23:59 +00:00
Raymond Hettinger 2e7b748a9e SF patch #634557: inspect.BlockFinder didn't do a good enough job finding
the end of code blocks.

Patch contributed by Patrick O'Brien.
2003-01-19 13:21:20 +00:00
Tim Peters 80cebc16aa SF patch 670194: Performance enhancement for _strptime.py.
From Brett Cannon.  Mostly speedups via caching format string ->
compiled regexp.
2003-01-19 04:40:44 +00:00
Raymond Hettinger 6550051691 SF bug #668906: class browser raises AttributeError
The Py2.3 updates to the pyclbr module return both Class and Function
objects.  The IDLE ClassBrowser module only knew about Class and could
not handle objects which did not define "super".

Fixed by adding a guard.
2003-01-19 02:37:41 +00:00
Raymond Hettinger 9543b34006 SF patch #670423: Add missing identity tests to operator.c 2003-01-18 23:22:20 +00:00
Tim Peters 08e54270f2 SF patch 670012: Compatibility changes for _strptime.py.
Patch from Brett Cannon:

    First, the 'y' directive now handles [00, 68] as a suffix for the
    21st century while [69, 99] is treated as the suffix for the 20th
    century (this is for Open Group compatibility).

    strptime now returns default values that make it a valid date ...

    the ability to pass in a regex object to use instead of a format
    string (and the inverse ability to have strptime return a regex object)
    has been removed. This is in preparation for a future patch that will
    add some caching internally to get a speed boost.
2003-01-18 03:53:49 +00:00
Jack Jansen e58962af4d Fixed the first two bugs in the new file dialogs (found by Just):
- AskFileForSave didn't work for string return values
- filterProc didn't work.
2003-01-17 23:13:03 +00:00
Just van Rossum 504377d4dd make sure src exists before creating a symlink 2003-01-17 20:02:06 +00:00
Raymond Hettinger 7b0cf76b72 * Migrate sample distribution test from random.py to test_random.py.
* Use Sets module to more clearly articulate a couple of tests.
2003-01-17 17:23:23 +00:00
Jack Jansen f0d12da482 Added methods AskFileForOpen(), AskFileForSave() and AskFolder(). These
are going to replace StandardGetFile() and friends. Main differences are
that these allow you to ask for specific datatypes to be returned (FSSpec,
FSRef, string, unicode or subtypes thereof) and that they provide access
to underlying features of Navigation Services through keyword arguments.
2003-01-17 16:04:39 +00:00
Gregory P. Smith b6c9f78074 bugfix: do not double-close DB cursor during deallocation when the
underlying DB has already been closed (and thus all of its cursors).
        This fixes a potential segfault.
        SF pybsddb bug id 667343
bugfix: close the DB object when raising an exception due to an error
        during DB.open.  This prevents an exception when closing the
        environment about not all databases being closed.
        SF pybsddb bug id 667340
2003-01-17 08:42:50 +00:00
Gregory P. Smith c25fd3fb48 bugfix: disallow use of DB_TXN after commit() or abort(), prevents a
coredump or segmentation violation.

Sourceforge patch ID 664896:
http://sourceforge.net/tracker/index.php?func=detail&aid=664896&group_id=13900&atid=313900

The bug was reported on the pybsddb-users mailing list.
2003-01-17 07:52:59 +00:00
Kurt B. Kaiser 5ec186b1cb Patch 611069 (Christos Georgiou) IDLE TODO:left/right when selected text
M EditorWindow.py
M NEWS.txt
M TODO.txt
2003-01-17 04:04:06 +00:00
Kurt B. Kaiser 9fd0799ff5 SF Bug 667812: Some Linux distros have Alt and Meta reversed. 2003-01-16 21:40:21 +00:00
Raymond Hettinger 6aa1c3f4cc Let test_random cover the endpoints.
Strengthen slicing tests.
Improved variable names.
2003-01-16 14:00:15 +00:00
Raymond Hettinger a9f18dc0f0 Test optional slice arguments.
Add backwards compatibility test.
2003-01-16 13:02:25 +00:00
Raymond Hettinger 4422375c72 Added doctest for examples in the library reference.
Added random test from bisect to augment the finite precomputed checks.
2003-01-16 12:31:36 +00:00
Raymond Hettinger d230550a6b Convert to unittest format so that more tests can be added cleanly. 2003-01-16 12:02:35 +00:00
Martin v. Löwis 6f2adc7cd0 Catch IOErrors. 2003-01-16 11:02:43 +00:00
Martin v. Löwis 71b755646a Support copying booleans. Fixes #668925. 2003-01-16 10:40:00 +00:00
Mark Hammond d800ae12f2 This test previously failed when run from the 'test' directory. In that
case, the test module created is actually a sub-package of 'test', thus
the module is named 'test.areallylongpackage...' - this caused failure.

Replace the hard-coded module names with __name__ attributes, which
correctly reflects any hierarchy.
2003-01-16 04:56:52 +00:00
Jack Jansen 8834009338 On Mac OS X calling setlocale will raise locale.Error. This isn't fatal,
so just continue testing. Fixes #668787.
2003-01-15 23:43:02 +00:00
Jack Jansen 62fe75509c Checking in Brett Cannon's patch #662053, which fixes bug #661354.
_strptime can now handle getting two empty strings as the timezone information.
2003-01-15 22:59:39 +00:00
Jack Jansen 791f7d4783 Added ismount().
Fixes #661762, bugfix candidate.
2003-01-15 22:45:48 +00:00
Jack Jansen 2d0909b9cb Implemented FSCatalogInfo structure support, and used this to implement
FSSpec.SetDates() and GetDates(). Closes #662836.
2003-01-15 22:36:16 +00:00
Raymond Hettinger 2dc505e058 * Add test for __cmp__()
* Add doctest for example in the library reference manual
2003-01-15 16:15:38 +00:00
Martin v. Löwis 0c6774d92b Patch #661719: Expose compilation errors as exceptions on request. 2003-01-15 11:51:06 +00:00
Martin v. Löwis d69663d300 Patch #473586: Implement CGIXMLRPCRequestHandler. 2003-01-15 11:37:23 +00:00
Kurt B. Kaiser 6fa0911f5a Updated IDLE Help to reflect changes in Additional Help Source
Configuration implementation.
2003-01-14 22:06:11 +00:00
Kurt B. Kaiser 8e92bf7699 M Bindings.py
M EditorWindow.py
M NEWS.txt
M config-main.def
M configDialog.py
M configHandler.py
M configHelpSourceEdit.py
M configSectionNameDialog.py

- Change default: IDLE now starts with Python Shell.

- Removed the File Path from the Additional Help Sources scrolled list.

- Add capability to access Additional Help Sources on the web if the
  Help File Path begins with //http or www.  (Otherwise local path is
  validated, as before.)

- Additional Help Sources were not being posted on the Help menu in the
  order entered.  Implement sorting the list by [HelpFiles] 'option'
  number.

- Add Browse button to New Help Source dialog.  Arrange to start in
  Python/Doc if platform is Windows, otherwise start in current directory.

- Put the Additional Help Sources directly on the Help menu instead of in
  an Extra Help cascade menu.  Rearrange the Help menu so the Additional
  Help Sources come last.  Update help.txt appropriately.

- Fix Tk root pop-ups in configSectionNameDialog.py  and configDialog.py
2003-01-14 22:03:31 +00:00
Guido van Rossum 50e92235e7 Explicitly raise an exception in __cmp__ -- this clarifies that cmp()
is not supported on sets.  (Unfortunately, sorting a list of sets may
still return random results because it uses < exclusively, but for
sets that inly implements a partial ordering.  Oh well.)
2003-01-14 16:45:04 +00:00
Raymond Hettinger 2d375f78a5 SF bug #661184: inspect.getsource bug
inspect.getsource would crash with one line definitions like:
   def f(x): return x
or
   f = lambda x: x
2003-01-14 02:19:36 +00:00
Just van Rossum 9896ea24f9 make sure Info.plist has a CFBundleIdentifier entry 2003-01-13 23:30:04 +00:00
Tim Peters ddc82ea944 A new test here was failing on Windows, because the test before it never
managed to delete the @test file it intended to delete.  Also, I don't
see a reason to create a 4MB file in the new test, so cut it back to 16K.
2003-01-13 21:38:45 +00:00
Guido van Rossum 87fec22476 Duh. cmdqueue should be an instance variable, not a class variable.
This was introduced in 1998 in rev. 1.13, where I imported extensive
patches that, I am sad to say, I didn't review as carefully as I
should have.
2003-01-13 21:18:54 +00:00
Guido van Rossum eef260757c Duh. The do_EOF() implementation was bogus. Make it more like
do_quit() -- but print a blank line first.
2003-01-13 21:13:55 +00:00
Neal Norwitz 1a9975014f Fix SF bug #667147, Segmentation fault printing str subclass
Fix infinite recursion which occurred when printing an object
whose __str__() returned self.

Will backport
2003-01-13 20:13:12 +00:00
Guido van Rossum 41b71b2f4f Fix NameError in getquotaroot(), sanctioned by Piers. 2003-01-13 15:04:26 +00:00
Tim Peters a9bc168f95 Got rid of the internal datetimetz type. 2003-01-11 03:39:11 +00:00
Neal Norwitz e931ed59d3 Fix SF bug # 602259, 3rd parameter for Tkinter.scan_dragto
Add the optional gain parameter and pass it to Tk.
2003-01-10 23:24:32 +00:00
Kurt B. Kaiser a7b804f28a Update documentation. 2003-01-10 21:27:23 +00:00
Kurt B. Kaiser 69e8afcc9f SF bug #652933 (for IdleFork): Open Module "math" Fails (Hettinger)
When a module doesn't have a __path__ attribute, trigger a dialog box
rather than dumping a traceback to the console.

Synch to Python IDLE.
2003-01-10 21:25:20 +00:00
Neal Norwitz e604c02a80 SF #665913, Fix mmap module core dump with unix
Closing an mmap'ed file (calling munmap) twice on Solaris caused a core dump.

Will backport.
2003-01-10 20:52:16 +00:00
Kurt B. Kaiser e7a161e60c M configDialog.py
M configHelpSourceEdit.py

1. Attach configHelpSourceEdit error dialogs to parent to avoid Tk root
   pop-ups.
2. Make configHelpSourceEdit OK button the default and bind <Return>.
3. Reformat configHelpSourceEdit.
4. ConfigDialog.SaveAllChangedConfig() had a bug which caused additional
   help sources to be deleted when other config items were changed.
4. Uniform capitalization in configDialog.
5. Update configDialog doc string.
2003-01-10 20:13:57 +00:00
Barry Warsaw 9149aeb842 Python 2.1's string module doesn't have ascii_letters, so let's just
hard code it.  We want this module to work with Python 2.1 for now.
2003-01-10 19:28:15 +00:00
Barry Warsaw a21bdeae51 Cleanups, and conversion of assert to assertEqual() 2003-01-10 19:03:29 +00:00
Kurt B. Kaiser 114713d194 1. Make finding Python help docs more robust, including the installed
configuation.
2. Make sure that os.startfile() is used to open both Python help docs
   and Extra Help docs on the Windows platforms.
2003-01-10 05:07:24 +00:00
Tim Peters 37f398282b Got rid of the timetz type entirely. This was a bit trickier than I
hoped it would be, but not too bad.  A test had to change:
time.__setstate__() can no longer add a non-None tzinfo member to a time
object that didn't already have one, since storage for a tzinfo member
doesn't exist in that case.
2003-01-10 03:49:02 +00:00
Kurt B. Kaiser a5e8bb94e5 Default the OK key in the Save Before Run dialog. 2003-01-10 03:06:30 +00:00
Just van Rossum f07518ac22 support unicode in menu items 2003-01-09 23:18:39 +00:00
Just van Rossum 6706c4d5fd cleaned up Jack's Mac OS9 changes 2003-01-09 22:27:10 +00:00
Walter Dörwald 0cb27dd023 Make the test scripts work again with narrow Python builds. 2003-01-09 11:38:50 +00:00
Just van Rossum 4e051d459d add newline to source before compilation 2003-01-09 10:47:20 +00:00
Walter Dörwald 30537a46ac Add a few test cases to increase code coverage:
From:
 69.73% of 294 source lines executed in file ./Modules/_codecsmodule.c
 79.47% of 487 source lines executed in file Python/codecs.c
 78.45% of 3643 source lines executed in file Objects/unicodeobject.c

To:
 70.41% of 294 source lines executed in file ./Modules/_codecsmodule.c
 82.75% of 487 source lines executed in file Python/codecs.c
 80.76% of 3638 source lines executed in file Objects/unicodeobject.c

This actually unearthed a bug in the handling of None
values in PyUnicode_EncodeCharmap.
2003-01-08 23:22:13 +00:00
Walter Dörwald 395bb49555 Add a test that exercises the error handling part of
PyUnicode_EncodeDecimal().
2003-01-08 23:02:34 +00:00
Tim Peters 6757c1e856 SF patch 661583: Remove old code from lib\os.py
A patch from Andrew Wilkinson to change some bizarre old exec statements
specific to NT and CE.
2003-01-08 21:20:57 +00:00
Tim Peters 0bf60bd67f Utterly minimal changes to collapse datetimetz into datetime, and timetz
into time.  This is little more than *exporting* the datetimetz object
under the name "datetime", and similarly for timetz.  A good implementation
of this change requires more work, but this is fully functional if you
don't stare too hard at the internals (e.g., right now a type named
"datetime" shows up as a base class of the type named "datetime").  The
docs also need extensive revision, not part of this checkin.
2003-01-08 20:40:01 +00:00
Steve Holden 8a978f7cde Fix bug 427345 [related to IE's additional input on POST request]. 2003-01-08 18:53:18 +00:00
Jack Jansen 472e7db5c0 Various tweaks to make the test work on the Mac. 2003-01-08 16:37:03 +00:00
Jack Jansen b11ce9b96c Always define getenv(), as suggested by Guido. This means that os.getenv() is also defined for MacPython-OS9 (even though it doesn't actually do anything useful), and it shouldn't hurt on other platforms. 2003-01-08 16:33:40 +00:00
Jack Jansen 52941a8348 Test that chmod() actually exists before calling it (it doesn't on MacOS9). 2003-01-08 16:33:16 +00:00
Jack Jansen 27d19c40bc Removed the SetDates warning. The warning is in the readme, and the print statement was too obtrusive (it appeared during the installation process, and the user needed to close the resulting window manually). 2003-01-08 16:32:29 +00:00
Jack Jansen 746096576b quashed another case of the 32-bit warning. 2003-01-08 16:32:09 +00:00
Jack Jansen 6797514557 Updated the list of expected skips for MacPython-OS9. 2003-01-08 16:31:11 +00:00
Jack Jansen 2918ae8fe6 n the Mac the frozen import that should fail actually succeeds, and we know it, so skip the test in stead of confusing the end user. 2003-01-08 16:30:54 +00:00
Jack Jansen ce92147cc8 Added the Mac to platforms that don't have user/group/other modes.
Set the limit for the number of open files to 32 if platform==mac.
2003-01-08 16:30:34 +00:00
Fred Drake 7511bd957d - be explicit: audio data files should be opened in binary mode
- ossaudiodev.open() raises IOError, not ossaudiodev.error, for cases
  which get mapped to TestSkipped
2003-01-08 07:09:43 +00:00
Guido van Rossum dca3f2f54a Enable building and testing of ossaudiodev for Linux. 2003-01-08 01:23:01 +00:00
Guido van Rossum 373c7412f2 Fix for SF bug #642358: only provide a new with a __dict__ or
__weaklist__ descriptor if we added __dict__ or __weaklist__,
respectively.  With unit test.
2003-01-07 13:41:37 +00:00
Raymond Hettinger 145a4a0f10 Much clearer when super() is used. 2003-01-07 10:25:55 +00:00
Raymond Hettinger ef30dc872b Revert change 1.37.
The nanoseconds saved by using dict.fromkeys aren't
worth the loss in clarity.  Linear searches live on.
2003-01-07 02:09:16 +00:00
Raymond Hettinger 625812f618 SF patch #662433: Fill arraymodule's tp_iter and sq_contains slots 2003-01-07 01:58:52 +00:00
Barry Warsaw 4e68a1ec6c CHARSETS, ALIASES, CODEC_MAP: SF feature request 633543, Korean
support and other charset defaults.  See also:

http://article.gmane.org/gmane.comp.python.mime.devel/250

(this just commits the last bit of the article that wasn't part of
email 2.4.3.)
2003-01-07 00:29:07 +00:00
Guido van Rossum 613f24fd73 Add a test for a feature added in rev. 2.82 of typeobject.c:
- SLOT1BINFULL() macro: changed this to check for __rop__ overriding
  __op__, like binary_op1() in abstract.c -- the latter only calls the
  slot function once if both types use the same slot function, so the
  slot function must make both calls -- which it already did for the
  __op__, __rop__ order, but not yet for the __rop__, __op__ order
  when B.__class__ is a subclass of A.__class__.

Also test the refinement added in rev. 2.201 that fixes the problem
reported in SF bug #623669.

Also test a similar provision in abstract.c's binary_op1().
2003-01-06 23:00:59 +00:00
Guido van Rossum 2720b0dff8 Add some print statements in verbose mode to announce that the newest
tests are run.  (All tests in this module should have one of these at
the top.)
2003-01-06 21:26:44 +00:00
Skip Montanaro f09b88ee2f * add mms (windows media) as another scheme
* reformat schemes to 80 columns
2003-01-06 20:27:03 +00:00
Guido van Rossum 4f37418d02 Disable the rexec test now that rexec is out of grace. 2003-01-06 16:03:43 +00:00
Guido van Rossum 38abbf5560 Remove bastion test output 2003-01-06 16:02:12 +00:00
Guido van Rossum 11ae4e20e0 Disable the Bastion test now that Bastion is out of grace. 2003-01-06 15:45:11 +00:00
Guido van Rossum 34a2e08586 Sabotage rexec.py. It is not safe since the new-style classes. 2003-01-06 15:43:34 +00:00
Andrew M. Kuchling b8c7b9f0cc Translate spaces in the machine name to underscores
(Power Macintosh -> Power_Macintosh)
2003-01-06 13:28:12 +00:00
Raymond Hettinger f2128b004c Used dictionaries rather than lists for membership testing. 2003-01-06 12:30:53 +00:00
Just van Rossum 077c5823d1 always also search on sys.path for res files 2003-01-06 11:15:05 +00:00
Neal Norwitz 68b539ef9c SF feature #618024, urlparse fails on imap:// 2003-01-06 06:58:31 +00:00
Neal Norwitz 4f442372cc SF feature #618024, urlparse fails on imap:// 2003-01-06 06:51:36 +00:00
Neal Norwitz b9ef4aea5e SF #651082, tarfile module implementation from Lars Gustäbel 2003-01-05 23:19:43 +00:00
Just van Rossum 66d16baf71 - squashed bare except in rmtree()
- improved readability of rmtree; removed silly apply()
2003-01-05 19:44:11 +00:00
Neal Norwitz 502b9e1fbb At least one Solaris box in the snake farm only supports "C" locale.
Adding try/except allows the test to pass
2003-01-05 18:15:23 +00:00
Raymond Hettinger 3dd990c53a Move the statistical tests for four distributions into the unittest suite. 2003-01-05 09:20:06 +00:00
Raymond Hettinger 15ec3731cf Add a test case. 2003-01-05 01:08:34 +00:00
Greg Ward 5bd844e20f Tweak __version__ -- the current code is between Optik 1.4 and 1.4.1. 2003-01-04 21:54:26 +00:00
Just van Rossum 8afa3a3092 module to run commands in a Terminal.app window 2003-01-04 21:44:21 +00:00
Guido van Rossum 5e1222be57 Add Shockwave Flash.
(backport candidate?)
2003-01-04 14:11:38 +00:00
Raymond Hettinger 73ced7ee99 Correct long standing bugs in the methods for random distributions.
The range of u=random() is [0,1), so log(u) and 1/x can fail.
Fix by setting u=1-random() or by reselecting for a usable value.

Will backport.
2003-01-04 09:26:32 +00:00
Tim Peters adf642038e A new implementation of astimezone() that does what we agreed on in all
cases, plus even tougher tests of that.  This implementation follows
the correctness proof very closely, and should also be quicker (yes,
I wrote the proof before the code, and the code proves the proof <wink>).
2003-01-04 06:03:15 +00:00
Raymond Hettinger 8ec78814c1 Test an edge case for sample(). 2003-01-04 05:55:11 +00:00
Raymond Hettinger 8b9aa8dbba Remove the random=None nonsense from sample() before it gets set in stone.
It was once available so that faster generators could be substituted.  Now,
that is less necessary and preferrably done via subclassing.

Also, clarified and shortened the comments for sample().
2003-01-04 05:20:33 +00:00
Kurt B. Kaiser 1061e7270b M AutoExpand.py
M Bindings.py
M EditorWindow.py
M PyShell.py
M config-keys.def
M configHandler.py
M help.txt

1. Annotate the shell window with last restart boundary upon restart.
2. Provide a shell menu entry and hot key (F6) to jump to the last
   restart boundary.
3. Add a new shell menu feature to restart the shell.
4. Update the help menu to add these features.
5. Update the help menu to put text in same order as the menus.
6. Correct a capitalization inconsistency on the Edit menu: Expand Word
7. Rename the "Debug" menu to be "Shell": it's doing more now.
8. Rearrange the "Shell" menu to make the StackViewer entries adjacent.
9. Add a get_geometry method to EditorWindow, which may be of use in
   making window positions persisent.
10. Make <ctrl-v> the "Classic Windows" paste key.
11. Restore decorum on the Help menu by removing "Advice".  As Guido said,
    things will never be the same.  Thanks, David!
2003-01-04 01:43:53 +00:00
Martin v. Löwis 25c7b50e8f Convert Tcl path objects to strings. Fixes #661357.
Provide .string attribute and __unicode for Tcl_Objs.
2003-01-04 00:08:09 +00:00
Walter Dörwald 8fa8972d80 Remove a list comprehension, because a loop over the list
is done afterwards anyway, so what the list comp does
can be done in the loop.
2003-01-03 21:06:46 +00:00
Walter Dörwald 51cc72c6c0 Pass the strict argument from read() on to readfp(), so the
file content ends up in the correct dict.
2003-01-03 21:02:36 +00:00
Walter Dörwald bb51ed333b Fix read_mime_types() so that it returns a dict as documented.
This fixes a bug reported as http://www.python.org/sf/661630,
which was introduced in the patch http://www.python.org/sf/554192.
2003-01-03 19:33:17 +00:00
Neal Norwitz 61cdac6d3d Fix SF #659228, 'realpath' function missing from os.path
Also added realpath = abspath for os2emx, similar to windows/mac
which also don't really implement realpath.

Backport candidate, I think?
2003-01-03 18:01:57 +00:00
Andrew M. Kuchling 51a6a4c835 [Patch #658094 ] PEP 301 implementation
Add the 'register' distutils command
2003-01-03 15:29:28 +00:00
Andrew M. Kuchling 282e2c36ba [Patch #658094] PEP 301 implementation
Add 'classifiers' keyword to DistributionMetadata
2003-01-03 15:24:36 +00:00
Just van Rossum 9a3129c148 Fix for bug #661136
Lesson learned: kids should not be allowed to use API's starting
with an underscore :-/
zipimport in 2.3a1 is even more broken than I thought: I attemped
to _PyString_Resize a string created by PyString_FromStringAndSize,
which fails for strings with length 0 or 1 since the latter returns
an interned string in those cases. This would cause a SystemError
with empty source files (and no matching pyc) in the zip archive.
I rewrote the offending code to simply allocate a new buffer and
avoid _PyString_Resize altogether.
Added a test that would've caught the problem.
2003-01-03 11:18:56 +00:00
Michael W. Hudson 8d0ffe0126 Remove debugging prints. 2003-01-03 10:25:20 +00:00
Barry Warsaw 3d597812b6 Jack complained that on test_crlf_separation() was failing on MacOS9
because the test file, msg_26.txt which has \r\n line endings, was
getting munged by cvs, which knows to do line ending conversions for
text files.  But we want \r\n to be preserved on all platforms, so we
cvs admin'd the file to be -kb (binary), which means we have to open
the file in binary mode to preserve these line ends.  Hopefully this
will be the end of the thrashing on this issue (but probably not).

Test passes on *nix now, and Tim confirms it passes on Windows.  We'll
leave it to Jack to test MacOS.
2003-01-02 22:48:36 +00:00
Tim Peters 397301eccb The tzinfo methods utcoffset() and dst() must return a timedelta object
(or None) now.  In 2.3a1 they could also return an int or long, but that
was an unhelpfully redundant leftover from an earlier version wherein
they couldn't return a timedelta.  TOOWTDI.
2003-01-02 21:28:08 +00:00
Skip Montanaro 4abd5f0fce Allow list sort's comparison function to explicitly be None. See SF patch
661092.
2003-01-02 20:51:08 +00:00
Kurt B. Kaiser fe8496ca03 1. Remove obsolete, incorrect comment on non-package installation
2. Add more .txt files to installation
3. Fix the reference to Visual Python, s/b VPython
2003-01-02 20:33:26 +00:00
Tim Peters 710fb1548a astimezone() internals: if utcoffset() returns a duration, complain if
dst() returns None (instead of treating that as 0).
2003-01-02 19:35:54 +00:00
Kurt B. Kaiser e23ca3c35a Improve exception handling. 2003-01-02 17:09:34 +00:00
Neal Norwitz b4a2df0c8d SF #660795
Add a test for logging from Vinay Sajip (module author)
2003-01-02 14:56:39 +00:00
Just van Rossum 109ecbf7a5 Replaced imp.set_frozenmodules() cruft with proper zipimport support.
This work uncovered the zipimport bug in 2.3a1 -- wish I'd had time to
do this before the release :-(.
2003-01-02 13:13:01 +00:00
Just van Rossum d35c6db526 Ugh, zipimport is virtually broken in 2.3a1 :-( It worked by accident in
the test set as it only tested with a zip archive in the current directory,
but it doesn't work at all for packages when the zip archive was specified
as an absolute path. It's a real embarrassing bug: a strchr call should
have been strrchr; fever apparently implies dyslexia.

Second stupid bug: the zipimport test failed with a name error
__importer__ (which I had renamed to __loader__ everywhere but here).
I would've sworn I ran the test after that change but that can't be true.
What I don't understand that noone reported a failing test_zipimport.py
before the release of 2.3a1.
2003-01-02 12:55:48 +00:00
Andrew MacIntyre c6fff897d7 EMX fork() emulation not good enough to cope with test_socketserver 2003-01-02 12:49:00 +00:00
Anthony Baxter 4cedc1e84e Clearing out old patch queue. Patch #558547, make SocketServer more
robust. This makes socketserver's close() method callable repeatedly
without error - similar to other file-like objects.
2003-01-02 03:07:48 +00:00
Tim Peters f36151556f A quicker astimezone() implementation, rehabilitating an earlier
suggestion from Guido, along with a formal correctness proof of the
trickiest bit.  The intricacy of the proof reveals how delicate this
is, but also how robust the conclusion:  correctness doesn't rely on
dst() returning +- one hour (not all real time zones do!), it only
relies on:

1. That dst() returns a (any) non-zero value if and only if daylight
   time is in effect.

and

2. That the tzinfo subclass implements a consistent notion of time zone.

The meaning of "consistent" was a hidden assumption, which is now an
explicit requirement in the docs.  Alas, it's an unverifiable (by the
datetime implementation) requirement, but so it goes.
2003-01-01 21:51:37 +00:00
Neal Norwitz 4e8f5492c5 Revert last change -- test works on HPUX again after Martin's checkin
to 'properly configure the slave terminal'

See SF patch # 656590 for the details.
2003-01-01 14:53:27 +00:00
Martin v. Löwis 14e73b1864 Expose I_ constants. Auto-detect stropts.h. Properly configure the slave terminal. 2003-01-01 09:51:12 +00:00
Tim Peters 36087edc05 The failure of the last-second addition to the timezone coversion test is
understood now:  it can't work.  Added comments explaining why (it's "the
usual"-- unrepresentable hours in local time --but in a slightly different
guise).
2003-01-01 04:18:51 +00:00
Kurt B. Kaiser 50e9c4ff55 More installation info. Bump alpha version. 2003-01-01 01:14:13 +00:00
Kurt B. Kaiser 38f11101d8 Debugger was tracing through rpc.py when IDLEfork was not started
from its source directory.  Generalize the "workaround" (though
the latter seems a reasonable solution?) to handle this.
2003-01-01 00:26:41 +00:00
Kurt B. Kaiser 7cca3d8ef0 Improve exception handling. 2002-12-31 23:18:00 +00:00
Barry Warsaw b1dcbd223e Make two tests non-locale-dependent 2002-12-31 19:27:45 +00:00
Jeremy Hylton 1856541142 Replace all but one explicit emit('SET_LINENO') with call to set_lineno().
Remove broken code in visitDict().  I assume the code was trying to
add set lineno events for each line of a dict constructor, but I think
it was using the wrong object (node instead of k or v).
2002-12-31 18:26:17 +00:00
Tony Lownds cf94ee817c Don't let the docstring end up in __main__.__doc__ 2002-12-31 18:22:37 +00:00
Barry Warsaw bc38baffbd test01_close_dbenv_before_db(): Added an XXX comment that this test is
BerkeleyDB version dependent.
2002-12-31 18:21:43 +00:00
Neal Norwitz 0aae2b07d7 Comment out test, since it hangs on HPUX, still investigating 2002-12-31 18:21:11 +00:00
Jeremy Hylton accb62b28e SF patch [ 597919 ] compiler package and SET_LINENO
A variety of changes from Michael Hudson to get the compiler working
with 2.3.  The primary change is the handling of SET_LINENO:

# The set_lineno() function and the explicit emit() calls for
# SET_LINENO below are only used to generate the line number table.
# As of Python 2.3, the interpreter does not have a SET_LINENO
# instruction.  pyassem treats SET_LINENO opcodes as a special case.

A few other small changes:
 - Remove unused code from pycodegen and pyassem.
 - Fix error handling in parsermodule.  When PyParser_SimplerParseString()
   fails, it sets an exception with detailed info.  The parsermodule
   was clobbering that exception and replacing it was a generic
   "could not parse string" exception.  Keep the original exception.
2002-12-31 18:17:44 +00:00
Kurt B. Kaiser 2cb540253b Update (slightly) for Alpha release 2002-12-31 18:12:04 +00:00
Martin v. Löwis 64aa5f6982 Remove bogus test; the master is not a terminal on Solaris and HP-UX. 2002-12-31 18:05:15 +00:00
Kurt B. Kaiser 085ce5a77a Move history to HISTORY.txt 2002-12-31 17:57:44 +00:00
Kurt B. Kaiser f5934dd5f8 Update for Alpha 0 Release 2002-12-31 17:56:18 +00:00
Tim Peters 521fc15e62 A new, and much hairier, implementation of astimezone(), building on
an idea from Guido.  This restores that the datetime implementation
never passes a datetime d to a tzinfo method unless d.tzinfo is the
tzinfo instance whose method is being called.  That in turn allows
enormous simplifications in user-written tzinfo classes (see the Python
sandbox US.py and EU.py for fully fleshed-out examples).

d.astimezone(tz) also raises ValueError now if d lands in the one hour
of the year that can't be expressed in tz (this can happen iff tz models
both standard and daylight time).  That it used to return a nonsense
result always ate at me, and it turned out that it seemed impossible to
force a consistent nonsense result under the new implementation (which
doesn't know anything about how tzinfo classes implement their methods --
it can only infer properties indirectly).  Guido doesn't like this --
expect it to change.

New tests of conversion between adjacent DST-aware timezones don't pass
yet, and are commented out.

Running the datetime tests in a loop under a debug build leaks 9
references per test run, but I don't believe the datetime code is the
cause (it didn't leak the last time I changed the C code, and the leak
is the same if I disable all the tests that invoke the only function
that changed here).  I'll pursue that next.
2002-12-31 17:36:56 +00:00
Fred Drake e2c649126e Further cleanup of exceptions. All interpolation-related exceptions
now derive from InterpolationError, which is not raised directly (only
subclasses get raised).  This matches what the docs already said.
2002-12-31 17:23:27 +00:00
Tony Lownds d8a6c5f4f4 Keep __main__ namespace clean 2002-12-31 16:52:44 +00:00
Just van Rossum e29310a2b3 patch attached to sf item #643711:
any_missing() returns less bogus missing modules.

- I've rewritten scan_code() more or less from scratch,
factored bits and pieces out for readability.
- keep track of global assignments and failed imports per
module; use this to determine whether the Y in "from X
import Y" is a submodule or just a global name. This is not
100% doable: you can't tell which symbols are imported when
doing a star import of a non-Python module short of actually
importing it.
- added a new method to ModuleFinder: any_missing_maybe(),
which returns *two* lists, one with certain misses, one with
possible misses. The possible misses are *very* often false
alarms, so it's useful to keep this list separate.
any_misses() now simply returns the union of
any_missing_maybe().

TODO: documentation, test_modulefinder.py
2002-12-31 16:33:00 +00:00
Just van Rossum 41c554fbec moving modulefinder.py to the standard library 2002-12-31 16:27:33 +00:00
Kurt B. Kaiser 6655e4bc27 Whitespace Normalization 2002-12-31 16:03:23 +00:00
Martin v. Löwis 96a60e4af5 Patch #658927: Add getctime to os.path.
Document that getatime and getmtime may return floats.
2002-12-31 13:11:54 +00:00
Andrew MacIntyre c70a8e411f OS/2 EMX has no popen2.Popen3 even though bunzip2 is available 2002-12-31 11:28:22 +00:00
Andrew MacIntyre fd07e7dda7 add list of expected skips for the OS/2 EMX port 2002-12-31 11:26:50 +00:00
Fred Drake b456e4f25b Make sure PrettyPrinter methods that mirror the module-level
convenience functions isreadable() and isrecursive() work the same way
as the convenience functions.
2002-12-31 07:16:16 +00:00
Fred Drake 397b615056 - PrettyPrinter.isreadable(), .isrecursive():
Pass the right number of args to .format().  (Caught by
    pychecker.)
- Protect the global namespace more carefully.
- Don't use the types module now that we don't need to.
2002-12-31 07:14:18 +00:00
Fred Drake 5478219e11 Add a test that InterpolationError is constructed properly and raised
when expected.  Only applies to the ConfigParser and SafeConfigParser
classes, not RawConfigParser.
2002-12-31 06:57:25 +00:00
Fred Drake 00dc5a93c1 ConfigParser._interpolate(): Pass the missing key to the
InterpolationError constructor, not the KeyError exception itself.
    (Caught by the new InterpolationError test.)

SafeConfigParser._interpolate_some():  Pass the right number of
    arguments to the InterpolationError constructor.
    (Caught by pychecker.)
2002-12-31 06:55:41 +00:00
Guido van Rossum 0146f419b4 Fix name error, found by pychecker. 2002-12-31 01:08:35 +00:00
Neal Norwitz d8b5e3fda1 Tix update from Mike Clarkson (maintainer) 2002-12-30 23:52:01 +00:00
Fred Drake 8d5dd98a2e - added InterpolationSyntaxError to __all__
- added docstring to exceptions
2002-12-30 23:51:45 +00:00
Neal Norwitz ce1d944b6b Add missing InterpolationSyntaxError.
XXX Not sure this is correct.
2002-12-30 23:38:47 +00:00
Neal Norwitz 6ec0a8ab93 sys was already imported, remove second import 2002-12-30 23:36:02 +00:00
Fred Drake a872595f31 - prefer "import ... as" to "import / (assignments) / del" for most things
- when the thread module isn't available, subsequent attempts to import
  threading should not suceed
2002-12-30 23:32:50 +00:00
Jack Jansen acda3394bb Updated the expected skips for MacOSX. 2002-12-30 23:03:13 +00:00
Jack Jansen 06f0cef1ca Skip this test on MacOSX: the locale support is too minimal to make
it pass.
2002-12-30 23:02:55 +00:00
Guido van Rossum a0934246d3 Use the dummy_thread module in Queue.py and tempfile.py.
tempfile.py already contained code to let it run without threads present;
for Queue.py this is considered a useful feature too.
2002-12-30 22:36:09 +00:00
Guido van Rossum ad50ca91a9 Brett Cannon's dummy_thread and dummy_threading modules (SF patch
622537), with some nitpicking editorial changes.
2002-12-30 22:30:22 +00:00
Neal Norwitz 5efc50d8af Fix SF #658820, regex fixes for _strptime (Brett Cannon)
Disallow zero for days and months
2002-12-30 22:23:12 +00:00
Jack Jansen 0940c6267a These were somehow never added to CVS. 2002-12-30 22:14:35 +00:00
Just van Rossum 52e14d640b PEP 302 + zipimport:
- new import hooks in import.c, exposed in the sys module
- new module called 'zipimport'
- various changes to allow bootstrapping from zip files

I hope I didn't break the Windows build (or anything else for that
matter), but then again, it's been sitting on sf long enough...

Regarding the latest discussions on python-dev: zipimport sets
pkg.__path__ as specified in PEP 273, and likewise, sys.path item such as
/path/to/Archive.zip/subdir/ are supported again.
2002-12-30 22:08:05 +00:00
Jack Jansen 60087fb450 Moved most of Mac/Lib hierarchy to Lib/plat-mac: it can be used both
in MacPython-OS9 and MacPython-OSX (or the equivalent unix Python on
Mac OS X). The only items remaining in Mac/Lib are modules that are
meaningful only for MacPython-OS9 (CFM stuff, MacPython preferences
in resources, etc).
2002-12-30 22:04:23 +00:00
Guido van Rossum c262a1f51c Add __all__. (Brett Cannon.) 2002-12-30 21:59:55 +00:00
Barry Warsaw 9a0d779c7d Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
version 4.1.1 and works with up to BerkeleyDB 4.1.25.
2002-12-30 20:53:52 +00:00
Barry Warsaw 0a26235e67 Add some missing tests. Should now test everything that pybsddb's
test suite tests.
2002-12-30 20:53:18 +00:00
Tim Peters bad8ff089a A step on the way to making tzinfo classes writable by mortals: get rid
of the timetz case.  A tzinfo method will always see a datetimetz arg,
or None, now.  In the former case, it's still possible that it will get
a datetimetz argument belonging to a different timezone.  That will get
fixed next.
2002-12-30 20:52:32 +00:00
Barry Warsaw 74859f3aa6 Template for future tests. 2002-12-30 20:44:16 +00:00
Neil Schemenauer 3ea60c2a7a Match new sequence behavior. User defined types now behave better as and
with sequences.
2002-12-30 20:21:15 +00:00
Barry Warsaw 10ee7a7f15 test_bad_8bit_header(): Tests for optional argument `errors'. See SF
bug #648119.
2002-12-30 19:14:38 +00:00
Barry Warsaw f4fdff715a Header.__init__(), .append(): Add an optional argument `errors' which
is passed straight through to the unicode() and ustr.encode() calls.
I think it's the best we can do to address the UnicodeErrors in badly
encoded headers such as is described in SF bug #648119.
2002-12-30 19:13:00 +00:00
Barry Warsaw 72261c9dfb Actually, make this 2.5a1 since it will include API changes that may
need more vetting, and it will be included in Python 2.3a1.
2002-12-30 19:08:38 +00:00
Barry Warsaw 207d1c2065 Bump to 2.5 2002-12-30 17:45:41 +00:00
Barry Warsaw f29ffbdbf5 TestMIMEAudio.setUp(): Use the email package's copy of the audio test
file, needed because some binary distros (read RPMs) don't include the
test module in their standard Python package.  This eliminates an
external dependency and closes SF bug # 650441.
2002-12-30 17:45:02 +00:00
Barry Warsaw c99c08c764 A copy of the audio test file from Lib/test, needed because some
binary distros (read RPMs) don't include the test module in their
standard Python package.  This eliminates an external dependency and
closes SF bug # 650441.
2002-12-30 17:44:27 +00:00
Tim Peters 31cc3156e7 Added tests that conversion to our own timezone is always an identity,
and that conversion to "timezone" None is the same as stripping the
tzinfo member.
2002-12-30 17:37:30 +00:00
Barry Warsaw ba97659f5f parsedate_tz(): Fix SF bug #552345, optional FWS between the comma and
the day in an RFC 2822 date.
2002-12-30 17:21:36 +00:00
Barry Warsaw 795833fbc6 test_parsedate_compact(): A test for optional FWS between the comma
and the day number in an RFC 2822 date specification.  See bug
#552345.
2002-12-30 17:20:53 +00:00
Tim Peters 1024bf8364 Beefed up the timezone conversion test by adding a phony UTC zone that's
west of the US zones getting converted, and also by using Eastern "as if"
it were UTC (wrt Pacific), and vice versa.
2002-12-30 17:09:40 +00:00
Barry Warsaw 5c8fef903d A code cleansing pass 2002-12-30 16:43:42 +00:00
Barry Warsaw 1fb22bb24f Port rfc822.py changes that didn't make it into this copy,
specifically that dots are allowed in obs-phrase.  This fixes parsing
of dots in realnames.
2002-12-30 16:21:07 +00:00
Barry Warsaw edb59c1ee8 test_name_with_dots(): A new test to ensure that we're implementing
RFC 2822's rules w.r.t. dots in the realname part of address fields.
2002-12-30 16:19:52 +00:00
Marc-André Lemburg 63b482cefb String tests should test 8-bit strings :-) 2002-12-30 10:50:32 +00:00
Raymond Hettinger e401b6fc55 Last checkin was missing the tuple comma.
The new "substr in str" feature masked the error.
2002-12-30 07:21:32 +00:00
Raymond Hettinger ecccafb2d4 Restore the test of the random module after including "Random" in the
ignore tuple.

The line, "from _random import Random as CoreGenerator", fools the test
code which expects CoreGenerator.__name__ to be "CoreGenerator" instead
of "Random".
2002-12-30 07:04:47 +00:00
Raymond Hettinger 4c47bd5e60 Temporarily comment out a test that crashes upon the introduction of
the _random subclass for Random.
2002-12-30 03:01:25 +00:00
Raymond Hettinger dd24a9f363 This test depends on the exact ordering produced by the WichmannHill
random number generator.  Altered it a bit to use the old generator
and restore the test.
2002-12-30 00:46:09 +00:00
Tim Peters 621818b318 A start at non-trivial (== DST-aware) tests of timezone conversion.
Guido has in mind an easier way for users to code this stuff, but the
only tests we have now are for fixed-offset tzinfo classes, and this
stuff is extremely delicate in the endcases (read the new test code
for why:  there are holes in time <wink>).
2002-12-29 23:44:49 +00:00
Raymond Hettinger 40f6217092 SF patch 658251: Install a C implementation of the Mersenne Twister as the
core generator for random.py.
2002-12-29 23:03:38 +00:00
Kurt B. Kaiser 5e65ce671c Remove some old debugging print statements. 2002-12-29 22:48:52 +00:00
Kurt B. Kaiser 4ada7ad3bc M EditorWindow.py
M PyShell.py

1. PyShell Rev 1.39, EditorWindow Rev 1.37 fix was not handling a
   multiline prompt.
2. The same fix introduced a bug where hitting <enter> at a previous
   prompt-only line would copy the prompt to the iomark.
3. Move the setting of sys.ps1 earlier, into PyShell.main(), to allow
   this code to work before a shell is started up.
4. If cursor is on the input line in the prompt, and you hit <enter>,
   process the line instead of complaining.
5. If line has no stdin range (this includes the last line before shell
   restart) strip any prompt before recalling.
2002-12-29 22:03:38 +00:00
Marc-André Lemburg 79f57833f3 Patch for bug #659709: bogus computation of float length
Python 2.2.x backport candidate. (This bug has been around since
Python 1.6.)
2002-12-29 19:44:06 +00:00