Opened 8 years ago

Closed 8 years ago

#17523 closed defect (fixed)

Symbolic power of None will crash

Reported by: Martin von Gagern Owned by:
Priority: major Milestone: sage-6.5
Component: symbolics Keywords:
Cc: Merged in:
Authors: Jeroen Demeyer Reviewers: Martin von Gagern
Report Upstream: N/A Work issues:
Branch: 50d0aff (Commits, GitHub, GitLab) Commit: 50d0affffbcb97ed23862989ce67644261bc0b2e
Dependencies: Stopgaps:

Status badges

Description (last modified by Martin von Gagern)

Computing a symbolic power in a situation where the base is None will cause Sage to crash:

sage: None^pi

Change History (9)

comment:1 Changed 8 years ago by Martin von Gagern

Description: modified (diff)
Summary: Symbolic exponent of None will crashSymbolic power of None will crash

comment:2 Changed 8 years ago by Jeroen Demeyer

Authors: Jeroen Demeyer

comment:3 Changed 8 years ago by Jeroen Demeyer

Branch: u/jdemeyer/ticket/17523
Created: Dec 18, 2014, 11:22:08 AMDec 18, 2014, 11:22:08 AM
Modified: Dec 18, 2014, 12:44:49 PMDec 18, 2014, 12:44:49 PM

comment:4 Changed 8 years ago by Jeroen Demeyer

Commit: ea65f564519f1389b7f1c7f2e83cfe7257a5eb0e
Status: newneeds_review

New commits:

ea65f56Check when converting to Expression

comment:5 Changed 8 years ago by Martin von Gagern

Branch: u/jdemeyer/ticket/17523u/gagern/ticket/17523
Modified: Dec 18, 2014, 2:21:45 PMDec 18, 2014, 2:21:45 PM

comment:6 Changed 8 years ago by Martin von Gagern

Commit: ea65f564519f1389b7f1c7f2e83cfe7257a5eb0e50d0affffbcb97ed23862989ce67644261bc0b2e

I consider it better to restrict the try block to just the very thing you anticipate, namely self not being of type Expression. An error raised when converting the exponent should not lead to the catch block with reversed roles.

I hadn't known of the lack of reverse arithmetic operations in Cython until I read about this here. Good to know that you can't rely on the type of self! That manual also suggests (or even requires?) raising NotImplemented for mismatched operand types. Presumably so that the opposite order can be tried as well. Should we in some cases raise that instead of the current TypeError? Does anyone have an idea of the benefits and drawbacks of doing so?


New commits:

50d0affMake conversion error messages symmetric.

comment:7 Changed 8 years ago by Jeroen Demeyer

I agree with your patch.

comment:8 Changed 8 years ago by Martin von Gagern

Reviewers: Martin von Gagern
Status: needs_reviewpositive_review

I'm happy with your work, doctests are happy with both of us, so everything's fine.

comment:9 Changed 8 years ago by Volker Braun

Branch: u/gagern/ticket/1752350d0affffbcb97ed23862989ce67644261bc0b2e
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.