Commit Graph

20018 Commits

Author SHA1 Message Date
Guido van Rossum 843daa8cad Test for the safety check in wrap_cmpfunc(). 2001-09-18 20:04:26 +00:00
Guido van Rossum ceccae5365 wrap_cmpfunc(): added a safety check for the __cmp__ wrapper. We can
only safely call a type's tp_compare slot if the second argument is
also an instance of the same type.  I hate to think what
e.g. int_compare() would do with a second argument that's a float!
2001-09-18 20:03:57 +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
Fred Drake 18d8d5a708 Fix minor usage and consistency nits. 2001-09-18 17:58:20 +00:00
Guido van Rossum 624c8af706 All the news that fits, we print.
(Went through the logs looking for nuggets.  This is what I found.)
2001-09-18 15:21:04 +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 f0b35e1501 Redo the PyMethod attributes using a dir()-friendly approach, creating
descriptors for each attribute.  The getattr() implementation is
similar to PyObject_GenericGetAttr(), but delegates to im_self instead
of looking in __dict__; I couldn't do this as a wrapper around
PyObject_GenericGetAttr().

XXX A problem here is that this is a case of *delegation*.  dir()
doesn't see exactly the same attributes that are actually defined;
e.g. if the delegate is a Python function object, it supports
attributes like func_code etc., but these are not visible to dir(); on
the other hand, dynamic function attributes (stored in the function's
__dict__) *are* visible to dir().  Maybe we need a mechanism to tell
dir() about the delegation mechanism?  I vaguely recall seeing a
request in the newsgroup for a more formal definition of attribute
delegation too.  Sigh, time for a new PEP.
2001-09-18 03:53:24 +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
Guido van Rossum 427ce80df6 Sort the headers in PYTHON_HEADERS alphabetically. Add
structmember.h, which was missing (and caused me a snide comment by
Tim when he fixed something I missed because of the missed dependency
:-).
2001-09-18 02:40:21 +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 26f68f5957 type_new(): Didn't compile anymore, due to change in struct memberlist
definition.  Guido, what else did you forget to check in <wink>?
2001-09-18 00:23:33 +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 5d1e34aa42 Track changes to compiler API 2001-09-17 21:31:35 +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 eab4328f1a Fix calculation of hardest_arg.
The argument properties are ordered from easiest to hardest.  The
harder the arg, the more complicated that code that must be generated
to return it from getChildren() and/or getChildNodes().  The old
calculation routine was bogus, because it always set hardest_arg to
the hardness of the last argument.  Now use max() to always set it to
the hardness of the hardest argument.
2001-09-17 20:16:30 +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
Guido van Rossum c299fc16f2 Add support for restricting access based on restricted execution mode.
Renamed the 'readonly' field to 'flags' and defined some new flag
bits: READ_RESTRICTED and WRITE_RESTRICTED, as well as a shortcut
RESTRICTED that means both.
2001-09-17 19:28:08 +00:00
Jeremy Hylton bf80a033ee Add -p option to invoke Python profiler 2001-09-17 18:08:40 +00:00
Jeremy Hylton ce0c19c4a8 Only print attributes that start with co_.
If passed a .py file as an argument, try to find its accompanying
.pyc.
2001-09-17 18:08:20 +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
Andrew M. Kuchling fda3c3ddae [Patch #462255, from Jason Tishler] Re-enables building the resouce
module on the Cygwin platform.
2001-09-17 16:19:16 +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
Guido van Rossum 3065c94f37 Add cross-compilation defaults to most AC_TRY_RUN values. The
supplied values are the most "normal" or "common" values found for
recent 32 bit machines.  This now seems to work to build Python 2.2
for the ARM processor used on the iPAQ.
2001-09-17 04:03:14 +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 bc7e863ce2 merge_class_dict(): Clear the error if __bases__ doesn't exist. 2001-09-16 20:33:22 +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 a2e2dbe8cd Improve handling of docstrings. I had feared this was a case of
introspection incompatibility, but in fact it's just that calltips
always gave up on a docstring that started with a newline (but
didn't realize they were giving up <wink>).
2001-09-16 02:19:49 +00:00
Tim Peters 5b7759f9db Fixed typo in new 'p' description. 2001-09-15 18:16:27 +00:00
Tim Peters 88091aae7e SF bug [#461674] struct 'p' format doesn't work (maybe)
Rewrote the 'p' description.
2001-09-15 18:09:22 +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
Tim Peters ad2dc3fc44 Update the warning about transporting marshals across boxes with different
ideas about sizeof(long).
2001-09-14 20:40:13 +00:00