Skip to content

Commit 49e8699

Browse files
author
Ralf W. Grosse-Kunstleve
committed
merging current boost/python and libs/python from trunk into release branch
[SVN r74931]
1 parent cfa2baf commit 49e8699

10 files changed

Lines changed: 44 additions & 33 deletions

File tree

doc/v2/slice.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ <h4><a name="slice-spec-synopsis"></a>Class <code>slice</code> synopsis</h4>
8585
object stop();
8686
object step();
8787

88-
// The return type of slice::get_indicies()
88+
// The return type of slice::get_indices()
8989
template &lt;typename RandomAccessIterator&gt;
9090
struct range
9191
{
@@ -96,7 +96,7 @@ <h4><a name="slice-spec-synopsis"></a>Class <code>slice</code> synopsis</h4>
9696

9797
template &lt;typename RandomAccessIterator&gt;
9898
range&lt;RandomAccessIterator&gt;
99-
get_indicies(
99+
get_indices(
100100
RandomAccessIterator const&amp; begin,
101101
RandomAccessIterator const&amp; end);
102102
};
@@ -164,7 +164,7 @@ <h4><a name="slice-spec-observers"></a>Class <code>slice</code>
164164
<pre>
165165
template &lt;typename RandomAccessIterator&gt;
166166
slice::range&lt;RandomAccessIterator&gt;
167-
slice::get_indicies(
167+
slice::get_indices(
168168
RandomAccessIterator const&amp; begin,
169169
RandomAccessIterator const&amp; end) const;
170170
</pre>
@@ -173,16 +173,16 @@ <h4><a name="slice-spec-observers"></a>Class <code>slice</code>
173173
Iterators that form a half-open range.</dt>
174174
<dt><b>Effects:</b> Create a RandomAccessIterator pair that defines a
175175
fully-closed range within the [begin,end) range of its arguments.&nbsp;
176-
This function translates this slice's indicies while accounting for the
177-
effects of any PyNone or negative indicies, and non-singular step sizes.</dt>
176+
This function translates this slice's indices while accounting for the
177+
effects of any PyNone or negative indices, and non-singular step sizes.</dt>
178178
<dt><b>Returns:</b> a slice::range
179179
that has been initialized with a non-zero value of step and a pair of
180180
RandomAccessIterators that point within the range of this functions
181181
arguments and define a closed interval.</dt>
182182
<dt><b>Throws:</b> <a href="definitions.html#raise">Raises</a> a Python <code>TypeError</code> exception if any of this slice's arguments
183183
are neither references to <code>PyNone</code> nor convertible to <code>int</code>.&nbsp; Throws
184184
<code>std::invalid_argument</code> if the resulting range would be empty.&nbsp; You
185-
should always wrap calls to <code>slice::get_indicies()</code>
185+
should always wrap calls to <code>slice::get_indices()</code>
186186
within <code>try { ...; } catch (std::invalid_argument) {}</code> to
187187
handle this case and take appropriate action.</dt>
188188
<dt><b>Rationale</b>: closed-interval: If
@@ -221,7 +221,7 @@ <h2><a name="examples"></a><b>Examples</b></h2>
221221
{
222222
slice::range&lt;std::vector&lt;double&gt;::const_iterator&gt; bounds;
223223
try {
224-
bounds = index.get_indicies&lt;&gt;(Foo.begin(), Foo.end());
224+
bounds = index.get_indices&lt;&gt;(Foo.begin(), Foo.end());
225225
}
226226
catch (std::invalid_argument) {
227227
return 0.0;

doc/v2/with_custodian_and_ward.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ <h2>
9191
<hr>
9292
<h2>
9393
<a name="introduction">Introduction</a>
94-
</h2>This header provides faciliites for establishing a lifetime
94+
</h2>This header provides facilities for establishing a lifetime
9595
dependency between two of a function's Python argument or result objects.
9696
The <i>ward</i> object will not be destroyed until after the custodian as
9797
long as the <i>custodian</i> object supports <a href=

include/boost/python/class.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ namespace detail
138138
static void
139139
must_be_derived_class_member(Default const&)
140140
{
141-
typedef typename assertion<mpl::not_<is_same<Default,Fn> > >::failed test0;
141+
// https://svn.boost.org/trac/boost/ticket/5803
142+
//typedef typename assertion<mpl::not_<is_same<Default,Fn> > >::failed test0;
142143
# if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
143144
typedef typename assertion<is_polymorphic<T> >::failed test1;
144145
# endif

include/boost/python/detail/make_keyword_range_fn.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ object make_keyword_range_constructor(
5757
, Holder* = 0
5858
, ArgList* = 0, Arity* = 0)
5959
{
60-
#if !defined( BOOST_PYTHON_NO_PY_SIGNATURES) && defined( BOOST_PYTHON_PY_SYGNATURES_PROPER_INIT_SELF_TYPE)
60+
#if !defined( BOOST_PYTHON_NO_PY_SIGNATURES) && defined( BOOST_PYTHON_PY_SIGNATURES_PROPER_INIT_SELF_TYPE)
6161
python_class<BOOST_DEDUCED_TYPENAME Holder::value_type>::register_();
6262
#endif
6363
return detail::make_keyword_range_function(

include/boost/python/object/class_metadata.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ struct class_metadata
238238
//
239239
inline static void maybe_register_pointer_to_python(...) {}
240240

241-
#ifndef BOOST_PYTHON_NO_PY_SYGNATURES
241+
#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
242242
inline static void maybe_register_pointer_to_python(void*,void*,mpl::true_*)
243243
{
244244
objects::copy_class_object(python::type_id<T>(), python::type_id<back_reference<T const &> >());
@@ -255,7 +255,7 @@ struct class_metadata
255255
, make_ptr_instance<T2, pointer_holder<held_type, T2> >
256256
>()
257257
);
258-
#ifndef BOOST_PYTHON_NO_PY_SYGNATURES
258+
#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
259259
// explicit qualification of type_id makes msvc6 happy
260260
objects::copy_class_object(python::type_id<T2>(), python::type_id<held_type>());
261261
#endif
@@ -270,7 +270,7 @@ struct class_metadata
270270
inline static void maybe_register_class_to_python(T2*, mpl::false_)
271271
{
272272
python::detail::force_instantiate(class_cref_wrapper<T2, make_instance<T2, holder> >());
273-
#ifndef BOOST_PYTHON_NO_PY_SYGNATURES
273+
#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
274274
// explicit qualification of type_id makes msvc6 happy
275275
objects::copy_class_object(python::type_id<T2>(), python::type_id<held_type>());
276276
#endif

include/boost/python/object/make_holder.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
# include <boost/python/object/instance.hpp>
1414
# include <boost/python/converter/registry.hpp>
15-
#if !defined( BOOST_PYTHON_NO_PY_SIGNATURES) && defined( BOOST_PYTHON_PY_SYGNATURES_PROPER_INIT_SELF_TYPE)
15+
#if !defined( BOOST_PYTHON_NO_PY_SIGNATURES) && defined( BOOST_PYTHON_PY_SIGNATURES_PROPER_INIT_SELF_TYPE)
1616
# include <boost/python/detail/python_type.hpp>
1717
#endif
1818

@@ -81,7 +81,7 @@ struct make_holder<N>
8181
# endif
8282

8383
static void execute(
84-
#if !defined( BOOST_PYTHON_NO_PY_SIGNATURES) && defined( BOOST_PYTHON_PY_SYGNATURES_PROPER_INIT_SELF_TYPE)
84+
#if !defined( BOOST_PYTHON_NO_PY_SIGNATURES) && defined( BOOST_PYTHON_PY_SIGNATURES_PROPER_INIT_SELF_TYPE)
8585
boost::python::detail::python_class<BOOST_DEDUCED_TYPENAME Holder::value_type> *p
8686
#else
8787
PyObject *p

include/boost/python/slice.hpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace detail
3030
// that created this slice, than that parameter is None here, and compares
3131
// equal to a default-constructed boost::python::object.
3232
// If a user-defined type wishes to support slicing, then support for the
33-
// special meaning associated with negative indicies is up to the user.
33+
// special meaning associated with negative indices is up to the user.
3434
object start() const;
3535
object stop() const;
3636
object step() const;
@@ -63,7 +63,7 @@ class slice : public detail::slice_base
6363

6464
// The following algorithm is intended to automate the process of
6565
// determining a slice range when you want to fully support negative
66-
// indicies and non-singular step sizes. Its functionallity is simmilar to
66+
// indices and non-singular step sizes. Its functionallity is simmilar to
6767
// PySlice_GetIndicesEx() in the Python/C API, but tailored for C++ users.
6868
// This template returns a slice::range struct that, when used in the
6969
// following iterative loop, will traverse a slice of the function's
@@ -110,7 +110,7 @@ class slice : public detail::slice_base
110110

111111
template<typename RandomAccessIterator>
112112
slice::range<RandomAccessIterator>
113-
get_indicies( const RandomAccessIterator& begin,
113+
get_indices( const RandomAccessIterator& begin,
114114
const RandomAccessIterator& end) const
115115
{
116116
// This is based loosely on PySlice_GetIndicesEx(), but it has been
@@ -240,6 +240,16 @@ class slice : public detail::slice_base
240240

241241
return ret;
242242
}
243+
244+
// Incorrect spelling. DO NOT USE. Only here for backward compatibility.
245+
// Corrected 2011-06-14.
246+
template<typename RandomAccessIterator>
247+
slice::range<RandomAccessIterator>
248+
get_indicies( const RandomAccessIterator& begin,
249+
const RandomAccessIterator& end) const
250+
{
251+
get_indices(begin, end);
252+
}
243253

244254
public:
245255
// This declaration, in conjunction with the specialization of

src/object/function.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -433,23 +433,23 @@ void function::add_to_namespace(
433433
if (attribute.ptr()->ob_type == &function_type)
434434
{
435435
function* new_func = downcast<function>(attribute.ptr());
436-
PyObject* dict = 0;
436+
handle<> dict;
437437

438438
#if PY_VERSION_HEX < 0x03000000
439439
// Old-style class gone in Python 3
440440
if (PyClass_Check(ns))
441-
dict = ((PyClassObject*)ns)->cl_dict;
441+
dict = handle<>(borrowed(((PyClassObject*)ns)->cl_dict));
442442
else
443443
#endif
444444
if (PyType_Check(ns))
445-
dict = ((PyTypeObject*)ns)->tp_dict;
445+
dict = handle<>(borrowed(((PyTypeObject*)ns)->tp_dict));
446446
else
447-
dict = PyObject_GetAttrString(ns, const_cast<char*>("__dict__"));
447+
dict = handle<>(PyObject_GetAttrString(ns, const_cast<char*>("__dict__")));
448448

449449
if (dict == 0)
450450
throw_error_already_set();
451451

452-
handle<> existing(allow_null(::PyObject_GetItem(dict, name.ptr())));
452+
handle<> existing(allow_null(::PyObject_GetItem(dict.get(), name.ptr())));
453453

454454
if (existing)
455455
{

test/slice.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ bool accept_slice( slice) { return true; }
9898

9999
#if BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1400)) \
100100
|| BOOST_WORKAROUND( BOOST_INTEL_WIN, == 710)
101-
int check_slice_get_indicies(slice index);
101+
int check_slice_get_indices(slice index);
102102
#endif
103-
int check_slice_get_indicies(
103+
int check_slice_get_indices(
104104
#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590))
105105
const
106106
#endif
@@ -116,7 +116,7 @@ int check_slice_get_indicies(
116116

117117
slice::range<std::vector<int>::iterator> bounds;
118118
try {
119-
bounds = index.get_indicies(coll.begin(), coll.end());
119+
bounds = index.get_indices(coll.begin(), coll.end());
120120
}
121121
catch (std::invalid_argument) {
122122
return 0;
@@ -136,5 +136,5 @@ BOOST_PYTHON_MODULE(slice_ext)
136136
def( "accept_slice", accept_slice);
137137
def( "check_numeric_array_rich_slice", check_numeric_array_rich_slice);
138138
def( "check_string_rich_slice", check_string_rich_slice);
139-
def( "check_slice_get_indicies", check_slice_get_indicies);
139+
def( "check_slice_get_indices", check_slice_get_indices);
140140
}

test/slice.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@
3737
... print 1
3838
...
3939
1
40-
>>> check_slice_get_indicies( slice(None))
40+
>>> check_slice_get_indices( slice(None))
4141
0
42-
>>> check_slice_get_indicies( slice(2,-2))
42+
>>> check_slice_get_indices( slice(2,-2))
4343
0
44-
>>> check_slice_get_indicies( slice(2, None, 2))
44+
>>> check_slice_get_indices( slice(2, None, 2))
4545
5
46-
>>> check_slice_get_indicies( slice(2, None, -1))
46+
>>> check_slice_get_indices( slice(2, None, -1))
4747
-12
48-
>>> check_slice_get_indicies( slice( 20, None))
48+
>>> check_slice_get_indices( slice( 20, None))
4949
0
50-
>>> check_slice_get_indicies( slice( -2, -5, -2))
50+
>>> check_slice_get_indices( slice( -2, -5, -2))
5151
6
5252
"""
5353

0 commit comments

Comments
 (0)