File: python34.py

package info (click to toggle)
giac 1.9.0.35%2Bdfsg2-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 113,448 kB
  • sloc: cpp: 394,793; ansic: 200,527; python: 30,548; javascript: 28,735; makefile: 8,328; yacc: 2,690; lex: 2,458; sh: 623; perl: 314; lisp: 216; asm: 62; java: 41; xml: 36; sed: 16; csh: 7; pascal: 6
file content (42 lines) | stat: -rw-r--r-- 1,283 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# tests that differ when running under Python 3.4 vs 3.5/3.6/3.7

try:
    exec
except NameError:
    print("SKIP")
    raise SystemExit

# from basics/fun_kwvarargs.py
# test evaluation order of arguments (in 3.4 it's backwards, 3.5 it's fixed)
def f4(*vargs, **kwargs):
    print(vargs, kwargs)
def print_ret(x):
    print(x)
    return x
f4(*print_ret(['a', 'b']), kw_arg=print_ret(None))

# test evaluation order of dictionary key/value pair (in 3.4 it's backwards)
{print_ret(1):print_ret(2)}

# from basics/syntaxerror.py
def test_syntax(code):
    try:
        exec(code)
    except SyntaxError:
        print("SyntaxError")
test_syntax("f(*a, *b)") # can't have multiple * (in 3.5 we can)
test_syntax("f(**a, **b)") # can't have multiple ** (in 3.5 we can)
test_syntax("f(*a, b)") # can't have positional after *
test_syntax("f(**a, b)") # can't have positional after **
test_syntax("() = []") # can't assign to empty tuple (in 3.6 we can)
test_syntax("del ()") # can't delete empty tuple (in 3.6 we can)

# from basics/sys1.py
# uPy prints version 3.4
import sys
print(sys.version[:3])
print(sys.version_info[0], sys.version_info[1])

# from basics/exception1.py
# in 3.7 no comma is printed if there is only 1 arg (in 3.4-3.6 one is printed)
print(repr(IndexError("foo")))