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

In python-2.7 deprecation warnings are not shown to the user by default #11244

Closed
kiwifb opened this issue Apr 24, 2011 · 26 comments
Closed

In python-2.7 deprecation warnings are not shown to the user by default #11244

kiwifb opened this issue Apr 24, 2011 · 26 comments
Assignees
Milestone

Comments

@kiwifb
Copy link
Member

kiwifb commented Apr 24, 2011

In python 2.7 deprecation warnings are a developer only feature. Which mean that sage's deprecation warnings are not shown either. A previous patch in #9958 only re-enable deprecation warnings in doctests but not in regular sage sessions.

Apply:

CC: @kini

Component: misc

Author: François Bissey

Reviewer: Mariah Lenox

Merged: sage-4.7.2.alpha0

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

@kiwifb

This comment has been minimized.

@kiwifb
Copy link
Member Author

kiwifb commented Apr 24, 2011

Author: François Bissey

@kiwifb
Copy link
Member Author

kiwifb commented Apr 24, 2011

Attachment: trac_11244_reenable_deprecationwarnings_in_python27.patch.gz

new patch to restore deprecation warnings in python 2.7 (now in git format)

@kiwifb
Copy link
Member Author

kiwifb commented Apr 24, 2011

comment:2

There is an issue with

sage -t -force_lib "devel/sage-main/sage/combinat/partition.py"
**********************************************************************
File "/usr/share/sage/devel/sage-main/sage/combinat/partition.py", line 2511:
    sage: RestrictedPartitions(5,[3,2,1])
Expected:
    doctest:...: DeprecationWarning: RestrictedPartitions is deprecated; use Partitions with the parts_in keyword instead.
    doctest:...: DeprecationWarning: RestrictedPartitions_nsk is deprecated; use Partitions with the parts_in keyword instead.
    Partitions of 5 restricted to the values [1, 2, 3]
Got:
    doctest:260: DeprecationWarning: RestrictedPartitions_nsk is deprecated; use Partitions with the parts_in keyword instead.
    Partitions of 5 restricted to the values [1, 2, 3] 

But clearly I am not sure why the original code should give both a warning and a deprecation warning. Of course my patch only let sage display the later.

@kiwifb
Copy link
Member Author

kiwifb commented Apr 24, 2011

comment:3

The code in question

    import warnings
    warnings.warn('RestrictedPartitions is deprecated; use Partitions with the parts_in keyword instead.', DeprecationWarning, stacklevel=2)
    from sage.misc.misc import deprecation
    deprecation('RestrictedPartitions is deprecated; use Partitions with the parts_in keyword instead.')
    return RestrictedPartitions_nsk(n, S, k)

@kiwifb
Copy link
Member Author

kiwifb commented Apr 24, 2011

comment:4

I see that in fact there are are two related functions being deprecated and this is a way to warn for both at the same time.

@kiwifb

This comment has been minimized.

@kiwifb
Copy link
Member Author

kiwifb commented Apr 24, 2011

Work Issues: fix warnings in sage/combinat/partition.py

@kiwifb

This comment has been minimized.

@kiwifb
Copy link
Member Author

kiwifb commented Apr 25, 2011

Patch to reenable extra deprecation warning in sage/combinat/partition.py.

@kiwifb

This comment has been minimized.

@kiwifb
Copy link
Member Author

kiwifb commented Apr 25, 2011

comment:6

Attachment: trac_11244_fix_combinatpartition_warnings.patch.gz

Fixing my mistaken assumptions about warnings in general.

@kiwifb
Copy link
Member Author

kiwifb commented Apr 25, 2011

comment:7

There are more deprecation warnings issued by the standard python mechanism rather than sage's mechanism

sage-4.7.alpha1 $ grep -r DeprecationWarning\,\ stacklevel *
sage/matrix/constructor.py:                    warnings.warn("invocation of block_matrix with just a list whose length is a perfect square is deprecated. See the documentation for details.", DeprecationWarning, stacklevel=2)
sage/combinat/partition.py:    warnings.warn('RestrictedPartitions is deprecated; use Partitions with the parts_in keyword instead.', DeprecationWarning, stacklevel=2)
sage/combinat/partition.py:        warnings.warn('RestrictedPartitions_nsk is deprecated; use Partitions with the parts_in keyword instead.', DeprecationWarning, stacklevel=2)
sage/groups/perm_gps/permgroup.py:        warnings.warn('quotient_group() is deprecated; use quotient() instead.', DeprecationWarning, stacklevel=2)
sage/graphs/base/graph_backends.py:                    DeprecationWarning, stacklevel=2)
sage/graphs/base/graph_backends.py:                    DeprecationWarning, stacklevel=2)
sage/misc/misc.py:    warn(message, DeprecationWarning, stacklevel=3)

@kiwifb

This comment has been minimized.

@kiwifb
Copy link
Member Author

kiwifb commented Apr 25, 2011

3 more files fixed. double messaging removed in two of them. [rebased on 4.7.alpha5]

@kiwifb
Copy link
Member Author

kiwifb commented Apr 25, 2011

comment:9

Attachment: trac_11244_fixmoredeprecationswarnings.patch.gz

@kiwifb
Copy link
Member Author

kiwifb commented May 18, 2011

Use this patch if you base your review on 4.7.1.alpha1

@kiwifb

This comment has been minimized.

@kiwifb
Copy link
Member Author

kiwifb commented May 30, 2011

comment:10

Attachment: trac_11244_fixmoredeprecationswarnings.2.patch.gz

@sagetrac-mariah
Copy link
Mannequin

sagetrac-mariah mannequin commented Jun 15, 2011

comment:11

Patches applied to sage-4.7.1.alpha2, then did 'sage -b', followed by 'make testlong'. All tests passed. Positive review!

@sagetrac-mariah
Copy link
Mannequin

sagetrac-mariah mannequin commented Jun 15, 2011

Reviewer: Mariah Lenox

@kiwifb
Copy link
Member Author

kiwifb commented Jun 15, 2011

comment:12

Thank you Mariah for the review. Thank you John for the suggestion to make it better. Thank you Steve for pointing the obvious.

Thank you all for making this reach this stage.

@jdemeyer jdemeyer modified the milestones: sage-4.7.1, sage-4.7.2 Jun 15, 2011
@kiwifb
Copy link
Member Author

kiwifb commented Jun 18, 2011

Changed work issues from fix warnings in sage/combinat/partition.py to none

@kiwifb
Copy link
Member Author

kiwifb commented Jun 18, 2011

comment:14

Removing the work issue as it was in fact dealt with.

@jdemeyer
Copy link

Merged: sage-4.7.2.alpha0

@jasongrout
Copy link
Member

comment:16

(for another ticket) maybe it would be best if we subclassed the warnings to all inherit from a SageWarning class, and then turn on just Sage warnings...

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

3 participants