2007-08-15 11:28:22 -03:00
|
|
|
.. highlightlang:: c
|
|
|
|
|
|
|
|
|
|
|
|
.. _concrete:
|
|
|
|
|
|
|
|
**********************
|
|
|
|
Concrete Objects Layer
|
|
|
|
**********************
|
|
|
|
|
|
|
|
The functions in this chapter are specific to certain Python object types.
|
|
|
|
Passing them an object of the wrong type is not a good idea; if you receive an
|
|
|
|
object from a Python program and you are not sure that it has the right type,
|
|
|
|
you must perform a type check first; for example, to check that an object is a
|
|
|
|
dictionary, use :cfunc:`PyDict_Check`. The chapter is structured like the
|
|
|
|
"family tree" of Python object types.
|
|
|
|
|
|
|
|
.. warning::
|
|
|
|
|
|
|
|
While the functions described in this chapter carefully check the type of the
|
|
|
|
objects which are passed in, many of them do not check for *NULL* being passed
|
|
|
|
instead of a valid object. Allowing *NULL* to be passed in can cause memory
|
|
|
|
access violations and immediate termination of the interpreter.
|
|
|
|
|
|
|
|
|
|
|
|
.. _fundamental:
|
|
|
|
|
|
|
|
Fundamental Objects
|
|
|
|
===================
|
|
|
|
|
|
|
|
This section describes Python type objects and the singleton object ``None``.
|
|
|
|
|
2008-01-20 05:30:57 -04:00
|
|
|
.. toctree::
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2008-01-20 05:30:57 -04:00
|
|
|
type.rst
|
|
|
|
none.rst
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
|
|
|
|
.. _numericobjects:
|
|
|
|
|
|
|
|
Numeric Objects
|
|
|
|
===============
|
|
|
|
|
|
|
|
.. index:: object: numeric
|
|
|
|
|
2008-01-20 05:30:57 -04:00
|
|
|
.. toctree::
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2008-01-20 05:30:57 -04:00
|
|
|
long.rst
|
|
|
|
bool.rst
|
|
|
|
float.rst
|
|
|
|
complex.rst
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
|
|
|
|
.. _sequenceobjects:
|
|
|
|
|
|
|
|
Sequence Objects
|
|
|
|
================
|
|
|
|
|
|
|
|
.. index:: object: sequence
|
|
|
|
|
|
|
|
Generic operations on sequence objects were discussed in the previous chapter;
|
|
|
|
this section deals with the specific kinds of sequence objects that are
|
|
|
|
intrinsic to the Python language.
|
|
|
|
|
2008-01-05 17:16:33 -04:00
|
|
|
.. XXX sort out unicode, str, bytes and bytearray
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2008-01-20 05:30:57 -04:00
|
|
|
.. toctree::
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2008-05-26 12:01:55 -03:00
|
|
|
bytes.rst
|
2008-05-26 13:04:49 -03:00
|
|
|
bytearray.rst
|
2008-01-20 05:30:57 -04:00
|
|
|
unicode.rst
|
|
|
|
buffer.rst
|
|
|
|
tuple.rst
|
|
|
|
list.rst
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
|
2008-01-20 05:30:57 -04:00
|
|
|
.. _mapobjects:
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2008-01-20 05:30:57 -04:00
|
|
|
Mapping Objects
|
|
|
|
===============
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2008-01-20 05:30:57 -04:00
|
|
|
.. index:: object: mapping
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2008-01-20 05:30:57 -04:00
|
|
|
.. toctree::
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2008-01-20 05:30:57 -04:00
|
|
|
dict.rst
|
2007-08-15 11:28:22 -03:00
|
|
|
|
|
|
|
|
2008-01-20 05:30:57 -04:00
|
|
|
.. _otherobjects:
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2008-01-20 05:30:57 -04:00
|
|
|
Other Objects
|
|
|
|
=============
|
2007-08-15 11:28:22 -03:00
|
|
|
|
2008-01-20 05:30:57 -04:00
|
|
|
.. toctree::
|
|
|
|
|
|
|
|
set.rst
|
|
|
|
function.rst
|
|
|
|
method.rst
|
|
|
|
file.rst
|
|
|
|
module.rst
|
|
|
|
iterator.rst
|
|
|
|
descriptor.rst
|
|
|
|
slice.rst
|
|
|
|
weakref.rst
|
2009-05-05 19:31:58 -03:00
|
|
|
capsule.rst
|
2008-01-20 05:30:57 -04:00
|
|
|
cell.rst
|
|
|
|
gen.rst
|
|
|
|
datetime.rst
|
Merged revisions 72487-72488,72879 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r72487 | jeffrey.yasskin | 2009-05-08 17:51:06 -0400 (Fri, 08 May 2009) | 7 lines
PyCode_NewEmpty:
Most uses of PyCode_New found by http://www.google.com/codesearch?q=PyCode_New
are trying to build an empty code object, usually to put it in a dummy frame
object. This patch adds a PyCode_NewEmpty wrapper which lets the user specify
just the filename, function name, and first line number, instead of also
requiring lots of code internals.
........
r72488 | jeffrey.yasskin | 2009-05-08 18:23:21 -0400 (Fri, 08 May 2009) | 13 lines
Issue 5954, PyFrame_GetLineNumber:
Most uses of PyCode_Addr2Line
(http://www.google.com/codesearch?q=PyCode_Addr2Line) are just trying to get
the line number of a specified frame, but there's no way to do that directly.
Forcing people to go through the code object makes them know more about the
guts of the interpreter than they should need.
The remaining uses of PyCode_Addr2Line seem to be getting the line from a
traceback (for example,
http://www.google.com/codesearch/p?hl=en#u_9_nDrchrw/pygame-1.7.1release/src/base.c&q=PyCode_Addr2Line),
which is replaced by the tb_lineno field. So we may be able to deprecate
PyCode_Addr2Line entirely for external use.
........
r72879 | jeffrey.yasskin | 2009-05-23 19:23:01 -0400 (Sat, 23 May 2009) | 14 lines
Issue #6042:
lnotab-based tracing is very complicated and isn't documented very well. There
were at least 3 comment blocks purporting to document co_lnotab, and none did a
very good job. This patch unifies them into Objects/lnotab_notes.txt which
tries to completely capture the current state of affairs.
I also discovered that we've attached 2 layers of patches to the basic tracing
scheme. The first layer avoids jumping to instructions that don't start a line,
to avoid problems in if statements and while loops. The second layer
discovered that jumps backward do need to trace at instructions that don't
start a line, so it added extra lnotab entries for 'while' and 'for' loops, and
added a special case for backward jumps within the same line. I replaced these
patches by just treating forward and backward jumps differently.
........
2009-07-21 01:30:03 -03:00
|
|
|
code.rst
|