Skip to content

Commit 34b4c6a

Browse files
committed
Merge branch 'master'
2 parents 03330a3 + f2626ee commit 34b4c6a

File tree

117 files changed

+4157
-405
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+4157
-405
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ language runtime. The main focus is on user-observable behavior of the engine.
99
* New parser generated from CPython's new PEG grammar definition. It brings better compatibility and enables us to implement the `ast` module.
1010
* Added support for tracing API (`sys.settrace`) which makes `pdb` and related tools work on GraalPy.
1111
* Updated our pip support to automatically choose the best version for known packages. You can use `pip install pandas`, and pip will select the versions of pandas and numpy that we test in the GraalPy CI.
12+
* Added support for Flask - https://pypi.org/project/Flask/
1213

1314
## Version 22.2.0
1415
* Updated to HPy version 0.0.4, which adds support for the finished HPy port of Kiwi, and the in-progress ports of Matplotlib and NumPy.

ci.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "overlay": "55b5a0614a8d46864bb0197b92d2e20033e58ed7" }
1+
{ "overlay": "2cd069137637587d926bf791fd2003912df2368b" }

docs/user/Tooling.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ For example, it does not currently track calls, only line counts and called func
3939
The `_lsprof` built-in module has been implemented using the GraalVM `cpusampler` tool.
4040
Not all profiling features are currently supported, but basic profiling works:
4141
```shell
42-
graalpy -m cProfile -s sort -m ginstall --help
42+
graalpy -m cProfile -s calls -m ginstall --help
4343
```
4444

4545
The interactive exploration of a stats output file also works:
@@ -50,3 +50,24 @@ ginstall.profile%
5050
callers
5151
[...]
5252
```
53+
54+
The profile module works as well:
55+
```shell
56+
graalpy -m profile -s calls -m ginstall --help
57+
```
58+
or
59+
```shell
60+
>>> import profile
61+
>>> profile.run('l = []; l.append(1)')
62+
5 function calls in 0.002 seconds
63+
64+
Ordered by: standard name
65+
66+
ncalls tottime percall cumtime percall filename:lineno(function)
67+
1 0.000 0.000 0.000 0.000 :0(_setprofile)
68+
1 0.000 0.000 0.000 0.000 :0(append)
69+
1 0.000 0.000 0.001 0.001 :0(exec)
70+
1 0.000 0.000 0.000 0.000 <string>:1(<module>)
71+
1 0.001 0.001 0.002 0.002 profile:0(l = []; l.append(1))
72+
0 0.000 0.000 profile:0(profiler)
73+
```

graalpython/com.oracle.graal.python.cext/include/boolobject.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
1+
/* Copyright (c) 2018, 2022, Oracle and/or its affiliates.
22
* Copyright (C) 1996-2017 Python Software Foundation
33
*
44
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
@@ -20,11 +20,14 @@ PyAPI_DATA(PyTypeObject) PyBool_Type;
2020
Don't forget to apply Py_INCREF() when returning either!!! */
2121

2222
/* Don't use these directly */
23-
PyAPI_DATA(struct _longobject) _Py_FalseStruct, _Py_TrueStruct;
23+
PyAPI_DATA(struct _longobject*) _Py_FalseStructReference;
24+
PyAPI_DATA(struct _longobject*) _Py_TrueStructReference;
25+
#define _Py_TrueStruct (*_Py_TrueStructReference)
26+
#define _Py_FalseStruct (*_Py_FalseStructReference)
2427

2528
/* Use these macros */
26-
#define Py_False ((PyObject *) &_Py_FalseStruct)
27-
#define Py_True ((PyObject *) &_Py_TrueStruct)
29+
#define Py_False ((PyObject *) _Py_FalseStructReference)
30+
#define Py_True ((PyObject *) _Py_TrueStructReference)
2831

2932
/* Macros for returning Py_True or Py_False, respectively */
3033
#define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True

graalpython/com.oracle.graal.python.cext/include/classobject.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
1+
/* Copyright (c) 2018, 2022, Oracle and/or its affiliates.
22
* Copyright (C) 1996-2020 Python Software Foundation
33
*
44
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
@@ -24,7 +24,7 @@ typedef struct {
2424

2525
PyAPI_DATA(PyTypeObject) PyMethod_Type;
2626

27-
#define PyMethod_Check(op) ((op)->ob_type == &PyMethod_Type)
27+
#define PyMethod_Check(op) (Py_TYPE(op) == &PyMethod_Type)
2828

2929
PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *);
3030

@@ -47,7 +47,7 @@ typedef struct {
4747

4848
PyAPI_DATA(PyTypeObject) PyInstanceMethod_Type;
4949

50-
#define PyInstanceMethod_Check(op) ((op)->ob_type == &PyInstanceMethod_Type)
50+
#define PyInstanceMethod_Check(op) (Py_TYPE(op) == &PyInstanceMethod_Type)
5151

5252
PyAPI_FUNC(PyObject *) PyInstanceMethod_New(PyObject *);
5353
PyAPI_FUNC(PyObject *) PyInstanceMethod_Function(PyObject *);

graalpython/com.oracle.graal.python.cext/include/cpython/abstract.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2020, 2021, Oracle and/or its affiliates.
1+
/* Copyright (c) 2020, 2022, Oracle and/or its affiliates.
22
* Copyright (C) 1996-2020 Python Software Foundation
33
*
44
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
@@ -130,7 +130,7 @@ _PyObject_Vectorcall(PyObject *callable, PyObject *const *args,
130130
return _PyObject_MakeTpCall(callable, args, nargs, kwnames);
131131
}
132132
res = func(callable, args, nargsf, kwnames);
133-
return _Py_CheckFunctionResult(callable, res, NULL);
133+
return res; // _Py_CheckFunctionResult(callable, res, NULL);
134134
}
135135

136136
/* Same as _PyObject_Vectorcall except that keyword arguments are passed as
@@ -197,8 +197,8 @@ PyAPI_FUNC(Py_ssize_t) PyObject_LengthHint(PyObject *o, Py_ssize_t);
197197

198198
/* Return 1 if the getbuffer function is available, otherwise return 0. */
199199
#define PyObject_CheckBuffer(obj) \
200-
(((obj)->ob_type->tp_as_buffer != NULL) && \
201-
((obj)->ob_type->tp_as_buffer->bf_getbuffer != NULL))
200+
((Py_TYPE(obj)->tp_as_buffer != NULL) && \
201+
(Py_TYPE(obj)->tp_as_buffer->bf_getbuffer != NULL))
202202

203203
/* This is a C-API version of the getbuffer function call. It checks
204204
to make sure object has the required function pointer and issues the
@@ -266,14 +266,14 @@ PyAPI_FUNC(void) PyBuffer_Release(Py_buffer *view);
266266
/* ==== Iterators ================================================ */
267267

268268
#define PyIter_Check(obj) \
269-
((obj)->ob_type->tp_iternext != NULL && \
270-
(obj)->ob_type->tp_iternext != &_PyObject_NextNotImplemented)
269+
(Py_TYPE(obj)->tp_iternext != NULL && \
270+
Py_TYPE(obj)->tp_iternext != &_PyObject_NextNotImplemented)
271271

272272
/* === Number Protocol ================================================== */
273273

274274
#define PyIndex_Check(obj) \
275-
((obj)->ob_type->tp_as_number != NULL && \
276-
(obj)->ob_type->tp_as_number->nb_index != NULL)
275+
(Py_TYPE(obj)->tp_as_number != NULL && \
276+
Py_TYPE(obj)->tp_as_number->nb_index != NULL)
277277

278278
/* === Sequence protocol ================================================ */
279279

graalpython/com.oracle.graal.python.cext/include/object.h

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
1+
/* Copyright (c) 2018, 2022, Oracle and/or its affiliates.
22
* Copyright (C) 1996-2020 Python Software Foundation
33
*
44
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
@@ -123,9 +123,22 @@ typedef struct {
123123
/* Cast argument to PyVarObject* type. */
124124
#define _PyVarObject_CAST(op) ((PyVarObject*)(op))
125125

126-
#define Py_REFCNT(ob) (_PyObject_CAST(ob)->ob_refcnt)
127-
#define Py_TYPE(ob) (_PyObject_CAST(ob)->ob_type)
128-
#define Py_SIZE(ob) (_PyVarObject_CAST(ob)->ob_size)
126+
PyAPI_FUNC(Py_ssize_t) _Py_REFCNT(PyObject *);
127+
PyAPI_FUNC(void) _Py_SET_REFCNT(PyObject*, Py_ssize_t);
128+
PyAPI_FUNC(struct _typeobject*) _Py_TYPE(PyObject *);
129+
PyAPI_FUNC(void) _Py_SET_TYPE(PyObject *, struct _typeobject *);
130+
PyAPI_FUNC(Py_ssize_t) _Py_SIZE(PyVarObject *);
131+
PyAPI_FUNC(void) _Py_SET_SIZE(PyVarObject *, Py_ssize_t);
132+
133+
#define Py_REFCNT(ob) (_Py_REFCNT(_PyObject_CAST(ob)))
134+
#define Py_SET_REFCNT(ob, v) (_Py_SET_REFCNT(_PyObject_CAST(ob), v))
135+
#define Py_TYPE(ob) (_Py_TYPE(_PyObject_CAST(ob)))
136+
#define Py_SIZE(ob) (_Py_SIZE(_PyVarObject_CAST(ob)))
137+
138+
#define Py_SET_TYPE(ob, v) (_Py_SET_TYPE(_PyObject_CAST(ob), (struct _typeobject *) v))
139+
#define Py_SET_SIZE(ob, v) (_Py_SET_SIZE(_PyVarObject_CAST(ob), (Py_ssize_t) v))
140+
141+
#define Py_IS_TYPE(ob, type) (Py_TYPE(ob) == (type))
129142

130143
/*
131144
Type objects contain a string containing the type name (to help somewhat
@@ -445,7 +458,7 @@ static inline void _Py_NewReference(PyObject *op)
445458
}
446459
_Py_INC_TPALLOCS(op);
447460
_Py_INC_REFTOTAL;
448-
Py_REFCNT(op) = 1;
461+
Py_SET_REFCNT(op, 1);
449462
}
450463

451464
static inline void _Py_ForgetReference(PyObject *op)
@@ -562,8 +575,9 @@ where NULL (nil) is not suitable (since NULL often means 'error').
562575
563576
Don't forget to apply Py_INCREF() when returning this value!!!
564577
*/
565-
PyAPI_DATA(PyObject) _Py_NoneStruct; /* Don't use this directly */
566-
#define Py_None (&_Py_NoneStruct)
578+
PyAPI_DATA(PyObject*) _Py_NoneStructReference; /* Don't use this directly */
579+
#define _Py_NoneStruct (*_Py_NoneStructReference)
580+
#define Py_None (_Py_NoneStructReference)
567581

568582
/* Macro for returning Py_None from a function */
569583
#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
@@ -572,8 +586,9 @@ PyAPI_DATA(PyObject) _Py_NoneStruct; /* Don't use this directly */
572586
Py_NotImplemented is a singleton used to signal that an operation is
573587
not implemented for a given type combination.
574588
*/
575-
PyAPI_DATA(PyObject) _Py_NotImplementedStruct; /* Don't use this directly */
576-
#define Py_NotImplemented (&_Py_NotImplementedStruct)
589+
PyAPI_DATA(PyObject*) _Py_NotImplementedStructReference; /* Don't use this directly */
590+
#define _Py_NotImplementedStruct (*_Py_NotImplementedStructReference)
591+
#define Py_NotImplemented (_Py_NotImplementedStructReference)
577592

578593
/* Macro for returning Py_NotImplemented from a function */
579594
#define Py_RETURN_NOTIMPLEMENTED \

graalpython/com.oracle.graal.python.cext/include/objimpl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
1+
/* Copyright (c) 2018, 2022, Oracle and/or its affiliates.
22
* Copyright (C) 1996-2020 Python Software Foundation
33
*
44
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
@@ -142,7 +142,7 @@ static inline PyObject*
142142
_PyObject_INIT(PyObject *op, PyTypeObject *typeobj)
143143
{
144144
assert(op != NULL);
145-
Py_TYPE(op) = typeobj;
145+
Py_SET_TYPE(op, typeobj);
146146
if (PyType_GetFlags(typeobj) & Py_TPFLAGS_HEAPTYPE) {
147147
Py_INCREF(typeobj);
148148
}
@@ -157,7 +157,7 @@ static inline PyVarObject*
157157
_PyObject_INIT_VAR(PyVarObject *op, PyTypeObject *typeobj, Py_ssize_t size)
158158
{
159159
assert(op != NULL);
160-
Py_SIZE(op) = size;
160+
Py_SET_SIZE(op, size);
161161
PyObject_INIT((PyObject *)op, typeobj);
162162
return op;
163163
}

graalpython/com.oracle.graal.python.cext/include/pycapsule.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
1+
/* Copyright (c) 2018, 2022, Oracle and/or its affiliates.
22
* Copyright (C) 1996-2017 Python Software Foundation
33
*
44
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
@@ -22,7 +22,8 @@
2222
extern "C" {
2323
#endif
2424

25-
PyAPI_DATA(PyTypeObject) PyCapsule_Type;
25+
PyAPI_DATA(PyTypeObject*) PyCapsule_TypeReference;
26+
#define PyCapsule_Type (*PyCapsule_TypeReference)
2627

2728
typedef void (*PyCapsule_Destructor)(PyObject *);
2829

graalpython/com.oracle.graal.python.cext/include/pyerrors.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
1+
/* Copyright (c) 2018, 2022, Oracle and/or its affiliates.
22
* Copyright (C) 1996-2020 Python Software Foundation
33
*
44
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
@@ -59,11 +59,11 @@ PyAPI_FUNC(void) PyException_SetContext(PyObject *, PyObject *);
5959
PyType_FastSubclass((PyTypeObject*)(x), Py_TPFLAGS_BASE_EXC_SUBCLASS))
6060

6161
#define PyExceptionInstance_Check(x) \
62-
PyType_FastSubclass((x)->ob_type, Py_TPFLAGS_BASE_EXC_SUBCLASS)
62+
PyType_FastSubclass(Py_TYPE(x), Py_TPFLAGS_BASE_EXC_SUBCLASS)
6363

6464
PyAPI_FUNC(const char *) PyExceptionClass_Name(PyObject *);
6565

66-
#define PyExceptionInstance_Class(x) ((PyObject*)((x)->ob_type))
66+
#define PyExceptionInstance_Class(x) ((PyObject*)(Py_TYPE(x)))
6767

6868

6969
/* Predefined exceptions */

0 commit comments

Comments
 (0)