changes made by 2to3 tool (idioms), many changes

This commit has still doctests failures in 16 files.
This is committed to show where 2to3 introduces invalid changes!
reverted changes to 4 modules done by 2to3 tool

2 changes concern isinstance() -> type()
4 changes concern sorted() -> .sort()
change "while 1:" into "while True:" for .pyx modules

While not strictly necessary it was simple enough :-)
Improve the deprecated_function_alias
Trac #15984: Python 3 preparation: Change some code to use more modern Python idioms

This fixer changes code like {{{type(x) == T)}}} and {{{while 1:}}} and
it introduces the {{{sorted()}}} function where appropriate.

These changes are optional, but they improve style and may provide a
small performance gain.

Changes according to {{{lib2to3/fixes/fix_idioms.py}}}:
{{{
* Change some type comparisons to isinstance() calls:
    type(x) == T -> isinstance(x, T)
    type(x) is T -> isinstance(x, T)
    type(x) != T -> not isinstance(x, T)
    type(x) is not T -> not isinstance(x, T)

* Change "while 1:" into "while True:".

* Change both
    v = list(EXPR)
    v.sort()
    foo(v)

and the more general
    v = EXPR
    v.sort()
    foo(v)

into
    v = sorted(EXPR)
    foo(v)
}}}

URL: http://trac.sagemath.org/15984
Reported by: wluebbe
Ticket author(s): Wilfried Luebbe
Reviewer(s): Travis Scrimshaw
Trac #16093: Finding name for deprecation sometimes fails

Deprecated functions from modules imported with `import foo` don't work,
while modules imported with `from bar import foo` do work. This is
because sometimes there is no `__module__` attribute.

URL: http://trac.sagemath.org/16093
Reported by: vbraun
Ticket author(s): Volker Braun
Reviewer(s): Jan Keitel
Updated Sage version to 6.2.beta7