Opened 5 months ago

Closed 4 months ago

#31043 closed defect (fixed)

Preparsing aborts when first line is a comment

Reported by: gh-spaghettisalat Owned by:
Priority: major Milestone: sage-9.3
Component: user interface Keywords: preparser, multiline input, comment
Cc: slelievre, egourgoulhon, strogdon Merged in:
Authors: Joshua Campbell Reviewers: Samuel Lelièvre
Report Upstream: N/A Work issues:
Branch: 19fcb63 (Commits, GitHub, GitLab) Commit: 19fcb637e896aec7c6bb4042d68eb6752c0f69d4
Dependencies: Stopgaps:

Status badges

Description

For example

preparse('''# some comment

some_function(some_var) = some_var
         ''')

yields

# πšœπš˜πš–πšŽ πšŒπš˜πš–πš–πšŽπš—πš

πšœπš˜πš–πšŽ_πšπšžπš—πšŒπšπš’πš˜πš—(πšœπš˜πš–πšŽ_πšŸπšŠπš›)=πšœπš˜πš–πšŽ_πšŸπšŠπš›

instead of the correct

# πšœπš˜πš–πšŽ πšŒπš˜πš–πš–πšŽπš—πš

__πšπš–πš™__=πšŸπšŠπš›("πšœπš˜πš–πšŽ_πšŸπšŠπš›");πšœπš˜πš–πšŽ_πšπšžπš—πšŒπšπš’πš˜πš—=πšœπš’πš–πš‹πš˜πš•πš’πšŒ_πšŽπš‘πš™πš›πšŽπšœπšœπš’πš˜πš—(πšœπš˜πš–πšŽ_πšŸπšŠπš›).πšπšžπš—πšŒπšπš’πš˜πš—(πšœπš˜πš–πšŽ_πšŸπšŠπš›)

Change History (9)

comment:1 Changed 5 months ago by gh-spaghettisalat

  • Branch set to public/preparse_comment_bug
  • Commit set to 9bcb6a013b4d369bb227940dca78c28594e3b3fb
  • Status changed from new to needs_review

New commits:

​9bcb6a0preparse: don't abort preparsing when first line is a comment

comment:2 Changed 5 months ago by git

  • Commit changed from 9bcb6a013b4d369bb227940dca78c28594e3b3fb to ec93db37bca08fcf442c2e0f28312b590ffcc0ce

Branch pushed to git repo; I updated commit sha1. New commits:

​0def715Merge branch 'develop' into public/preparse_comment_bug
​ec93db3Add regression test

comment:3 Changed 5 months ago by gh-jcamp0x2a

  • Authors set to Joshua Campbell
  • Cc slelievre egourgoulhon strogdon added
  • Component changed from PLEASE CHANGE to user interface

I believe I broke this with my fix for #30928. Thank you for spotting it and submitting a fix! I've taken the liberty of adding a regression test. Oh, please add yourself as the first author, too.

comment:4 follow-up: Changed 4 months ago by slelievre

Maybe the doctest could be more similar to the one above it.

Something like:

-        sage: preparse('''# some comment
-        ....: some_function(some_var) = some_var''')
-        '# some comment\n__tmp__=var("some_var"); some_function = symbolic_expression(some_var).function(some_var)'
+        sage: print(preparse('''# some comment
+        ....: f(x) = x + 1'''))
+        # some comment
+        __tmp__=var("x"); f = symbolic_expression(x + Integer(1)).function(x)

comment:5 Changed 4 months ago by git

  • Commit changed from ec93db37bca08fcf442c2e0f28312b590ffcc0ce to 19fcb637e896aec7c6bb4042d68eb6752c0f69d4

Branch pushed to git repo; I updated commit sha1. New commits:

​19fcb63Make regression test more similar to the one above

comment:6 in reply to: ↑ 4 Changed 4 months ago by gh-jcamp0x2a

Replying to slelievre:

Maybe the doctest could be more similar to the one above it.

Agreed. I've incorporated your suggested change into the branch. Thanks!

comment:7 Changed 4 months ago by slelievre

  • Reviewers set to Samuel LeliΓ¨vre
  • Status changed from needs_review to positive_review

Thanks! Good to go.

comment:8 Changed 4 months ago by slelievre

  • Keywords preparser multiline input comment added

comment:9 Changed 4 months ago by vbraun

  • Branch changed from public/preparse_comment_bug to 19fcb637e896aec7c6bb4042d68eb6752c0f69d4
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.