Commit Graph

5084 Commits

Author SHA1 Message Date
Guido van Rossum 5b5e0b9bf9 Keep tabnanny happy. 2001-09-19 13:28:25 +00:00
Marc-André Lemburg 816a1b75b7 Fixed search function error reporting in the encodings package
__init__.py module to raise errors which can be catched as LookupErrors
as well as SystemErrors.

Modified the error messages to include more information about the
failing module.
2001-09-19 11:52:07 +00:00
Marc-André Lemburg aa32c5aa7c Added new helpers for easy access to codecs. Docs will follow. 2001-09-19 11:24:48 +00:00
Martin v. Löwis 5485404293 Patch to bug #461754: CDATA should not undergo entity subst. 2001-09-19 09:08:19 +00:00
Guido van Rossum 1952e388ca Add additional coercion support for "self subtypes" to int, long,
float (compare the recent checkin to complex).  Added tests for these.
2001-09-19 01:25:16 +00:00
Guido van Rossum d5d8e4a436 Enable two checks for comparing a complex to a complex subtype
instance.

Split a string comparison test in two halves, replacing "a==b==a" with
separate tests for a==b and b==a.  (Reason: while experimenting, this
test failed, and I wanted to know if it was the first or the second ==
operator that failed.)
2001-09-19 01:16:16 +00:00
Tim Peters 50fda6c21f Enable some comparison tests that failed before. Still having problems
with subsclasses of complex and string.
2001-09-18 21:24:18 +00:00
Guido van Rossum 0639f59859 Add a similar test for rich comparisons. 2001-09-18 21:06:04 +00:00
Fredrik Lundh 59b68656f8 fixed #449964: sre.sub raises an exception if the template contains a
\g<x> group reference followed by a character escape

(also restructured a few things on the way to fixing #449000)
2001-09-18 20:55:24 +00:00
Guido van Rossum ab3b0343b8 Hopefully fix 3-way comparisons. This unfortunately adds yet another
hack, and it's even more disgusting than a PyInstance_Check() call.
If the tp_compare slot is the slot used for overrides in Python,
it's always called.

Add some tests that show what should work too.
2001-09-18 20:38:53 +00:00
Guido van Rossum eb94905265 Get rid of a superfluous space after "--" in the message printed for a
skipped test -- the print command already supplies a space.
2001-09-18 20:34:19 +00:00
Andrew M. Kuchling 97c56357b1 Fix typo in comment 2001-09-18 20:29:48 +00:00
Guido van Rossum 843daa8cad Test for the safety check in wrap_cmpfunc(). 2001-09-18 20:04:26 +00:00
Fredrik Lundh 21009b9c6f an SRE bugfix a day keeps Guido away...
#462270: sub-tle difference between pre.sub and sre.sub.  PRE ignored
an empty match at the previous location, SRE didn't.

also synced with Secret Labs "sreopen" codebase.
2001-09-18 18:47:09 +00:00
Guido van Rossum 912e56c3ac SF bug #417176 (Martijn Pieters): MultiFile.read() includes CRLF
boundary.

Fixed by keeping a readahead buffer containing the next line.

XXX We have no test suite for this.  Maybe the new email package will
help?
2001-09-18 14:34:06 +00:00
Guido van Rossum 555d12f986 softspace(): be prepared to catch AttributeError as well as TypeError
upon attempted attribute assignment.  Caught by MWH, SF bug #462522.
2001-09-18 13:33:01 +00:00
Tim Peters 22cd768177 This module didn't work at all anymore -- blew up with AttributeError
on file.__methods__.  Since the docs say "This module will become obsolete
in a future release", this is just a quick hack to stop it from blowing
up.  If you care about this module, test it!  It doesn't make much sense
on Windows.
2001-09-18 05:40:24 +00:00
Guido van Rossum db2a902dee Undo some (but not all) of the more lenient acceptance of
(AttributeError, TypeError) -- the leniency wasn't needed everywhere.
2001-09-18 03:55:22 +00:00
Guido van Rossum bd13149711 - Some tests that check that assignments are not allowed expect this
to raise TypeError.  In practice, a disallowed attribute assignment
  can raise either TypeError or AttributeError (and it's unclear which
  is better).  So allow either.  (Yes, this is in anticipation of a
  code change that switches the exception raised. :-)

- Add a utility function, cantset(), which verifies that setting a
  particular attribute to a given value is disallowed, and also that
  deleting that same attribute is disallowed.  Use this in the
  test_func_*() tests.

- Add a new set of tests that test conformance of various instance
  method attributes.  (Also in anticipation of code that changes their
  implementation.)
2001-09-18 03:28:54 +00:00
Tim Peters b64bec3ec0 Whitespace normalization. 2001-09-18 02:26:39 +00:00
Tim Peters a86f0c17a1 Make test_socketserver require the network resource.
Add it back to the list of tests we expect to skip on Windows.
2001-09-18 02:18:57 +00:00
Tim Peters 7a76d4b4e4 I don't expect test_socketserver to get skipped on Windows anymore. 2001-09-18 00:24:10 +00:00
Tim Peters a9f6f22f72 Rework akin to test_threaded_import, so that this can run under regrtest.
Also raise TestSkipped (intead of appearing to fail) if the import lock
is held.
2001-09-17 23:56:20 +00:00
Guido van Rossum d9d1d4ac6f Rewrite function attributes to use the generic routines properly.
This uses the new "restricted" feature of structmember, and getset
descriptors for some of the type checks.
2001-09-17 23:46:56 +00:00
Jeremy Hylton 9dca36432e API change:
compile() becomes replacement for builtin compile()
compileFile() generates a .pyc from a .py
both are exported in __init__

compiler.parse() gets optional second argument to specify compilation
mode, e.g. single, eval, exec

Add AbstractCompileMode as parent class and Module, Expression, and
Interactive as concrete subclasses.  Each corresponds to a compilation
mode.

THe AbstractCompileMode instances in turn delegate to CodeGeneration
subclasses specialized for their particular functions --
ModuleCodeGenerator, ExpressionCodeGeneration,
InteractiveCodeGenerator.
2001-09-17 21:02:51 +00:00
Jeremy Hylton c8ed18a4e3 Re-created after change to astgen to calculate hardest_arg correctly 2001-09-17 20:17:02 +00:00
Jeremy Hylton 2e4cc7e0d8 Last set of change to get regression tests to pass
Remove the only test in the syntax module.  It ends up that the
transformer must handle this error case.

In the transformer, check for a list compression in com_assign_list()
by looking for a list_for node where a comma is expected.

In pycodegen.compile() re-raise the SyntaxError rather than catching
it and exiting
2001-09-17 19:33:48 +00:00
Jeremy Hylton 37c9351cf6 Handle more syntax errors.
Invoke compiler.syntax.check() after building AST.  If a SyntaxError
occurs, print the error and exit without generating a .pyc file.

Refactor code to use compiler.misc.set_filename() rather than passing
filename argument around to each CodeGenerator instance.
2001-09-17 18:03:55 +00:00
Jeremy Hylton 09392b77a4 Add utility to set filename attribute on all nodes 2001-09-17 18:02:21 +00:00
Fredrik Lundh b329b7134c Brian Quinlan's XML-RPC server framework. 2001-09-17 17:35:21 +00:00
Jeremy Hylton aee0bfedcc support true division 2001-09-17 16:41:02 +00:00
Guido van Rossum 83eeef4b06 SF patch #461781 by Chris Lawrence: os.path.realpath - Resolve symlinks:
Once upon a time, I put together a little function
   that tries to find the canonical filename for a given
   pathname on POSIX. I've finally gotten around to
   turning it into a proper patch with documentation.
   On non-POSIX, I made it an alias for 'abspath', as
   that's the behavior on POSIX when no symlinks are
   encountered in the path.

   Example:
   >>> os.path.realpath('/usr/bin/X11/X')
   '/usr/X11R6/bin/X'
2001-09-17 15:16:09 +00:00
Tim Peters 305b5857f6 PyObject_Dir(): Merge in __members__ and __methods__ too (if they exist,
and are lists, and then just the string elements (if any)).

There are good and bad reasons for this.  The good reason is to support
dir() "like before" on objects of extension types that haven't migrated
to the class introspection API yet.  The bad reason is that Python's own
method objects are such a type, and this is the quickest way to get their
im_self etc attrs to "show up" via dir().  It looks much messier to move
them to the new scheme, as their current getattr implementation presents
a view of their attrs that's a untion of their own attrs plus their
im_func's attrs.  In particular, methodobject.__dict__ actually returns
methodobject.im_func.__dict__, and if that's important to preserve it
doesn't seem to fit the class introspection model at all.
2001-09-17 02:38:46 +00:00
Tim Peters 28bc59f116 In a world with a growing number of subclassable types, replace
type(x) is T
tests with
    isinstance(x, T)
Also got rid of a future-generators import, left over from code that
wasn't intended to get checked in.
2001-09-16 08:40:16 +00:00
Tim Peters e0007821cd Since we had a bug with multiplication of dynamic long subclasses, add a
little test to make sure it doesn't come back.
2001-09-15 06:35:55 +00:00
Guido van Rossum 7e35d57c0c A fix for SF bug #461546 (bug in long_mul).
Both int and long multiplication are changed to be more careful in
their assumptions about when one of the arguments is a sequence: the
assumption that at least one of the arguments must be an int (or long,
respectively) is still held, but the assumption that these don't smell
like sequences is no longer true: a subtype of int or long may well
have a sequence-repeat thingie!
2001-09-15 03:14:32 +00:00
Tim Peters 0891ac017d The 'p' (Pascal string) pack code acts unreasonably when the string size
and count exceed 255.  Changed to preserve as much of the string as
possible (instead of count%256 characters).
2001-09-15 02:35:15 +00:00
Jeremy Hylton 1048aa933f Add code generator for yield stmt 2001-09-14 23:17:55 +00:00
Jeremy Hylton dd32138e7d limit prefix test for lambda
the compiler package generates a module-unique trailing suffix for
each lambda
2001-09-14 23:01:49 +00:00
Jeremy Hylton 6a9cac68b6 del no longer necessary now that new module is gone 2001-09-14 22:54:48 +00:00
Jeremy Hylton 1e99a77120 Various sundry changes for 2.2 compatibility
Remove the option to have nested scopes or old LGB scopes.  This has a
large impact on the code base, by removing the need for two variants
of each CodeGenerator.

Add a get_module() method to CodeGenerator objects, used to get the
future features for the current module.

Set CO_GENERATOR, CO_GENERATOR_ALLOWED, and CO_FUTURE_DIVISION flags
as appropriate.

Attempt to fix the value of nlocals in newCodeObject(), assuming that
nlocals is 0 if CO_NEWLOCALS is not defined.
2001-09-14 22:49:08 +00:00
Jeremy Hylton 652a22437a The object-being sliced in an assignment to a slice is referenced, not
bound.

When a Yield() node is visited, assign to the generator attribute of
the scope, not the visitor.
2001-09-14 22:45:57 +00:00
Jeremy Hylton 9ee78f7d61 the new new doesn't define CO_xxx as the old new did 2001-09-14 22:44:35 +00:00
Jeremy Hylton fff252d20d the names attribute of Global is not a node 2001-09-14 22:40:36 +00:00
Guido van Rossum f7fcf5eea6 SF patch #461413 (Gerhard Häring): Add STARTTLS feature to smtplib
This patch adds the features from RFC 2487 (Secure SMTP
   over TLS) to the smtplib module:

   - A starttls() function
   - Wrapper classes that simulate enough of sockets and
     files for smtplib, but really wrap a SSLObject
   - reset the list of known SMTP extensions at each call
     of ehlo(). This should have been the case anyway.
2001-09-14 16:08:44 +00:00
Tim Peters 0ab085c4cb Changed the dict implementation to take "string shortcuts" only when
keys are true strings -- no subclasses need apply.  This may be debatable.

The problem is that a str subclass may very well want to override __eq__
and/or __hash__ (see the new example of case-insensitive strings in
test_descr), but go-fast shortcuts for strings are ubiquitous in our dicts
(and subclass overrides aren't even looked for then).  Another go-fast
reason for the change is that PyCheck_StringExact() is a quicker test
than PyCheck_String(), and we make such a test on virtually every access
to every dict.

OTOH, a str subclass may also be perfectly happy using the base str eq
and hash, and this change slows them a lot.  But those cases are still
hypothetical, while Python's own reliance on true-string dicts is not.
2001-09-14 00:25:33 +00:00
Tim Peters 8fa45677c1 Now that file objects are subclassable, you can get at the file constructor
just by doing type(f) where f is any file object.  This left a hole in
restricted execution mode that rexec.py can't plug by itself (although it
can plug part of it; the rest is plugged in fileobject.c now).
2001-09-13 21:01:29 +00:00
Tim Peters 561f899d19 Use the keyword form of file() instead of open() to create TESTFN. 2001-09-13 19:36:36 +00:00
Tim Peters 808b94eb45 Added simple tests of keyword arguments in the basic type constructors. 2001-09-13 19:33:07 +00:00
Tim Peters 3f996e7266 type_call(): Change in policy. The keyword args (if any) are now passed
on to the tp_new slot (if non-NULL), as well as to the tp_init slot (if
any).  A sane type implementing both tp_new and tp_init should probably
pay attention to the arguments in only one of them.
2001-09-13 19:18:27 +00:00