Commit Graph

3828 Commits

Author SHA1 Message Date
Thomas Wouters 9bc844e7be Make Py_ssize_t-clean. 2006-03-01 21:50:07 +00:00
Thomas Wouters f98db65e52 Make Py_ssize_t-clean. 2006-03-01 21:37:32 +00:00
Martin v. Löwis 6db0e00d57 Change GC refcount to Py_ssize_t. 2006-03-01 16:56:25 +00:00
Tim Peters 67d70eb957 Repair mangled code in the Windows flavor of
posix__getfullpathname().

In partial answer to the now-deleted XXX comment:

	/* XXX(twouters) Why use 'et#' here at all? insize isn't used */

`insize` is an input parameter too, and it was left uninitialized,
leading to seemingly random failures.
2006-03-01 04:35:45 +00:00
Thomas Wouters 68bc4f9ae5 Py_ssize_t-ify. 2006-03-01 01:05:10 +00:00
Thomas Wouters 9d63ccae90 Fix DBEnv's set_tx_timestamp wrapper to be slightly more correct on
non-32bit platforms. Will still only allow 32 bits in a timestamp on Win64,
but at least it won't crash, and it'll work right on platforms where longs
are big enough to contain time_t's.

(A better-working, although conceptually less-right fix would have been to
use Py_ssize_t here, but Martin and Tim won't let me.)
2006-03-01 01:01:55 +00:00
Guido van Rossum 1a5e21e033 Updates to the with-statement:
- New semantics for __exit__() -- it must re-raise the exception
  if type is not None; the with-statement itself doesn't do this.
  (See the updated PEP for motivation.)

- Added context managers to:
  - file
  - thread.LockType
  - threading.{Lock,RLock,Condition,Semaphore,BoundedSemaphore}
  - decimal.Context

- Added contextlib.py, which defines @contextmanager, nested(), closing().

- Unit tests all around; bot no docs yet.
2006-02-28 21:57:43 +00:00
Tim Peters 85b1052efe Another bit of unconstification. 2006-02-28 18:33:35 +00:00
Thomas Wouters f7f438ba3b SF patch #1438387, PEP 328: relative and absolute imports.
- IMPORT_NAME takes an extra argument from the stack: the relativeness of
   the import. Only passed to __import__ when it's not -1.

 - __import__() takes an optional 5th argument for the same thing; it
   __defaults to -1 (old semantics: try relative, then absolute)

 - 'from . import name' imports name (be it module or regular attribute)
   from the current module's *package*. Likewise, 'from .module import name'
   will import name from a sibling to the current module.

 - Importing from outside a package is not allowed; 'from . import sys' in a
   toplevel module will not work, nor will 'from .. import sys' in a
   (single-level) package.

 - 'from __future__ import absolute_import' will turn on the new semantics
   for import and from-import: imports will be absolute, except for
   from-import with dots.

Includes tests for regular imports and importhooks, parser changes and a
NEWS item, but no compiler-package changes or documentation changes.
2006-02-28 16:09:29 +00:00
Martin v. Löwis 1d519e4625 unconst. 2006-02-27 23:10:11 +00:00
Thomas Wouters b9eb5510e6 Convert array.array.insert to use Py_ssize_t (like the rest already does.) 2006-02-27 19:44:56 +00:00
Martin v. Löwis 02cbf4ae4b More unconsting. 2006-02-27 17:20:04 +00:00
Martin v. Löwis b79afb6e3a unconst. 2006-02-27 17:01:22 +00:00
Martin v. Löwis 15e62742fa Revert backwards-incompatible const changes. 2006-02-27 16:46:16 +00:00
Thomas Wouters e2dd78c760 Update for PEP 308 patch. 2006-02-27 16:25:11 +00:00
Martin v. Löwis 577b5b960d Create _ast module.
Cleanup Python-ast.c generation.
2006-02-27 15:23:19 +00:00
Guido van Rossum 1968ad32cd - Patch 1433928:
- The copy module now "copies" function objects (as atomic objects).
  - dict.__getitem__ now looks for a __missing__ hook before raising
    KeyError.
  - Added a new type, defaultdict, to the collections module.
    This uses the new __missing__ hook behavior added to dict (see above).
2006-02-25 22:38:04 +00:00
Georg Brandl c2fb6c74c6 Fix typo in functional module 2006-02-21 17:49:57 +00:00
Guido van Rossum 668a94a34f NETLINK_TCPDIAG and NETLINK_NFLOG aren't defined on older Linux
systems; define these conditionally.
2006-02-21 01:07:27 +00:00
Georg Brandl e393bf6fe3 Patch #931938: prevent setting sys.prefix to "" 2006-02-20 17:37:36 +00:00
Georg Brandl dbd8339a01 Bug #854823: socketmodule now builds on Sun platforms even when
INET_ADDRSTRLEN is not defined.
2006-02-20 09:42:33 +00:00
Hye-Shik Chang d69e034571 Fix a build problem introduced by r42230. 2006-02-19 16:22:22 +00:00
Georg Brandl e810fe2ca4 Remove two instances of trailing commas. Resolves patch #1209781. 2006-02-19 15:28:47 +00:00
Georg Brandl e9b1949f70 Patch #1352711: make zipimport raise a complete IOError 2006-02-19 09:38:58 +00:00
Neal Norwitz 093ab1aa03 Remove unused variable 2006-02-18 23:26:27 +00:00
Georg Brandl f4f4415a18 Patch #1393157: os.startfile() now has an optional argument to specify
a "command verb" to invoke on the file.
2006-02-18 22:29:33 +00:00
Georg Brandl 47fab92542 Bug #1366000: cleanup BZ2File.seek() logic. Fixes the case of whence=2, offset>=0. 2006-02-18 21:57:25 +00:00
Martin v. Löwis 5bb8a15593 Fix typo. 2006-02-18 12:49:49 +00:00
Martin v. Löwis 151860752f Fix size computation on Win64. 2006-02-18 12:38:35 +00:00
Martin v. Löwis 5c97c798d2 Make ssize_t-clean. 2006-02-17 15:49:09 +00:00
Georg Brandl b86a54f395 Add deprecation warning to modules deprecated since 2000. 2006-02-17 11:29:04 +00:00
Thomas Wouters 2c98a7bbc6 Fix typo. 2006-02-17 09:59:00 +00:00
Georg Brandl 1b6726732c Bug #1432350: arrayobject should use PyObject_VAR_HEAD 2006-02-17 08:56:33 +00:00
Martin v. Löwis cfe7e0912c Remove size restrictions. 2006-02-17 06:59:14 +00:00
Tim Peters f28829577d mmap_flush_method(): Squash compiler warning about
mixing signed and unsigned types in comparison.
2006-02-17 01:07:39 +00:00
Tim Peters 8f9cc29e74 Remove space between function name and left paren
in function calls.
2006-02-17 00:00:20 +00:00
Tim Peters 23721ee96c Removed pointless parens around `return` expressions;
deleted some curlies around one-line blocks.
2006-02-16 23:50:16 +00:00
Tim Peters ec0a5f0add Trimmed trailing whitespace. 2006-02-16 23:47:20 +00:00
Tim Peters e564e7f939 new_mmap_object(), Windows flavor.
On a box where sizeof(size_t) == 4, C doesn't define
what happens when a size_t value is shifted right by
32 bits, and this caused test_mmap to fail on Windows
in a debug build.  So use different code to break
the size apart depending on how large size_t actually
is.

This looks like an illusion, since lots of code in this
module still appears to assume sizes can't be more
than 32 bits (e.g., the internal _GetMapSize() still
returns an int), but at least test_mmap passes again.
2006-02-16 23:46:01 +00:00
Thomas Wouters dde176593d More Py_ssize_t format characters. 2006-02-16 21:10:52 +00:00
Tim Peters 2ad8c56e6c struct_pack(): Repair new assert-fail crash in
debug-build test_struct on a box where plain "char"
is signed.
2006-02-16 20:19:46 +00:00
Thomas Wouters 13870b18f2 Also make _heapq.nlargest() use Py_ssize_t instead of ints, to iter over
lists and call Py_ssize_t-using helpers. All other code in this module was
already adapted to Py_ssize_t.
2006-02-16 19:21:53 +00:00
Thomas Wouters ed6254acf2 Use 'n' format for Py_ssize_t variables to PyArg_ParseTuple(). Py_ssize_t
has been applied fairly arbitrarily in this module (nsmallest uses
Py_ssize_t, nlargest does not) and it probably deserves a more complete
review. Fixes heapq.nsmallest() always returning the empty list (on
platforms with 64-bit ssize_t/long)
2006-02-16 17:32:54 +00:00
Thomas Wouters 7a2f83b706 Use correct format specifier for Py_ssize_t variable to PyArg_ParseTuple(). 2006-02-16 17:07:41 +00:00
Martin v. Löwis 41290685f9 Change _PyObject_GC_Resize to expect Py_ssize_t. 2006-02-16 14:56:14 +00:00
Martin v. Löwis ad0a4629be Use Py_ssize_t for counts and sizes. 2006-02-16 14:30:23 +00:00
Neal Norwitz 3eaf2b5044 Update comment and make accurate. 2006-02-16 08:08:54 +00:00
Martin v. Löwis 18e165558b Merge ssize_t branch. 2006-02-15 17:27:45 +00:00
Tim Peters 219c164a47 randombits(): Stop compiler warning about mixing
signed with unsigned types in comparison.
2006-02-15 03:01:30 +00:00
Neal Norwitz 389cea8efc Try to improve name based on discussion on python-checkins with Jim Jewett 2006-02-13 00:35:21 +00:00
Armin Rigo f5b3e36493 Renamed _length_cue() to __length_hint__(). See:
http://mail.python.org/pipermail/python-dev/2006-February/060524.html
2006-02-11 21:32:43 +00:00
Martin v. Löwis f84d1b9375 Introduce Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE.
Proposed by Tim Peters.
2006-02-11 09:27:05 +00:00
Armin Rigo 2bc23f512d The default timer unit was incorrectly measured in milliseconds instead
of seconds, producing numbers 1000 times too large.  It would be nice to
write a test for this, but how...  (thanks mwh)
2006-02-10 13:19:53 +00:00
Armin Rigo a871ef2b3e Added the cProfile module.
Based on lsprof (patch #1212837) by Brett Rosen and Ted Czotter.
With further editing by Michael Hudson and myself.
History in svn repo: http://codespeak.net/svn/user/arigo/hack/misc/lsprof

* Module/_lsprof.c is the internal C module, Lib/cProfile.py a wrapper.
* pstats.py updated to display cProfile's caller/callee timings if available.
* setup.py and NEWS updated.
* documentation updates in the profiler section:
   - explain the differences between the three profilers that we have now
   - profile and cProfile can use a unified documentation, like (c)Pickle
   - mention that hotshot is "for specialized usage" now
   - removed references to the "old profiler" that no longer exists
* test updates:
   - extended test_profile to cover delicate cases like recursion
   - added tests for the caller/callee displays
   - added test_cProfile, performing the same tests for cProfile
* TO-DO:
   - cProfile gives a nicer name to built-in, particularly built-in methods,
     which could be backported to profile.
   - not tested on Windows recently!
2006-02-08 12:53:56 +00:00
Neal Norwitz 082b2df33f Bug #876637, prevent stack corruption when socket descriptor
is larger than FD_SETSIZE.

This can only be acheived with ulimit -n SOME_NUMBER_BIGGER_THAN_FD_SETSIZE
which is typically only available to root.  Since this wouldn't normally
be run in a test (ie, run as root), it doesn't seem too worthwhile to
add a normal test.  The bug report has one version of a test.  I've
written another.  Not sure what the best thing to do is.

Do the check before calling internal_select() because we can't set
an error in between Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS.
This seemed the clearest solution, ie handle before calling internal_select()
rather than inside.  Plus there is at least one place outside
of internal_select() that needed to be handled.

Will backport.
2006-02-07 07:04:46 +00:00
Neal Norwitz 19cbcad20e Fix indentation (whitespace only). 2006-02-07 06:59:20 +00:00
Neal Norwitz 02876df9de Check return results for errors 2006-02-07 06:58:52 +00:00
Neal Norwitz 0e6bc8c260 Patch #1407135, bug #1424041, make mmap.mmap(-1, length) work the same
on both Unix (SVR4 and BSD) and Windows.  Restores behaviour of passing -1
for anonymous memory on Unix.  Use MAP_ANONYMOUS instead of _ANON since
the latter is deprecated according to Linux (gentoo) man pages.

Should we continue to allow mmap.mmap(0, length) to work on Windows?
0 is a valid fd.

Will backport bugfix portions.
2006-02-05 05:45:43 +00:00
Neal Norwitz d1cfc8ade1 Whitespace normalization 2006-02-05 03:36:57 +00:00
Martin v. Löwis 57a34e8026 Patch #1422385: Changes to nis module to support multiple NIS domains 2006-02-04 19:12:37 +00:00
Martin v. Löwis 14694662d5 Drop C library for stat/fstat on Windows. 2006-02-03 12:54:16 +00:00
Gregory P. Smith fd049a696d maintain support for older python versions in this module so that it
is ok for a standalone pybsddb source dist for use with <= 2.3.
2006-01-30 00:22:08 +00:00
Gregory P. Smith 8a47404799 Add wrapper for DBEnv.set_tx_timeout method to allow time based DB_RECOVER 2006-01-27 07:05:40 +00:00
Neal Norwitz 62a21121b4 Fix bug #1413192, fix seg fault in bsddb if a txn was deleted before the env.
Will backport.
2006-01-25 05:21:55 +00:00
Gregory P. Smith 4e414d8386 commits sourceforge patch #1407992 by neil.norwitz.
this fixes the bsddb db associate tests when compiled against
BerkeleyDB 3.3 thru 4.1.  4.2 thru 4.4 already passed and still
pass.
2006-01-24 19:55:02 +00:00
Gregory P. Smith 29602d2153 Support for BerkeleyDB 4.4 (tested against 4.4.20 as well as all the
way back thru 3.2).  This should be backported to the release24-maint
branch.
2006-01-24 09:46:48 +00:00
Tim Peters 3d56350910 _compile(): raise an exception if downcasting to SRE_CODE
loses information:

    OverflowError: regular expression code size limit exceeded

Otherwise the compiled code is gibberish, possibly leading at
least to wrong results or (as reported on c.l.py) internal
sre errors at match time.

I'm not sure how to test this.  SRE_CODE is a 2-byte type on
my box, and it's easy to create a regexp that causes the new
exception to trigger here.  But it may be a 4-byte type on
other boxes, and creating a regexp large enough to trigger
problems there would be pretty crazy.

Bugfix candidate.
2006-01-21 02:47:53 +00:00
Neal Norwitz 1ac754fa10 Check return result from Py_InitModule*(). This API can fail.
Probably should be backported.
2006-01-19 06:09:39 +00:00
Martin v. Löwis d078e40d41 Generate getbuildinfo.o each time the linker is invoked;
try to generate SVNVERSION information if subwcrev.exe
can be found.
2006-01-18 09:13:51 +00:00
Neal Norwitz 20bad74d63 SF Bug #1407069, Remove extra semi-colon if there is no long long 2006-01-17 05:27:39 +00:00
Neal Norwitz 658516617c Get socketmodule to build after adding netlink support. 2006-01-16 04:31:40 +00:00
Fredrik Lundh b84b35f02a the implementation uses ZipImportError, not ZipImporterError... 2006-01-15 15:00:40 +00:00
Martin v. Löwis d056005482 Change build format of netlink addresses. 2006-01-15 07:49:20 +00:00
Martin v. Löwis 11017b172d Patch #1103116: AF_NETLINK sockets basic support. 2006-01-14 18:12:57 +00:00
Neal Norwitz 3b4fff8079 Fix SF bug #1402308, segfault when using mmap(-1, ...)
This didn't crash on Linux, but valgrind complained.
I'm not sure if this test is valid on Windows.

Will backport.
2006-01-11 08:54:45 +00:00
Neal Norwitz 88bbd73d07 SF bug #1400822, Extended version of _curses over{lay,write} does not work
Fix signatures to conform to doc (also fixed ungetmouse()).

Will backport.
2006-01-10 07:05:44 +00:00
Neal Norwitz 5e3d862392 Bug #1400115, Fix segfault when calling curses.panel.userptr()
without prior setting of the userptr.

Will backport.
2006-01-09 06:24:35 +00:00
Neal Norwitz d948a43df8 Fix icc warnings: try to set TCL_UNIX_FD for #if TCL_WIN_SOCKET == TCL_UNIX_FD. res is not used, add a XXX comment 2006-01-08 01:08:55 +00:00
Neal Norwitz e4ab5f5531 Fix icc warnings: HASH_OBJ_CONSTRUCTOR was not defined and using #if HASH_OBJ_CONSTRUCTOR 2006-01-08 01:08:09 +00:00
Neal Norwitz d39d861a36 Fix icc warnings: strlen() returns size_t 2006-01-08 01:03:36 +00:00
Neal Norwitz 52ca0dd712 Fix icc warnings: using wrong enum type 2006-01-07 21:21:16 +00:00
Neal Norwitz f0459142d5 Fix icc warnings: extra semi-colon and signed vs unsigned 2006-01-07 21:20:24 +00:00
Neal Norwitz 3f0464839b Fix icc warnings: extra semi-colon 2006-01-07 21:19:49 +00:00
Tim Peters a9652f11ad Py_GetBuildInfo(): Squash compiler warnings.
Locals `revision` and `branch` were const-incorrect.
2006-01-06 02:45:17 +00:00
Martin v. Löwis 456af5f78b Deal with empty svn_revisions. 2006-01-06 00:43:42 +00:00
Martin v. Löwis 43b57805fb Drop sys.build_number. Add sys.subversion. 2006-01-05 23:38:54 +00:00
Skip Montanaro 2b47445234 squash compiler warning on Mac OSX 10.3 2006-01-05 10:49:13 +00:00
Martin v. Löwis c5bf5a00a3 Always set SVNVERSION to "exported" if it otherwise fails. 2006-01-05 10:33:59 +00:00
Martin v. Löwis dea59e5755 Stop maintaining the buildno file.
Also, stop determining Unicode sizes with PyString_GET_SIZE.
2006-01-05 10:00:36 +00:00
Neal Norwitz 40c6b47ca1 Fix errors on 64-bit platforms. Will backport 2006-01-05 05:43:35 +00:00
Martin v. Löwis 70cef449ca Remove unneeded directories. 2006-01-03 06:48:38 +00:00
Martin v. Löwis d372aa8e37 Import zlib into Python tree. 2006-01-03 06:44:59 +00:00
Armin Rigo f5bd3b442d adding in-place operators to the operator module. 2005-12-29 16:50:42 +00:00
Armin Rigo c4308d5be6 two missing PyDoc_STR(). 2005-12-29 14:39:28 +00:00
Georg Brandl cd4d1e8b46 [ 959576 ] Can't build Python on POSIX w/o $HOME 2005-12-27 17:37:07 +00:00
Fredrik Lundh c3389997d4 SF#1389809
cast first PyUnicode_Decode argument to proper type (why is
"char *" used for encoded byte streams, btw?  shouldn't that
be "void *" or, if necessary, "unsigned char *"?)
2005-12-25 11:40:19 +00:00
Barry Warsaw ce3a9131c3 Revert most of r41765. Don't use $Revision$ in Py_GetBuildNumber(). Keep the
use of $(srcdir) in Makefile.pre.in so builds outside the source dir still
work.
2005-12-19 14:43:44 +00:00
Neal Norwitz 9dbc7dd6f2 Remove extra parens 2005-12-19 06:08:59 +00:00
Neal Norwitz 30b5c5d011 Fix SF bug #1072182, problems with signed characters.
Most of these can be backported.
2005-12-19 06:05:18 +00:00
Barry Warsaw a3bdc2c2a5 Handle a couple of use cases discussed in python-dev w.r.t. calculating the
Subversion revision number.

First, in an svn export, there will be no .svn directory, so use an in-file
$Revision$ keyword string with the keyword chrome stripped off.

Also, use $(srcdir) in the Makefile.pre.in to handle the case where Python is
build outside the source tree.
2005-12-18 22:46:35 +00:00