# HG changeset patch
# User Volker Braun <vbraun.name@gmail.com>
# Date 1366887998 -3600
# Node ID cb9735f1d2ebc9466b2c06727ae3d1d296e7b345
# Parent 6d0d6381e4542f088f4638c7a6bcd12e83aa2fa4
Disallow conversion of 0 into Set_object
diff --git a/sage/sets/set.py b/sage/sets/set.py
a
|
b
|
|
193 | 193 | |
194 | 194 | sage: latex(Set(ZZ)) |
195 | 195 | \Bold{Z} |
| 196 | |
| 197 | TESTS:: |
| 198 | |
| 199 | sage: 0 == Set([1]), Set([1]) == 0 |
| 200 | (False, False) |
| 201 | sage: 1 == Set([0]), Set([0]) == 1 |
| 202 | (False, False) |
196 | 203 | """ |
197 | 204 | def __init__(self, X): |
198 | 205 | """ |
… |
… |
|
205 | 212 | |
206 | 213 | sage: type(Set(QQ)) |
207 | 214 | <class 'sage.sets.set.Set_object_with_category'> |
| 215 | |
| 216 | TESTS:: |
| 217 | |
| 218 | sage: _a, _b = get_coercion_model().canonical_coercion(Set([0]), 0) |
| 219 | Traceback (most recent call last): |
| 220 | ... |
| 221 | TypeError: no common canonical parent for objects with parents: |
| 222 | '<class 'sage.sets.set.Set_object_enumerated_with_category'>' |
| 223 | and 'Integer Ring' |
208 | 224 | """ |
| 225 | from sage.rings.integer import is_Integer |
| 226 | if isinstance(X, (int,long)) or is_Integer(X): |
| 227 | # The coercion model will try to call Set_object(0) |
| 228 | raise ValueError('underlying object cannot be an integer') |
209 | 229 | Parent.__init__(self, category=Sets()) |
210 | 230 | self.__object = X |
211 | 231 | |