Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue7353] cporting docs recommend using Include/intobject.h, which was removed in 3.1?

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Nov 19, 2009, 6:49 AM

Post #1 of 7 (298 views)
Permalink
[issue7353] cporting docs recommend using Include/intobject.h, which was removed in 3.1?

R. David Murray <rdmurray [at] bitdance> added the comment:

You didn't. Doc bugs are automatically assigned to Georg by the tracker.

----------
nosy: +r.david.murray
priority: -> normal
stage: -> needs patch
title: Why was Include/intobject.h removed in 3.1? -> cporting docs recommend using Include/intobject.h, which was removed in 3.1?
type: -> behavior
versions: +Python 3.2

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7353>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 19, 2009, 6:50 AM

Post #2 of 7 (276 views)
Permalink
[issue7353] cporting docs recommend using Include/intobject.h, which was removed in 3.1? [In reply to]

Changes by R. David Murray <rdmurray [at] bitdance>:


----------
nosy: -r.david.murray

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7353>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 19, 2009, 3:03 PM

Post #3 of 7 (270 views)
Permalink
[issue7353] cporting docs recommend using Include/intobject.h, which was removed in 3.1? [In reply to]

Benjamin Peterson <benjamin [at] python> added the comment:

Hmm, I wish intobject.h hadn't been removed so soon. I'm not really sure
how a file of #defines could suffer bitrot. This point is probably moot,
though because there's little point in having its presence skip a
version. I suppose sticking it in Tools or even Doc/includes is the
second best option.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7353>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 20, 2009, 6:10 AM

Post #4 of 7 (266 views)
Permalink
[issue7353] cporting docs recommend using Include/intobject.h, which was removed in 3.1? [In reply to]

Mark Dickinson <dickinsm [at] gmail> added the comment:

[Benjamin]
>I wish intobject.h hadn't been removed so soon.

Yes; I'm sorry about that.

> I'm not really sure how a file of #defines could suffer bitrot.

Good point. Me neither.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7353>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 21, 2009, 9:04 AM

Post #5 of 7 (254 views)
Permalink
[issue7353] cporting docs recommend using Include/intobject.h, which was removed in 3.1? [In reply to]

Guido van Rossum <guido [at] python> added the comment:

I don't think it would hurt to put it back, would it? I think the "remove
this in 3.1" note was made when we expected 3.1 to be happening 1.5 years
after 3.0 rather than a few months.

----------
nosy: +gvanrossum

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7353>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 23, 2009, 4:24 AM

Post #6 of 7 (236 views)
Permalink
[issue7353] cporting docs recommend using Include/intobject.h, which was removed in 3.1? [In reply to]

Eric Smith <eric [at] trueblade> added the comment:

MvL made this comment in
http://www.mail-archive.com/python-dev [at] python/msg43844.html

I'm copying it here so it doesn't get lost and because I think he makes
a good point that many people would miss (at least I didn't think of it).
-----------------------------------------------

The macros (unfortunately) allowed
to make non-obvious mistakes. Now that they are gone, people need to
really think of what precisely they want to do.

For example, consider

if (PyInt_Check(o)){
long val = PyInt_AsLong(o);
// process
} else if (PyLong_Check(o)) {
long long val = PyLong_AsLongLong(o);
// check for overflow
// process
}

With intobject.h, this code would continue to compile, but work
incorrectly, as the second case will never be executed. It would
be better to port this as

#if Py2.x
if (PyInt_Check(o)){
long val = PyInt_AsLong(o);
// process
} else
#endif
if (PyLong_Check(o)) {

i.e. eliminating the int case altogether. For another example,

long foo = PyInt_AsLong(Foo);

has a hidden error in 3.x, with intobject: PyLong_AsLong might
overflow, which the 2.x case doesn't.

So eliminating intobject.h likely helps avoiding subtle errors.

Regards,
Martin

----------
nosy: +eric.smith

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7353>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 23, 2009, 4:52 AM

Post #7 of 7 (231 views)
Permalink
[issue7353] cporting docs recommend using Include/intobject.h, which was removed in 3.1? [In reply to]

Marc-Andre Lemburg <mal [at] egenix> added the comment:

Eric pointed me to this ticket after having raised the question on
python-dev: http://www.mail-archive.com/python-dev [at] python/msg43841.html

I think the discussion should be continued there instead of on this ticket.

Just for completeness, I'm copying my reply to Martin's reply here
(http://www.mail-archive.com/python-dev [at] python/msg43849.html):

"""
> For example, consider
>
> if (PyInt_Check(o)){
> long val = PyInt_AsLong(o);
> // process
> } else if (PyLong_Check(o)) {
> long long val = PyLong_AsLongLong(o);
> // check for overflow
> // process
> }
>
> With intobject.h, this code would continue to compile, but work
> incorrectly, as the second case will never be executed. It would
> be better to port this as
>
> #if Py2.x
> if (PyInt_Check(o)){
> long val = PyInt_AsLong(o);
> // process
> } else
> #endif
> if (PyLong_Check(o)) {
>
> i.e. eliminating the int case altogether.

Sure, but that assumes that the original code already had support
for Python longs, which a lot of code doesn't.

In an ideal world, developers would add that code to their
extensions right away. In the real world, where developers only
have limited resources available, you'll get more 3.x ports
by making such ports as painless as possible while at the
same time not forcing them to alienate their 2.x user base.

The long support could then be added in later releases
of the extensions, giving the developers more time adapt.

> For another example,
>
> long foo = PyInt_AsLong(Foo);
>
> has a hidden error in 3.x, with intobject: PyLong_AsLong might
> overflow, which the 2.x case doesn't.

That's not quite true: PyInt_AsLong(obj) will try the
nb_int slot on non-integer objects which can return errors
(it returns -1 and sets the error message).

> So eliminating intobject.h likely helps avoiding subtle errors.

In the long run, yes. In the short run, other criteria are
more important, IMHO.
"""

IMO, it would be worthwhile collecting all Python 2.x compatibility C
APIs in two new files:

* py2compat.h
* py2compat.c

These could then be used in extensions and make the use of such
compatibility APIs explicit in the extension.

----------
nosy: +lemburg

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7353>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.