Skip to content

Fix the compatibility of IPython 9.0+#86

Open
cxzhong wants to merge 1 commit intosagemath:masterfrom
cxzhong:patch-1
Open

Fix the compatibility of IPython 9.0+#86
cxzhong wants to merge 1 commit intosagemath:masterfrom
cxzhong:patch-1

Conversation

@cxzhong
Copy link
Copy Markdown

@cxzhong cxzhong commented Apr 15, 2026

Comment thread emacs_sage_shell.py
Comment on lines +182 to +183
text, completions = ip.complete(f'{varname}.')
ln = len(text)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to work, but I don't understand it. I tried:

sage: import IPython
sage: ip = IPython.get_ipython()
sage: ip.complete("Bi")
('Bi',
 ['Bialgebras',
  'BialgebrasWithBasis',
  'Bijectionist',
  'Bilder/',
  'Bimodules',
  'BinaryQF',
  'BinaryQF_reduced_representatives',
  'BinaryRecurrenceSequence',
  'BinaryStrings',
  'BinaryTree',
  'BinaryTrees',
  'BipartiteGraph',
  'Bitset'])

so it seems it would strip the first two letters from every result - but it doesn't! Do you know why?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# Old IPython: ip.complete("ZZ.") → ('ZZ.', ['ZZ.CartesianProduct', ...])
# len("ZZ") + 1 = 3, strip 3 from 'ZZ.CartesianProduct' → 'CartesianProduct' 

# IPython 9.x: ip.complete("ZZ.") → ('.', ['.CartesianProduct', ...])
# len("ZZ") + 1 = 3, strip 3 from '.CartesianProduct' → 'rtesianProduct' 

Seems like this

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I was not clear. The example above is with IPython 9.12.0!

sage: import IPython
sage: ip = IPython.get_ipython()
sage: ip.complete("Bij")
('Bij', ['Bijectionist'])
sage: ip.complete("Bi")
('Bi',
 ['Bialgebras',
  'BialgebrasWithBasis',
  'Bijectionist',
  'Bilder/',
  'Bimodules',
  'BinaryQF',
  'BinaryQF_reduced_representatives',
  'BinaryRecurrenceSequence',
  'BinaryStrings',
  'BinaryTree',
  'BinaryTrees',
  'BipartiteGraph',
  'Bitset'])
sage: IPython.__version__
'9.12.0'
sage: ip.complete("Bijectionist.")
('.',
 ['.category',
  '.constant_blocks',
  '.dump',
  '.dumps',
  '.get_custom_name',
  '.minimal_subdistributions_blocks_iterator',
  '.minimal_subdistributions_iterator',
  '.parent',
  '.possible_values',
  '.rename',
  '.reset_name',
  '.save',
  '.set_constant_blocks',
  '.set_distributions',
  '.set_homomesic',
  '.set_intertwining_relations',
  '.set_quadratic_relation',
  '.set_semi_conjugacy',
  '.set_statistics',
  '.set_value_restrictions',
  '.solutions_iterator',
  '.statistics_fibers',
  '.statistics_table'])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants