#11244 closed defect (fixed)
In python-2.7 deprecation warnings are not shown to the user by default
Reported by: | fbissey | Owned by: | jason |
---|---|---|---|
Priority: | major | Milestone: | sage-4.7.2 |
Component: | misc | Keywords: | |
Cc: | kini | Merged in: | sage-4.7.2.alpha0 |
Authors: | François Bissey | Reviewers: | Mariah Lenox |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description (last modified by )
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:
Attachments (4)
Change History (21)
comment:1 Changed 10 years ago by
- Description modified (diff)
- Status changed from new to needs_review
Changed 10 years ago by
comment:2 Changed 10 years ago by
- Status changed from needs_review to needs_work
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.
comment:3 Changed 10 years ago by
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)
comment:4 Changed 10 years ago by
- Description modified (diff)
- Work issues set to fix warnings in sage/combinat/partition.py
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.
comment:5 Changed 10 years ago by
- Description modified (diff)
- Status changed from needs_work to needs_review
comment:6 Changed 10 years ago by
- Description modified (diff)
Fixing my mistaken assumptions about warnings in general.
comment:7 Changed 10 years ago by
- Status changed from needs_review to needs_work
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)
comment:8 Changed 10 years ago by
- Description modified (diff)
Changed 10 years ago by
3 more files fixed. double messaging removed in two of them. [rebased on 4.7.alpha5]
comment:9 Changed 10 years ago by
- Status changed from needs_work to needs_review
comment:10 Changed 10 years ago by
- Description modified (diff)
comment:11 Changed 10 years ago by
- Reviewers set to Mariah Lenox
- Status changed from needs_review to positive_review
Patches applied to sage-4.7.1.alpha2, then did 'sage -b', followed by 'make testlong'. All tests passed. Positive review!
comment:12 Changed 10 years ago by
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.
comment:13 Changed 10 years ago by
- Milestone changed from sage-4.7.1 to sage-4.7.2
comment:14 Changed 10 years ago by
- Work issues fix warnings in sage/combinat/partition.py deleted
Removing the work issue as it was in fact dealt with.
comment:15 Changed 10 years ago by
- Merged in set to sage-4.7.2.alpha0
- Resolution set to fixed
- Status changed from positive_review to closed
comment:16 Changed 10 years ago by
(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...
comment:17 Changed 9 years ago by
- Cc kini added
new patch to restore deprecation warnings in python 2.7 (now in git format)