Commit Graph

22426 Commits

Author SHA1 Message Date
Guido van Rossum 517c7d4fd3 PyNumber_CoerceEx: this took a shortcut (not doing anything) when the
left and right type were of the same type and not classic instances.

This shortcut is dangerous for proxy types, because it means that
coerce(Proxy(1), Proxy(2.1)) leaves Proxy(1) unchanged rather than
turning it into Proxy(1.0).

In an ever-so-slight change of semantics, I now only take the shortcut
when the left and right types are of the same type and don't have the
CHECKTYPES feature.  It so happens that classic instances have this
flag, so the shortcut is still skipped in this case (i.e. nothing
changes for classic instances).  Proxies also have this flag set
(otherwise implementing numeric operations on proxies would become
nightmarish) and this means that the shortcut is also skipped there,
as desired.  It so happens that int, long and float also have this
flag set; that means that e.g. coerce(1, 1) will now invoke
int_coerce().  This is fine: int_coerce() can deal with this, and I'm
not worried about the performance; int_coerce() is only invoked when
the user explicitly calls coerce(), which should be rarer than rare.
2002-04-26 02:49:14 +00:00
Fred Drake d451ec1cdb Clean up uses of some deprecated features.
Reported by Neal Norwitz on python-dev.
2002-04-26 02:29:55 +00:00
Neil Schemenauer 89e3ee0ccf If Py_OptimizeFlag is false then always evaluate assert conditions, don't
test __debug__ at runtime.  Closes SF patch #548833.
2002-04-26 01:58:53 +00:00
Guido van Rossum 9364698101 Make sure that tp_free frees the int the same way as tp_dealloc would.
This fixes the problem that Barry reported on python-dev:
   >>> 23000 .__class__ = bool
crashes in the deallocator.  This was because int inherited tp_free
from object, which uses the default allocator.

2.2. Bugfix candidate.
2002-04-26 00:53:34 +00:00
Barry Warsaw cf22c826a6 Fix typo in the setup of interpreter-mode-alist. 2002-04-25 21:46:33 +00:00
Barry Warsaw 884916112e SF patch #510288 by Kevin J. Butler, mod'd by Barry. This provides
better auto-recognition of a Jython file vs. a CPython (or agnostic)
file by looking at the #! line more closely, and inspecting the import
statements in the first 20000 bytes (configurable).  Specifically,

(py-import-check-point-max): New variable, controlling how far into
the buffer it will search for import statements.

(py-jpython-packages): List of package names that are Jython-ish.

(py-shell-alist): List of #! line programs and the modes associated
with them.

(jpython-mode-hook): Extra hook that runs when entering jpython-mode
(what about Jython mode? <20k wink>).

(py-choose-shell-by-shebang, py-choose-shell-by-import,
py-choose-shell): New functions.

(python-mode): Use py-choose-shell.

(jpython-mode): New command.

(py-execute-region): Don't use my previous hacky attempt at doing
this, use the new py-choose-shell function.

One other thing this file now does: it attempts to add the proper
hooks to interpreter-mode-alist and auto-mode-alist if they aren't
already there.  Might help with Emacs users since that editor doesn't
come with python-mode by default.
2002-04-25 21:31:47 +00:00
Guido van Rossum c95cc87447 Clean up the layout of the bool_as_number struct initializer. 2002-04-25 20:01:10 +00:00
Barry Warsaw 4aab68e1c1 (py-execute-region): Alexander Schmolck points out that leading
whitespace can hose the needs-if test.  So just skip all blank lines
at the start of the region right off the bat.
2002-04-25 19:17:42 +00:00
Thomas Heller 69d31b749d Pass the full pathname to MSVC when compiling a debug version. This
allows the debugger to find the source without asking the user to
browse for it.
2002-04-25 17:29:45 +00:00
Thomas Heller 378498dad6 Append the PC specific include 'PC' and library 'PCBuild' directories
under NT - this allows distutils to work with the CVS version or the
source distribution.

Wrap a long line.
2002-04-25 17:26:37 +00:00
Thomas Heller e65008038e Fix trivial typo. 2002-04-25 17:03:30 +00:00
Barry Warsaw 13caba30b8 (py-comint-output-filter-function): Add a pop-to-buffer call so you
always get to see the result of e.g. a py-execute-region.  Funny, this
bugged both me /and/ Guido!
2002-04-25 16:26:38 +00:00
Barry Warsaw 56bd2edeef (py-shell-hook): A new hook variable, run at the end of py-shell.
Allows for some customization of the underlying comint buffer.

(py-shell): Call the new hook.

(info-lookup-maybe-add-help): A new call suggested by Milan Zamazal to
make lookups in the Info documentation easier.
2002-04-25 15:44:17 +00:00
Jack Jansen 65300f17c3 Regenerated.
Bugfix candidate.
2002-04-24 09:13:24 +00:00
Thomas Heller 8da4b59221 Fix a small mistake and complete some function prototypes.
SF Patch #547813.
2002-04-24 06:35:11 +00:00
Neil Schemenauer 3b04d635a2 Add more tests for abstract isinstance() and issubclass(). 2002-04-24 03:33:02 +00:00
Tim Peters 1e33ffa5c7 test_resource has no chance of running on Windows. 2002-04-23 23:09:02 +00:00
Tim Peters e12cda9840 test_mmap started breaking on Windows, only when run after test_bsddb.
On Win2K it thought 'foo' started at byte offset 0 instead of at the
pagesize, and on Win98 it thought 'foo' didn't exist at all.  Somehow
or other this is related to the new "in memory file" gimmicks in
bsddb, but the old bsddb we use on Windows sucks so bad anyway I don't
want to bother digging deeper.  Flushing the file in test_mmap after
writing to it makes the problem go away, so good enough.
2002-04-23 23:07:28 +00:00
Barry Warsaw 906569de24 Unit tests for the changes in abstract.c version 2.101. The debug
build's "undetected error" problems were originally detected with
extension types, but we can whitebox test the same situations with
new-style classes.
2002-04-23 22:48:42 +00:00
Jack Jansen 033b79c483 Regenerated. 2002-04-23 22:46:01 +00:00
Barry Warsaw f16951cffe abstract_get_bases(): Clarify exactly what the return values and
states can be for this function, and ensure that only AttributeErrors
are masked.  Any other exception raised via the equivalent of
getattr(cls, '__bases__') should be propagated up.

abstract_issubclass(): If abstract_get_bases() returns NULL, we must
call PyErr_Occurred() to see if an exception is being propagated, and
return -1 or 0 as appropriate.  This is the specific fix for a problem
whereby if getattr(derived, '__bases__') raised an exception, an
"undetected error" would occur (under a debug build).  This nasty
situation was uncovered when writing a security proxy extension type
for the Zope3 project, where the security proxy raised a Forbidden
exception on getattr of __bases__.

PyObject_IsInstance(), PyObject_IsSubclass(): After both calls to
abstract_get_bases(), where we're setting the TypeError if the return
value is NULL, we must first check to see if an exception occurred,
and /not/ mask an existing exception.

Neil Schemenauer should double check that these changes don't break
his ExtensionClass examples (there aren't any test cases for those
examples and abstract_get_bases() was added by him in response to
problems with ExtensionClass).  Neil, please add test cases if
possible!

I belive this is a bug fix candidate for Python 2.2.2.
2002-04-23 22:45:44 +00:00
Jack Jansen 3adf8d1dae Converted to use re in stead of regex and regsub (finally:-). 2002-04-23 22:43:37 +00:00
Barry Warsaw 5ca537473b Rewrote the PyUnit description so that it now recommends to use
run_suite() instead of run_unittest().  Best practice is to plan for
multiple test classes.
2002-04-23 21:39:00 +00:00
Fred Drake 99d17006c1 Add text about circular references caused by storing frames in local
variables.  This closes SF bug #543148.
2002-04-23 21:21:20 +00:00
Jack Jansen 95df3fd159 Second part of fix for #493826: regenerated suite modules so errn exists but == 0 doesn't signal an error.
Bugfix candidate.
2002-04-23 21:08:54 +00:00
Jack Jansen 18983536dc First part of fix for #493826: if 'errn' key exists in return value this doesn't necesarily signal an error, only if the value is non-zero it does. This
does not correspond with my reading of the documentation, but the OSX Finder can return 'errn'=0, and it knows better than me:-)

Bugfix candidate.
2002-04-23 21:03:21 +00:00
Jeremy Hylton 1b0bf9b761 Ignore SIGXFSZ.
The SIGXFSZ signal is sent when the maximum file size limit is
exceeded (RLIMIT_FSIZE).  Apparently, it is also sent when the 2GB
file limit is reached on platforms without large file support.

The default action for SIGXFSZ is to terminate the process and dump
core.  When it is ignored, the system call that caused the limit to be
exceeded returns an error and sets errno to EFBIG.  Python
always checks errno on I/O syscalls, so there is nothing to do with
the signal.
2002-04-23 20:31:01 +00:00
Jeremy Hylton 74ce77f0e6 Add tests for the recent resource module change.
Also add a test that Python doesn't die with SIGXFSZ if it exceeds the
file rlimit.  (Assuming this will also test the behavior when the 2GB
limit is exceed on a platform that doesn't have large file support.)
2002-04-23 20:21:22 +00:00
Jeremy Hylton d95efe4257 Check for overflow errors in setrlimit(),
and reflow a long line.
2002-04-23 20:15:04 +00:00
Fred Drake ed9e453eb7 Minor change to an index entry. 2002-04-23 20:04:46 +00:00
Jeremy Hylton c4ad0bcbe5 Clarify return value of PyLong_AsLongLong().
The function is documented to return -1 on error.  If res was < 0, it
returned res.  It wasn't clear that the invariant was res < 0 iff res
== -1.
2002-04-23 20:01:20 +00:00
Jack Jansen 656b735af9 Backport of 1.6.4.2.2.3 from release22-maint branch. 2002-04-23 19:59:03 +00:00
Jack Jansen d92b7a01c5 Updated URL. 2002-04-23 19:56:20 +00:00
Jack Jansen 601b2fddf2 Backport of select parts of release22-maint (up to 1.38.4.2.2.3). 2002-04-23 19:50:53 +00:00
Barry Warsaw 8570013357 Whitespace normalization. Unka Timmy would be proud. 2002-04-23 18:18:43 +00:00
Fred Drake b957bc3dcc Clarify the return value of PyObject_IsInstance(). 2002-04-23 18:15:44 +00:00
Fred Drake 106c1a0e7a WCOREDUMP(), WIFCONTINUED(), WCONTINUED, WUNTRACED: New.
isatty(), WIFEXITED(), WIFSIGNALED(), WIFSTOPPED(): Changed to return
    bools instead of ints.
2002-04-23 15:58:02 +00:00
Guido van Rossum 256705bca7 SF patch 546244 by John Williams: add Text.dump() method. 2002-04-23 13:29:43 +00:00
Guido van Rossum 4e1dd7d63b Add warning about the HP PA-RISC 2.0 C compiler's optimizer. 2002-04-23 13:06:07 +00:00
Jack Jansen 1476c2753b There was a non-ascii character in the source. Replaced by a hex escape. 2002-04-23 10:52:44 +00:00
Anthony Baxter ae7639dbfb whitespace fixup. test__all__ and test_sundry were failing
for me on linux because of the inconsistent whitespace.
2002-04-23 02:38:39 +00:00
Anthony Baxter 4ce6b351cc don't fail if the audio device is busy, just skip.
SF patch 545486
2002-04-23 02:20:46 +00:00
Anthony Baxter 8388895fe4 SF patch [ 545523 ] patch for 514433 bsddb.dbopen (NULL)
closes SF #514433

can now pass 'None' as the filename for the bsddb.*open functions,
and you'll get an in-memory temporary store.

docs are ripped out of the bsddb dbopen man page. Fred may want to
clean them up.

Considering this for 2.2, but not 2.1.
2002-04-23 02:11:05 +00:00
Barry Warsaw 0494955b8f Merge in Skip's last few updates w.r.t. py-help-at-point:
(py-mode-map): Bind py-help-at-point to f1 as well as C-c C-h

(py-help-at-point): Make sure the symbol is quoted so things like
pydoc.help('sys.platform') work correctly.  Also, leave the *Python
Output* buffer in help-mode; this may be a bit more controversial.
2002-04-22 22:05:49 +00:00
Barry Warsaw 29a90f0a7a Some contributions and ideas by Alexander Schmolck: add a keybinding
to call pychecker on the current file, add a face for pseudo
keywords self, None, True, False, and Ellipsis.  Specifically,

(py-pychecker-command, py-pychecker-command-args): New variables.

(py-pseudo-keyword-face): New face variable, defaulting to a copy of
font-lock-keyword-face.

(python-font-lock-keywords): Add an entry for self, None, True, False,
Ellipsis to be rendered in py-pseudo-keyword-face.

(py-pychecker-history): New variable.

(py-mode-map): Bind C-c C-w to py-pychecker-run.

(py-pychecker-run): New command.
2002-04-22 21:48:20 +00:00
Tim Peters 030a5cebf4 unicode_memchr(): Squashed gratuitous int-vs-size_t mismatch (which
gives a compiler wng under MSVC because of the resulting signed-vs-
unsigned comparison).
2002-04-22 19:00:10 +00:00
Tim Peters 32b069cf54 SF bug 546078: IDLE calltips cause application error.
Assorted crashes on Windows and Linux when trying to display a very
long calltip, most likely a Tk bug.  Wormed around by clamping the
calltip display to a maximum of 79 characters (why 79? why not ...).

Bugfix candidate, for all Python releases.
2002-04-22 18:43:49 +00:00
Walter Dörwald de02bcb265 Apply patch diff.txt from SF feature request
http://www.python.org/sf/444708

This adds the optional argument for str.strip
to unicode.strip too and makes it possible
to call str.strip with a unicode argument
and unicode.strip with a str argument.
2002-04-22 17:42:37 +00:00
Barry Warsaw a7cc43b9e8 Skip Montanaro's contribution (slightly mod'd by Barry) to provide a
"help-on-symbol-at-point" feature which uses pydoc to provide help on
the symbol under point, if available.

Mods include some name changes, a port to Emacs, binding the command
to C-c C-h, and providing a more informative error message if the
symbol's help can't be found (through use of a nasty bare except).

Note also that py-describe-mode has been moved off of C-c C-h m; it's
now just available on C-c ?

Closes SF patch #545439.
2002-04-22 17:15:19 +00:00
Barry Warsaw a0113cd5cd (py-execute-region): If the line at the beginning of the region is a
#! line, use the command on that line as the shell command to use to
execute the region.  I.e. if the region looks like

----------------
#! /usr/bin/env python1.5

print 'hello world'.startswith('hello')
----------------

you'll get an exception! :)

This closes SF bug #232398.
2002-04-22 16:23:29 +00:00