Factory function for utc unpickling. Makes sure that unpickling a utc instance always returns the same module global. These examples belong in the UTC class above, but it is obscured; or in the README.rst, but we are not depending on Python 2.4 so integrating the README.rst exa
()
| 264 | |
| 265 | |
| 266 | def _UTC(): |
| 267 | """Factory function for utc unpickling. |
| 268 | |
| 269 | Makes sure that unpickling a utc instance always returns the same |
| 270 | module global. |
| 271 | |
| 272 | These examples belong in the UTC class above, but it is obscured; or in |
| 273 | the README.rst, but we are not depending on Python 2.4 so integrating |
| 274 | the README.rst examples with the unit tests is not trivial. |
| 275 | |
| 276 | >>> import datetime, pickle |
| 277 | >>> dt = datetime.datetime(2005, 3, 1, 14, 13, 21, tzinfo=utc) |
| 278 | >>> naive = dt.replace(tzinfo=None) |
| 279 | >>> p = pickle.dumps(dt, 1) |
| 280 | >>> naive_p = pickle.dumps(naive, 1) |
| 281 | >>> len(p) - len(naive_p) |
| 282 | 17 |
| 283 | >>> new = pickle.loads(p) |
| 284 | >>> new == dt |
| 285 | True |
| 286 | >>> new is dt |
| 287 | False |
| 288 | >>> new.tzinfo is dt.tzinfo |
| 289 | True |
| 290 | >>> utc is UTC is timezone('UTC') |
| 291 | True |
| 292 | >>> utc is timezone('GMT') |
| 293 | False |
| 294 | """ |
| 295 | return utc |
| 296 | |
| 297 | |
| 298 | _UTC.__safe_for_unpickling__ = True |
nothing calls this directly
no outgoing calls
no test coverage detected