Commit Graph

2362 Commits

Author SHA1 Message Date
Martin v. Löwis dde99d2633 Remove size constraints in SLICE opcodes. 2006-02-17 15:57:41 +00:00
Thomas Wouters 02cbdd3461 Use proper PyArg_Parse format char for Py_ssize_t, instead of 'l', in
buffer_new(). Probably fixes a bug in 'buffer("", 10, 10)' on platforms
where sizeof(Py_ssize_t) != sizeof(long) (Win64?)
2006-02-16 19:44:46 +00:00
Thomas Wouters de01774dae Use correct PyArg_Parse format char for Py_ssize_t in unicode.center().
Fixes:

>>> u"".center(10)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
MemoryError

on 64-bit systems.
2006-02-16 19:34:37 +00:00
Thomas Wouters 977485d888 Use Py_ssize_t in helper function between Py_ssize_t-using functions. 2006-02-16 15:59:12 +00:00
Martin v. Löwis eb079f1c25 Use Py_ssize_t for counts and sizes.
Convert Py_ssize_t using PyInt_FromSsize_t
2006-02-16 14:32:27 +00:00
Neal Norwitz 82c5a86d7c Oops, this is supposed to be disabled by default. 2006-02-16 07:30:11 +00:00
Martin v. Löwis e0e89f7920 Revert 42400. 2006-02-16 06:59:22 +00:00
Martin v. Löwis 2c95cc6d72 Support %zd in PyErr_Format and PyString_FromFormat. 2006-02-16 06:54:25 +00:00
Neal Norwitz 26efe402c2 Get rid of compiler warnings (gcc 3.3.4 on x86) 2006-02-16 06:21:57 +00:00
Tim Peters 15231548d2 doubletounicode(), longtounicode():
Py_SAFE_DOWNCAST can evaluate its first argument multiple
times in a debug build.  This caused two distinct assert-
failures in test_unicode run under a debug build.  Rewrote
the code in trivial ways so that multiple evaluation of the
first argument doesn't hurt.
2006-02-16 01:08:01 +00:00
Thomas Wouters 4701af5bf5 Remove two unused Py_ssize_t variables (merge glitches, looks like.) 2006-02-15 23:10:32 +00:00
Thomas Wouters b1410fb433 Avoid unused variables when SIZEOF_SIZE_T == SIZEOF_LONG. Also normalize
whitespace.
2006-02-15 23:08:56 +00:00
Martin v. Löwis 18e165558b Merge ssize_t branch. 2006-02-15 17:27:45 +00:00
Armin Rigo 967aa8b349 * Refcount leak. It was just a reference to Py_None, but still.
* Allow the 3rd argument to generator.throw() to be None.
  The 'raise' statement does the same, and anyway it follows the
  general policy that optional arguments of built-ins should, when
  reasonable, have a default value specifiable from Python.
2006-02-14 15:50:44 +00:00
Thomas Wouters c45251a485 SF patch #1397960: When mixing file-iteration and
readline/readlines/read/readinto, loudly break by raising ValueError, rather
than silently deliver data out of order or hitting EOF prematurely.

Probably not a bugfix candidate, even though it affects no 'working' code.
2006-02-12 11:53:32 +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
Thomas Wouters 553489ab1d As discussed on python-dev, silence three gcc-4.0.x warnings, using assert()
to protect against actual uninitialized usage.

Objects/longobject.c: In function ‘PyLong_AsDouble’:
Objects/longobject.c:655: warning: ‘e’ may be used uninitialized in this function

Objects/longobject.c: In function ‘long_true_divide’:
Objects/longobject.c:2263: warning: ‘aexp’ may be used uninitialized in this function
Objects/longobject.c:2263: warning: ‘bexp’ may be used uninitialized in this function
2006-02-01 21:32:04 +00:00
Neal Norwitz bab05c9604 Fix SF #1412837, compile failed with Watcom compiler 2006-01-24 06:06:11 +00:00
Neal Norwitz fc76d633e8 - Patch #1400181, fix unicode string formatting to not use the locale.
This is how string objects work.  u'%f' could use , instead of .
  for the decimal point.  Now both strings and unicode always use periods.

This is the code that would break:

import locale
locale.setlocale(locale.LC_NUMERIC, 'de_DE')
u'%.1f' % 1.0
assert '1.0' == u'%.1f' % 1.0

I couldn't create a test case which fails, but this fixes the problem.

Will backport.
2006-01-10 06:03:13 +00:00
Neal Norwitz 0c6e2f1640 Remove some shadowed variables 2006-01-08 06:13:44 +00:00
Neal Norwitz 76dc081dd9 strlen() returns a size_t, get rid of 64-bit warning 2006-01-08 06:13:13 +00:00
Neal Norwitz d43069ce95 Fix icc warnings: remove (sometimes) unused variable conditionally 2006-01-08 01:12:10 +00:00
Neal Norwitz b2da01b27c Fix icc warnings: remove unused variable 2006-01-08 01:11:25 +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 50bf51a3a9 Fix ref/memory leak introduced in rev 41845. 2006-01-02 02:46:54 +00:00
Tim Peters 60b29961dc Fixed English in a comment; trimmed trailing whitespace;
no code changes.
2006-01-01 01:19:23 +00:00
Armin Rigo 037d1e0ff3 SF bug #1153075: "PyXxx_Check(x) trusts x->ob_type->tp_mro".
A patch by mwh to check that user-defined mro's are reasonable
enough.
2005-12-29 17:07:39 +00:00
Armin Rigo fd163f92ce SF patch #1390657:
* set sq_repeat and sq_concat to NULL for user-defined new-style
  classes, as a way to fix a number of related problems.  See
  test_descr.notimplemented()).  One of these problems was fixed
  in r25556 and r25557 but many more existed; this is a general
  fix and thus reverts r25556-r25557.

* to avoid having PySequence_Repeat()/PySequence_Concat() failing
  on user-defined classes, they now fall back to nb_add/nb_mul if
  sq_concat/sq_repeat are not defined and the arguments appear to
  be sequences.

* added tests.

Backport candidate.
2005-12-29 15:59:19 +00:00
Neal Norwitz 7c460740ed Check return result for error 2005-12-18 08:02:38 +00:00
Hye-Shik Chang 835b243c71 Bug #1379994: Fix *unicode_escape codecs to encode r'\' as r'\\'
just like string codecs.
2005-12-17 04:38:31 +00:00
Neal Norwitz a716eabca7 Revert r41662 and the part of 41552 that originally caused the problem
(calling ftell(stdin) doesn't seem defined).  So we won't test errors
from ftell unless we can do it portably.
2005-12-15 05:25:09 +00:00
Hye-Shik Chang e237d50390 Add a workaround for file.ftell() to raise IOError for ttys.
ftell(3) on BSD doesn't set errno even for ttys and returns useless
values.
2005-12-13 16:44:02 +00:00
Neal Norwitz ba2fa637d6 en_sit will be freed when en is DECREF'd. Don't double free. 2005-12-11 20:55:10 +00:00
Jeremy Hylton af68c874a6 Add const to several API functions that take char *.
In C++, it's an error to pass a string literal to a char* function
without a const_cast().  Rather than require every C++ extension
module to put a cast around string literals, fix the API to state the
const-ness.

I focused on parts of the API where people usually pass literals:
PyArg_ParseTuple() and friends, Py_BuildValue(), PyMethodDef, the type
slots, etc.  Predictably, there were a large set of functions that
needed to be fixed as a result of these changes.  The most pervasive
change was to make the keyword args list passed to
PyArg_ParseTupleAndKewords() to be a const char *kwlist[].

One cast was required as a result of the changes:  A type object
mallocs the memory for its tp_doc slot and later frees it.
PyTypeObject says that tp_doc is const char *; but if the type was
created by type_new(), we know it is safe to cast to char *.
2005-12-10 18:50:16 +00:00
Michael W. Hudson b78a5fc004 Fix bug
[ 1346144 ] Segfaults from unaligned loads in floatobject.c

by using memcpy and not just blinding casting char* to double*.

Thanks to Rune Holm for the report.
2005-12-05 00:27:49 +00:00
Walter Dörwald d4fff1731c Fix leaked reference to None. 2005-11-28 22:15:56 +00:00
Neal Norwitz e5e5aa4ea6 Do a better job of not inlining Py_ADDRESS_IN_RANGE() for newer gcc's.
Perhaps Py_NO_INLINE should be moved to pyport.h or some other header?
2005-11-13 18:55:39 +00:00
Neal Norwitz 6576bd844f Prevent name pollution by making lots of internal functions static. 2005-11-13 18:41:28 +00:00
Armin Rigo c6686b7c7e Added proper reflection on instances of <type 'method-wrapper'>, e.g.
'[].__add__', to match what the other internal descriptor types provide:
'__objclass__' attribute, '__self__' member, and reasonable repr and
comparison.

Added a test.
2005-11-07 08:38:00 +00:00
Andrew M. Kuchling 8294de5673 Another comment typo fix 2005-11-02 16:36:12 +00:00
Walter Dörwald 2e2c02fedb Fix typo in comment. 2005-11-02 08:57:11 +00:00
Martin v. Löwis ab0f947a21 Remove .cvsignore files, as they live in svn:ignore
properties now.
2005-10-30 22:01:41 +00:00
Fred Drake db390c1ad8 fix typos, mostly in comments 2005-10-28 14:39:47 +00:00
Jeremy Hylton ec97a28b60 Fix a bunch of imports to use code.h instead of compile.h.
Remove duplicate declarations from compile.h
2005-10-21 14:58:06 +00:00
Michael W. Hudson b2308bb9be Fix bug:
[ 1327110 ] wrong TypeError traceback in generator expressions

by removing the code that can stomp on the users' TypeError raised by the
iterable argument to ''.join() -- PySequence_Fast (now?) gives a perfectly
reasonable message itself.  Also, a couple of tests.
2005-10-21 11:45:01 +00:00
Jeremy Hylton 3e0055f8c6 Merge ast-branch to head
This change implements a new bytecode compiler, based on a
transformation of the parse tree to an abstract syntax defined in
Parser/Python.asdl.

The compiler implementation is not complete, but it is in stable
enough shape to run the entire test suite excepting two disabled
tests.
2005-10-20 19:59:25 +00:00
Marc-André Lemburg 2cb94aba12 Enhance the performance of two important Unicode character
type lookups: whitespace and linebreak.

These lookup tables are from the Python 1.6 version with the addition
of the 205F code point which was added as whitespace code point to Unicode
since then.
2005-10-20 19:06:35 +00:00
Neal Norwitz 95c1e5065c SF bug #1331563 ] string_subscript doesn't check for failed PyMem_Malloc. Will backport 2005-10-20 04:15:52 +00:00
Marc-André Lemburg 5c4a9d6591 Whitespace corrections. 2005-10-19 22:39:02 +00:00
Marc-André Lemburg e115ec832c Bug fix for [ 1331062 ] utf 7 codec broken.
Backport candidate.
2005-10-19 22:33:31 +00:00