Convert Sage code to Python 3 (as used by Sage >= 9) #849

pull real-or-random wants to merge 1 commits into bitcoin-core:master from real-or-random:202011-sage-python3 changing 2 files +29 −24
  1. real-or-random commented at 1:30 pm on November 21, 2020: contributor

    This adds one more commit on top of #848 and squashes the commits.

    Thanks to @fchapoton for spotting the issue and suggesting initial fixes.

  2. in sage/group_prover.sage:103 in fe90a98cab outdated
     99@@ -100,7 +100,7 @@ class fastfrac:
    100     """Multiply something else with a fraction."""
    101     return self.__mul__(other)
    102 
    103-  def __div__(self,other):
    104+  def __truediv__(self,other):
    


    jonasnick commented at 11:09 am on November 23, 2020:
    This breaks sage 8.9. Can you leave the originas __div__ definition (which shouldn’t affect python 3) and add __truediv__? I tested that with this change both versions give the same output.

    real-or-random commented at 12:18 pm on November 23, 2020:

    I can do this but I don’t understand that this helps for sage 8.9 because it’s based on python 2 and all the other changes should break it. So you’re saying this works for you?

    https://wiki.sagemath.org/Python3-Switch


    fchapoton commented at 12:32 pm on November 23, 2020:
    the changes about print, xrange and map are all harmless : they work with good old python2-based sage

    real-or-random commented at 12:43 pm on November 23, 2020:
    Ok, I changed it.
  3. real-or-random force-pushed on Nov 23, 2020
  4. in sage/group_prover.sage:114 in dd72422c5f outdated
    110     return NotImplemented
    111 
    112+  # Compatibility wrapper for Sage versions based on Python 2
    113+  def __div__(self,other):
    114+     """Divide two fractions."""
    115+     return __truediv__(self,other)
    


    jonasnick commented at 1:21 pm on November 23, 2020:
    NameError: global name '__truediv__' is not defined. This should be return self.__truediv__(other)

    real-or-random commented at 2:57 pm on November 23, 2020:
    Ok, I assumed I’m clever enough to write three lines of Python code without testing. But apparently I was wrong. (Sorry, it’s a lot of work for me to install an older sage version…) Should work now.

    jonasnick commented at 3:19 pm on November 23, 2020:
    Fwiw, nix-shell -p sage would work but the tests take forever. Therefore you can use nix-shell '-p sage.overrideAttrs (oldAttrs: rec { buildInputs = [ makeWrapper ]; })' to disable the tests.
  5. Convert Sage code to Python 3 (as used by Sage >= 9)
    Co-authored-by: Tim Ruffing <crypto@timruffing.de>
    13c88efed0
  6. real-or-random force-pushed on Nov 23, 2020
  7. jonasnick approved
  8. jonasnick commented at 8:11 pm on November 23, 2020: contributor
    ACK 13c88efed0005eb6745a222963ee74564054eafb
  9. jonasnick merged this on Nov 23, 2020
  10. jonasnick closed this on Nov 23, 2020

  11. jonasnick cross-referenced this on Nov 23, 2020 from issue use python3 print by fchapoton
  12. Fabcien referenced this in commit fc71d00124 on Apr 8, 2021
  13. deadalnix referenced this in commit 70b41f3863 on Apr 9, 2021
  14. theStack referenced this in commit 3b04d924b7 on Jun 11, 2023
  15. theStack cross-referenced this on Jun 11, 2023 from issue clean up in-comment Sage code (refer to secp256k1_params.sage, update to Python3) by theStack
  16. theStack referenced this in commit 017358e685 on Jul 7, 2023
  17. theStack referenced this in commit 5a2c23f83c on Jul 7, 2023
  18. theStack referenced this in commit 600c5adcd5 on Jul 10, 2023
  19. real-or-random referenced this in commit cc55757552 on Jul 10, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-10-30 07:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me