Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't use the deprecated 'new' module #11819

Closed
jhpalmieri opened this issue Sep 20, 2011 · 12 comments
Closed

don't use the deprecated 'new' module #11819

jhpalmieri opened this issue Sep 20, 2011 · 12 comments

Comments

@jhpalmieri
Copy link
Member

The Python module 'new' is deprecated and has been removed in Python 3.0, so since it's not hard to avoid it, we shouldn't use it. The attached patch removes all imports of 'new', tested with

sage: search_src('import', 'new', whole_word=True)

The file new.py (in SAGE_ROOT/local/lib/python/) contains code like

from types import InstanceType as instance

so we just have to replace

import new
new.instance(...)

with

import types
types.InstanceType(...)

Apply

  1. attachment: trac_11819_review.patch

to the sage repository

Component: pickling

Keywords: sd35

Author: John Palmieri

Reviewer: Julian Rueth

Merged: sage-5.0.beta1

Issue created by migration from https://trac.sagemath.org/ticket/11819

@jhpalmieri
Copy link
Member Author

comment:1

Attachment: trac_11819-no-new.patch.gz

@saraedum
Copy link
Member

comment:2

It appears I added some uses of 'new' in #11716. So your patch doesn't apply anymore. I'm trying to do something about it now.

@saraedum
Copy link
Member

Reviewer: Julian Rueth

@saraedum
Copy link
Member

comment:3

I made some additional changes. Feel free to set it to positive review if you're ok with these.

@saraedum
Copy link
Member

comment:5

Btw. I'll add doctests to the new functions in #12192.

@saraedum
Copy link
Member

comment:6

Apply trac_11819_review.patch

@saraedum

This comment has been minimized.

@jhpalmieri
Copy link
Member Author

comment:7

The doctest

    sage: sage0("'new' in sys.modules")
    False

fails for me. It might be imported by IPython; if I do sage --ipython:

In [1]: import sys

In [2]: 'new' in sys.modules
Out[2]: True

Or more tersely:

$ sage --ipython -c "import sys; print 'new' in sys.modules"
True

@saraedum
Copy link
Member

Attachment: trac_11819_review.patch.gz

combined and rebased patch

@saraedum
Copy link
Member

comment:8

You are right. I must have run the wrong patch somehow. Sorry for that.

I adapted my patch. I it works now.

@saraedum
Copy link
Member

Changed keywords from none to sd35

@jdemeyer jdemeyer modified the milestones: sage-4.8, sage-5.0 Dec 22, 2011
@jdemeyer
Copy link
Contributor

Merged: sage-5.0.beta1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants