Opened 4 years ago

Closed 6 months ago

#12482 closed defect (fixed)

isinstance failure on lazy imported class

Reported by: nthiery Owned by: jason
Priority: major Milestone: sage-6.4
Component: misc Keywords: Cernay2012
Cc: rishi, jason, rlm, rbradshaw Merged in:
Authors: Jeroen Demeyer Reviewers: Volker Braun
Report Upstream: N/A Work issues:
Branch: 8528515 (Commits) Commit: 85285159cb0348786a148587cebfceae6f8d36ca
Dependencies: Stopgaps:

Description (last modified by jdemeyer)

isinstance may fail on a lazy imported class, which can cause hard to track history-dependent failures (just been hit: #12483)::

sage: lazy_import('sage.rings.rational_field', 'RationalField')
sage: isinstance(QQ, RationalField)
False
sage: isinstance(QQ, RationalField)
True

We fix this using the mechanism from PEP 3119.

Change History (12)

comment:1 Changed 4 years ago by nthiery

  • Description modified (diff)

comment:2 Changed 4 years ago by nthiery

  • Keywords Cernay2012 added

comment:3 Changed 3 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

comment:4 Changed 2 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:5 Changed 2 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:6 Changed 22 months ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:7 Changed 6 months ago by jdemeyer

  • Authors set to Jeroen Demeyer
  • Description modified (diff)

comment:8 Changed 6 months ago by jdemeyer

  • Branch set to u/jdemeyer/isinstance_failure_on_lazy_imported_class

comment:9 Changed 6 months ago by jdemeyer

  • Commit set to 85285159cb0348786a148587cebfceae6f8d36ca
  • Status changed from new to needs_review

New commits:

8528515Trac #12482: Support isinstance() and issubclass()

comment:10 Changed 6 months ago by vbraun

  • Reviewers set to Volker Braun
  • Status changed from needs_review to positive_review

comment:11 Changed 6 months ago by nthiery

Nicely done Jeroen! Thanks a lot, that will make lazy imported classes much more practical and safe.

comment:12 Changed 6 months ago by vbraun

  • Branch changed from u/jdemeyer/isinstance_failure_on_lazy_imported_class to 85285159cb0348786a148587cebfceae6f8d36ca
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.