Skip to content

Commit

Permalink
Merge branch 'master' into fix_cpp_locals_test_setup
Browse files Browse the repository at this point in the history
  • Loading branch information
da-woods authored Sep 14, 2024
2 parents cbee790 + 094d404 commit 41d5156
Show file tree
Hide file tree
Showing 108 changed files with 1,993 additions and 1,677 deletions.
54 changes: 49 additions & 5 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ Features added
https://github.com/cython/cython/issues?q=label%3A"nogil+CPython"
Patches by Lysandros Nikolaou and Nathan Goldbaum. (Github issue :issue:`6162`)

* Support for monitoring Cython modules via `sys.monitoring` in CPython 3.13+ was added.
For coverage reporting, this needs to be disabled with `-DCYTHON_USE_SYS_MONITORING=0`
as long as `coverage.py` does not support `sys.monitoring` for coverage plugins.
(Github issue :issue:`6144`)

* Many issues with the Limited C-API were resolved.
It is now sufficient to define the macro ``Py_LIMITED_API`` to activate the support.
https://github.com/cython/cython/issues?q=label%3A%22limited+api%22
Expand All @@ -39,14 +44,17 @@ Features added
* Most builtin methods now provide their return type for type inference.
(Github issues :issue:`4829`, :issue:`5865`)

* Method calls on builtin literal values are evaluated at compile time, if applicable.
(Github issue :issue:`6383`)

* The Python ``int`` type now maps directly to ``PyLong`` and is inferred accordingly.
(Github issue :issue:`4237`)

* Integer operations on known ``int`` types are faster.
(Github issue :issue:`5785`)

* f-strings are slightly faster.
(Github issue :issue:`5866`)
* f-strings are faster in some cases.
(Github issues :issue:`5866`, :issue:`6342`, :issue:`6383`)

* ``divmod()`` is faster on C integers.
Patch by Tong He. (Github issue :issue:`6073`)
Expand Down Expand Up @@ -91,6 +99,11 @@ Features added
Bugs fixed
----------

* C functions used different start lines and columns for error reporting and tracing
than Python functions. They now use the line and column of their first decorator
or (if none) their definition line, as in Python.
(Github issue :issue:`6366`)

* Dataclasses did not handle default fields without init value correctly.
(Github issue :issue:`5858`)

Expand All @@ -100,6 +113,9 @@ Bugs fixed
* The ``__class__`` cell variable in methods was not always working as in Python.
Initial patch by Tom Keefe. (Github issue :issue:`2912`)

* Subtyping `complex` as extension type could fail.
(Github issue :issue:`6346`)

* ``hasattr()`` now propagates exceptions that occur during lookup.
(Github issue :issue:`6269`)

Expand All @@ -113,6 +129,13 @@ Bugs fixed
due to differences in the builtins.
(Github issue :issue:`5591`)

* The `common_include_dir` feature used different file paths in the C code on Windows and Posix.
It now uses forward slashes as directory separator consistently.
(Github issue :issue:`6355`)

* File paths in the C code are now relative to the build directory.
Patch by Oscar Benjamin. (Github issue :issue:`6341`)

* The ``-a`` option in the IPython magic no longer copies the complete HTML document
into the notebook but only a more reasonable content snippet.
Patch by Min RK. (Github issue :issue:`5760`)
Expand All @@ -139,14 +162,18 @@ Bugs fixed
* Exporting C functions uses better platform compatible code.
(Github issue :issue:`4683`)

* Cython now uses `SHA-256` instead of `SHA-1` for caching etc. as the latter may not be
available on all Python installations.
(Github issue :issue:`6354`)

Other changes
-------------

* Support for Python 2.7 - 3.6 was removed, along with large chunks of legacy code.
(Github issue :issue:`2800`)

* The pxd files ``cpython.int``, ``cpython.cobject`` and ``cpython.oldbuffer`` were
removed as they refer to C-API declarations that are only in Python 2.x.
* The pxd files ``cpython.int``, ``cpython.cobject``, ``cpython.oldbuffer`` and ``cpython.string``
were removed as they refer to C-API declarations that are only in Python 2.x.
(Github issue :issue:`5870`)

* The generated C code now requires a C99 compatible C compiler.
Expand All @@ -155,6 +182,10 @@ Other changes
``language_level=3str`` has become a legacy alias.
(Github issue :issue:`5827`)

* The Py2 types ``unicode`` and ``basestring`` are now deprecated and have become aliases
of the ``str`` type.
(Github issue :issue:`6374`)

* Docstrings now strip their leading whitespace according to PEP-257.
Patch by Lawrence Mitchell. (Github issue :issue:`6241`)

Expand All @@ -180,7 +211,20 @@ Other changes
and users should migrate to using the two C macros only.
(Github issue :issue:`6036`)

* Includes all fixes as of Cython 3.0.11 (but generates C99 code in some places).
* Includes all fixes as of Cython 3.0.12 (but generates C99 code in some places).


3.0.12 (2024-??-??)
===================

Bugs fixed
----------

* Fused ctuples with the same entry types but different sizes could fail to compile.
(Github issue :issue:`6328`)

* In Py3, `pyximport` was not searching `sys.path` when looking for importable source files.
(Github issue :issue:`5615`)


3.0.11 (2024-08-05)
Expand Down
4 changes: 2 additions & 2 deletions Cython/Build/Tests/TestCythonizeArgsParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ def test_directives_types(self):
options, args = self.parse_args(['-X', cmd])
self.assertFalse(args)
self.assertTrue(self.are_default(options, ['directives']), msg = "Error for option: "+cmd)
if value == 'str':
value = 'unicode'
if value == 'unicode':
value = 'str'
self.assertEqual(options.directives[key], value, msg = "Error for option: "+cmd)

def test_directives_wrong(self):
Expand Down
18 changes: 5 additions & 13 deletions Cython/CodeWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,8 @@ def comma_separated_list(self, items):
def visit_Node(self, node):
raise AssertionError("Node not handled by serializer: %r" % node)

# TODO: Remove redundancy below. Most constants serialise fine as just "repr(node.value)".

def visit_IntNode(self, node):
self.put(node.value)

Expand All @@ -532,23 +534,13 @@ def visit_ConstNode(self, node):
self.put(str(node.value))

def visit_ImagNode(self, node):
self.put(node.value)
self.put("j")

def emit_string(self, node, prefix=""):
repr_val = repr(node.value)
if repr_val[0] in 'ub':
repr_val = repr_val[1:]
self.put("%s%s" % (prefix, repr_val))
self.put(f"{node.value}j")

def visit_BytesNode(self, node):
self.emit_string(node, "b")

def visit_StringNode(self, node):
self.emit_string(node)
self.put(repr(node.value))

def visit_UnicodeNode(self, node):
self.emit_string(node, "u")
self.put(repr(node.value))

def emit_sequence(self, node, parens=("", "")):
open_paren, close_paren = parens
Expand Down
4 changes: 2 additions & 2 deletions Cython/Compiler/AnalysedTreeTransforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def visit_ModuleNode(self, node):

def add_test(self, testpos, path, doctest):
pos = self.testspos
keystr = '%s (line %d)' % (path, testpos[1])
key = UnicodeNode(pos, value=EncodedString(keystr))
keystr = EncodedString(f'{path} (line {testpos[1]:d})')
key = UnicodeNode(pos, value=keystr)
value = UnicodeNode(pos, value=doctest)
self.tests.append(DictItemNode(pos, key=key, value=value))

Expand Down
7 changes: 1 addition & 6 deletions Cython/Compiler/AutoDocTransforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,8 @@ def visit_LambdaNode(self, node):
"Failed to convert lambda to string representation in {}".format(
self.description), level=1)

def visit_UnicodeNode(self, node):
# Discard Unicode prefix in annotations. Any tool looking at them
# would probably expect Py3 string semantics.
self.emit_string(node, "")

def visit_AnnotationNode(self, node):
self.put(node.string.unicode_value)
self.put(node.string.value)


class EmbedSignature(CythonTransform):
Expand Down
Loading

0 comments on commit 41d5156

Please sign in to comment.