Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Python language bindings to v1.3.1 #2382

Merged
merged 3 commits into from
Dec 2, 2023
Merged

Conversation

blueloveTH
Copy link
Contributor

@blueloveTH blueloveTH commented Nov 30, 2023

The previous pr is #2353 (3 weeks ago)

What's changed from v1.3.0 to v1.3.1

  1. fix a bug of type names
  2. improve f-string. It supports {{ and }} escape now
  3. rename easing functions. Now names are like easing.Linear and easing.OutQuad
  4. allow complex assignment in class definition
  5. add str.splitlines()
  6. fix [BUG] Memory leak in SStream::str() pocketpy/pocketpy#179
  7. add csv module

New module csv

v1.3.1 introduces csv module with csv.reader and csv.DictReader for parsing csv files.
The module is a compatible subset of cpython's csv which supports common csv format with linebreaks.

import csv
def test(data: str, expected):
    ret: list = csv.reader(data.splitlines())
    assert ret==expected, f"Expected {expected}, got {ret}"

test("""a,b,c
1,2,3
""",  [['a', 'b', 'c'], ['1', '2', '3']])

test("""a,b,c
1,2,"3"
""",  [['a', 'b', 'c'], ['1', '2', '3']])

test("""a,b,c
1,2,"3,,"
""",  [['a', 'b', 'c'], ['1', '2', '3,,']])

test("""a,b,c
1,2,'3'
""",  [['a', 'b', 'c'], ['1', '2', '\'3\'']])

test('''a,b,c
1,2,"123"""
''',  [['a', 'b', 'c'], ['1', '2', '123"']])

test("""a,b,c,
1,2,3,
""",  [['a', 'b', 'c', ''], ['1', '2', '3', '']])

test("""a,b ,c,
1,"22""33",3
""",  [['a', 'b ', 'c', ''], ['1', '22"33', '3']])

# newline
test('''a,b,c
1,2,"3,
  4"
5,"a,""
b",7
''',  [['a', 'b', 'c'], ['1', '2', '3,\n  4'], ['5', 'a,"\nb', '7']])

ret: list[dict] = csv.DictReader("""a,b,c
1,2,3
"4",5,6
""".splitlines())

assert ret==[
    {'a': '1', 'b': '2', 'c': '3'},
    {'a': '4', 'b': '5', 'c': '6'},
]

This upgrade has no break change and it should not break anything.

@nesbox nesbox merged commit 60c45ef into nesbox:main Dec 2, 2023
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[BUG] Memory leak in SStream::str()
2 participants