1 | | The patch 12159.patch modifies the code in remove_from_tuple() in sage.rings.polynomial.multi_polynomial.pyx. The patch 12160.patch adds a testing example in the docstring. |

| 1 | This works: |

| 2 | |

| 3 | {{{ |

| 4 | sage: R.<x,y>=PolynomialRing(QQ,2) |

| 5 | sage: a=x^2+x*y+y |

| 6 | sage: a.polynomial(x) |

| 7 | x^2 + y*x + y |

| 8 | |

| 9 | But this does not work: |

| 10 | |

| 11 | sage: R.<x,y>=PolynomialRing(GF(5),2) |

| 12 | sage: a=x^2+x*y+y |

| 13 | sage: a.polynomial(x) |

| 14 | Traceback (most recent call last): |

| 15 | ... |

| 16 | TypeError: 'tuple' object cannot be interpreted as an index |

| 17 | }}} |

| 18 | |

| 19 | I traced this bug, and found that |

| 20 | |

| 21 | {{{ |

| 22 | sage: B=QQ[x] |

| 23 | sage: print B({0:1,1:2}) |

| 24 | 2*x + 1 |

| 25 | sage: print B({(0,):1,(1,):2}) |

| 26 | 2*x + 1 |

| 27 | sage: B=GF(5)[x] |

| 28 | sage: print B({0:1,1:2}) |

| 29 | 2*x + 1 |

| 30 | sage: print B({(0,):1,(1,):2}) |

| 31 | Traceback (most recent call last): |

| 32 | ... |

| 33 | TypeError: 'tuple' object cannot be interpreted as an index |

| 34 | }}} |

| 35 | I think the second form is not acceptable. Then the function |

| 36 | remove_from_tuple() in sage.rings.polynomial.multi_polynomial.pyx |

| 37 | should be revised as it output (1,) from (1,2) for example. |