Benjamin Peterson
7d8a2e41a0
allow any number to be returned from __length_hint__ ( closes #15354 )
2012-07-14 17:53:55 -07:00
Raymond Hettinger
7d1483cbad
Make an error message more understandable and consistent with other error messages.
2011-11-20 10:38:53 -08:00
Mark Dickinson
cb61e5d9b5
Issue #9869 : Make long() and PyNumber_Long return something of type
...
long for a class whose __long__ method returns a plain int. This
fixes an interpreter crash (due to long_subtype_new assuming
PyNumber_Long returns a long) when initializing an instance of a long
subclass from an object whose __long__ method returns a plain int.
2010-09-26 10:37:12 +00:00
Antoine Pitrou
1fcdba84be
Merged revisions 84391 via svnmerge from
...
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r84391 | antoine.pitrou | 2010-09-01 14:58:21 +0200 (mer., 01 sept. 2010) | 5 lines
Issue #3101 : Helper functions _add_one_to_C() and _add_one_to_F() become
_Py_add_one_to_C() and _Py_add_one_to_F(), respectively.
........
2010-09-01 13:02:50 +00:00
Benjamin Peterson
d5adb5d73d
_PyObject_LookupSpecial returns a new reference
2010-06-05 02:07:01 +00:00
Benjamin Peterson
3a2acb5040
remove PyType_Ready call; float should be initialized in interpreter startup
2010-06-05 00:38:22 +00:00
Benjamin Peterson
2aa6c38237
properly lookup the __format__ special method
2010-06-05 00:32:50 +00:00
Antoine Pitrou
c83ea137d7
Untabify C files. Will watch buildbots.
2010-05-09 14:46:46 +00:00
Brett Cannon
0d8a859a85
Pull a NULL pointer check up to cover more cases in the function.
...
Found using Clang's static analyzer.
2010-05-04 01:23:36 +00:00
Eric Smith
d44b2fc87c
Issue 7994: Make object.__format__ with a non-empty format string a PendingDecprecationWarning. Still need to remove uses of this from various tests.
2010-04-02 12:30:56 +00:00
Benjamin Peterson
5fb877027b
substitute PyDict_Check() for PyObject_IsInstance
2009-12-10 03:37:59 +00:00
Benjamin Peterson
87e5006d8c
handle errors from _PyObject_LookupSpecial when __get__ fails
2009-05-25 02:40:21 +00:00
Benjamin Peterson
a27dbc68f0
completely ignore old-style stuff for type checking overloading
2009-05-16 22:40:56 +00:00
Benjamin Peterson
94eaba78b7
deal with old-style classes in issubclass and isinstance
2009-05-16 22:30:48 +00:00
Benjamin Peterson
fb6fb062e8
properly lookup __instancecheck__ and __subclasscheck__
2009-05-16 21:44:25 +00:00
Benjamin Peterson
ceea163e7c
clear error state properly
2009-05-09 19:18:36 +00:00
Benjamin Peterson
a7dc949e17
ignore AttributeErrors for classic classes
2009-05-09 19:03:05 +00:00
Benjamin Peterson
3f3d36bd03
ignore classic classes
2009-05-09 16:51:51 +00:00
Benjamin Peterson
af1692a266
convert some more special methods to use _PyObject_LookupSpecial
2009-05-09 16:36:39 +00:00
Georg Brandl
f5fd523981
"not subscriptable" should be a bit more understandable than "unsubscriptable".
2009-04-18 08:26:21 +00:00
Antoine Pitrou
789be0c0a0
Issue #2396 : backport the memoryview object.
2009-04-02 21:18:34 +00:00
Mark Dickinson
3e4caeb3bf
Issue #5341 : Fix a variety of spelling errors.
2009-02-21 20:27:01 +00:00
Mark Dickinson
b91d2f5bd3
Remove redundant assignment in _PyObject_LengthHint
2009-02-08 13:58:10 +00:00
Raymond Hettinger
d6fc2623c5
Validate that __length_hint__ returns a usable result.
2009-02-03 02:23:19 +00:00
Raymond Hettinger
b516370bcb
Issue 1242657: list(obj) can swallow KeyboardInterrupt.
2009-02-02 21:50:13 +00:00
Hirokazu Yamamoto
1e234e8c19
Fixed compile error on windows.
2009-01-25 17:46:48 +00:00
Benjamin Peterson
78821ddf8c
fix building the core with --disable-unicode
...
I changed some bytearray methods to use strings instead of unicode like bytes_repr
Also, bytearray.fromhex() can take strings as well as unicode
2009-01-25 17:15:10 +00:00
Amaury Forgeot d'Arc
a40d573664
#3720 : Interpreter crashes when an evil iterator removes its own next function.
...
Now the slot is filled with a function that always raises.
Will not backport: extensions compiled with 2.6.x would not run on 2.6.0.
2009-01-12 23:36:55 +00:00
Antoine Pitrou
0668c62677
Issue #2534 : speed up isinstance() and issubclass() by 50-70%, so as to
...
match Python 2.5 speed despite the __instancecheck__ / __subclasscheck__
mechanism. In the process, fix a bug where isinstance() and issubclass(),
when given a tuple of classes as second argument, were looking up
__instancecheck__ / __subclasscheck__ on the tuple rather than on each
type object.
Reviewed by Benjamin Peterson and Raymond Hettinger.
2008-08-26 22:42:08 +00:00
Martin v. Löwis
64034f994c
Fix memory leak: Always DECREF obj in PyBuffer_Release.
2008-08-14 20:12:06 +00:00
Martin v. Löwis
241b8345ea
Make obj an owned reference in Py_buffer; this checkin
...
was missing from the patch for #3139 .
2008-08-14 15:54:27 +00:00
Martin v. Löwis
f91d46a17d
Issue #3139 : Make buffer-interface thread-safe wrt. PyArg_ParseTuple,
...
by denying s# to parse objects that have a releasebuffer procedure,
and introducing s*.
More module might need to get converted to use s*.
2008-08-12 14:49:50 +00:00
Skip Montanaro
2c7ca9bb11
Correct grammar.
2008-07-07 11:16:14 +00:00
Gregory P. Smith
dd96db63f6
This reverts r63675 based on the discussion in this thread:
...
http://mail.python.org/pipermail/python-dev/2008-June/079988.html
Python 2.6 should stick with PyString_* in its codebase. The PyBytes_* names
in the spirit of 3.0 are available via a #define only. See the email thread.
2008-06-09 04:58:54 +00:00
Travis E. Oliphant
0144f27602
Remove locking part of new buffer protocol.
2008-06-06 22:39:47 +00:00
Christian Heimes
593daf545b
Renamed PyString to PyBytes
2008-05-26 12:51:38 +00:00
Neal Norwitz
fddc469876
Prevent namespace pollution, add static for internal functions
2008-04-15 03:46:21 +00:00
Raymond Hettinger
c71d2a9afd
Remove unnecessary traceback save/restore pair.
2008-03-19 22:47:48 +00:00
Raymond Hettinger
de48d8406f
Fix compiler warning.
2008-03-19 03:56:59 +00:00
Raymond Hettinger
9a47e6201f
Speed-up isinstance() for one easy case.
2008-03-18 23:22:29 +00:00
Travis E. Oliphant
3781aef8f8
Finish backporting new buffer API to Python 2.6. Left to do: memoryview object and structmodule. But, these need to be finished in Python 3.0 first. No objects support the new buffer API in Python 2.6 as of yet, and except for the memoryview object, I don't think they will.
2008-03-18 04:44:57 +00:00
Eric Smith
a9f7d62480
Backport of PEP 3101, Advanced String Formatting, from py3k.
...
Highlights:
- Adding PyObject_Format.
- Adding string.Format class.
- Adding __format__ for str, unicode, int, long, float, datetime.
- Adding builtin format.
- Adding ''.format and u''.format.
- str/unicode fixups for formatters.
The files in Objects/stringlib that implement PEP 3101 (stringdefs.h,
unicodedefs.h, formatter.h, string_format.h) are identical in trunk
and py3k. Any changes from here on should be made to trunk, and
changes will propogate to py3k).
2008-02-17 19:46:49 +00:00
Eric Smith
3f91437e5f
In PyNumber_ToBase, changed from an assert to returning an error when PyObject_Index() returns something other than an int or long. It should never be possible to trigger this, as PyObject_Index checks to make sure it returns an int or long.
2008-02-15 12:14:32 +00:00
Christian Heimes
e247f0037f
Use a static and interned string for __subclasscheck__ and __instancecheck__ as suggested by Thomas Heller in #2115
2008-02-14 22:40:11 +00:00
Eric Smith
5e527ebee1
Added PyNumber_ToBase and supporting routines _PyInt_Format and
...
_PyLong_Format. In longobject.c, changed long_format to
_PyLong_Format. In intobject.c, changed uses of PyOS_snprintf to
_PyInt_Format instead.
_PyLong_Format is similar to py3k's routine of the same name, except
it has 2 additional parameters: addL and newstyle. addL was existing
in long_format, and controls adding the trailing "L". This is
unneeded in py3k. newstyle is used to control whether octal prepends
"0" (the pre-2.6 style), or "0o" (the 3.0 sytle).
PyNumber_ToBase is needed for PEP 3127 (Integer Literal Support and
Syntax) and PEP 3101 (Advanced String Formatting).
This changeset does not need merging into py3k.
2008-02-10 01:36:53 +00:00
Jeffrey Yasskin
a26cf9b760
Make int() and long() fall back to __trunc__(). See issue 2002.
2008-02-04 01:04:35 +00:00
Christian Heimes
d7e1b2bd17
static PyObject* variables should use PyString_InternFromString() instead of PyObject_FromString() to store a python string in a function level static var.
2008-01-28 02:07:53 +00:00
Raymond Hettinger
4e2f714031
Fix Issue 1045.
...
Factor-out common calling code by simplifying the length_hint API.
Speed-up the function by caching the PyObject_String for the attribute lookup.
2007-12-06 00:56:53 +00:00
Christian Heimes
fe4826f6ac
merge -r59315:59316 from py3k: Fix issue #1553 : An errornous __length_hint__ can make list() raise a SystemError
2007-12-05 12:49:14 +00:00
Thomas Wouters
bbaff4c7e8
Properly indent two lines. (Spotted because it caused merge conflicts in the
...
py3k branch ;)
2007-09-18 23:27:30 +00:00