Opened 6 years ago

Closed 6 years ago

#21983 closed enhancement (fixed)

Remaining py3 syntax level errors

Reported by: jmantysalo Owned by:
Priority: major Milestone: sage-7.5
Component: python3 Keywords:
Cc: chapoton Merged in:
Authors: Jori Mäntysalo Reviewers: Frédéric Chapoton
Report Upstream: N/A Work issues:
Branch: 3cdfd4e (Commits, GitHub, GitLab) Commit: 3cdfd4e6f7ba5b39f039395dbbc5c9c1f2fe8deb
Dependencies: Stopgaps:

Status badges

Description

After plain docstring unicode errors (#21982) there are 2 times 2 problems:

  • lambda (a, b): -syntax at src/sage/graphs/generators/smallgraphs.py and src/sage/combinat/matrices/hadamard_matrix.py. These are easy.
  • Some kind of for i in [1,2], [3,4] -error in src/sage/combinat/designs/database.py and src/sage/combinat/root_system/coxeter_type.py. Not sure what to do - Frédéric?

After these we should have empty noerrors from

find src/sage/ -name '*.py' | while read f; do python3 -m py_compile $f 2>&1 |
egrep -q . && echo $f >> errors || echo $f >> noerrors ; done

Change History (11)

comment:1 follow-up: Changed 6 years ago by jdemeyer

The syntax for i in [1,2], [3,4] is correct in Python 3, so what is the problem?

comment:2 in reply to: ↑ 1 Changed 6 years ago by jmantysalo

Replying to jdemeyer:

The syntax for i in [1,2], [3,4] is correct in Python 3, so what is the problem?

Something like [f(x) for x in [1, 2], [3, 4]] I guess. But just run

python3 -m py_compile src/sage/combinat/root_system/coxeter_type.py

to see.

comment:3 Changed 6 years ago by jmantysalo

  • Authors set to Jori Mäntysalo

Found it. Actually it just that Python2 allows [x for x in 1, 2, 3] but Python3 does not. It is explained here: http://python-history.blogspot.fi/2010/06/from-list-comprehensions-to-generator.html

I can make the patch.

comment:4 Changed 6 years ago by jmantysalo

  • Branch set to u/jmantysalo/remaining_py3_syntax_level_errors

comment:5 Changed 6 years ago by jmantysalo

  • Commit set to a3af115fed1907a72262b58f68c1eb15170b4688
  • Status changed from new to needs_review

New commits:

a3af115Last py3-compliance on syntax level.

comment:6 follow-up: Changed 6 years ago by jdemeyer

In hadamard_matrix.py, it's much better to replace map(lambda x:f(x), I) by f(x) for x in I.

comment:7 Changed 6 years ago by git

  • Commit changed from a3af115fed1907a72262b58f68c1eb15170b4688 to 3cdfd4e6f7ba5b39f039395dbbc5c9c1f2fe8deb

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

3cdfd4eFrom map() to list comprehension.

comment:8 in reply to: ↑ 6 Changed 6 years ago by jmantysalo

Replying to jdemeyer:

In hadamard_matrix.py, it's much better to replace map(lambda x:f(x), I) by f(x) for x in I.

Good point. Maybe I should read the code I am changing. Well, next time then.

comment:9 Changed 6 years ago by chapoton

  • Reviewers set to Frédéric Chapoton
  • Status changed from needs_review to positive_review

ok, good, thanks

comment:10 Changed 6 years ago by jmantysalo

Hooray!

Is there any way to doccheck syntax being py3-compliant, i.e. a py2 module to check for py3 syntax?

comment:11 Changed 6 years ago by vbraun

  • Branch changed from u/jmantysalo/remaining_py3_syntax_level_errors to 3cdfd4e6f7ba5b39f039395dbbc5c9c1f2fe8deb
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.