Skip to content

Conversation

@max-muoto
Copy link
Contributor

@max-muoto max-muoto commented Jun 16, 2025

Add the following deprecations for 3.14:

  • pathlib.PurePath.as_uri deprecation.
  • pdb.curframe_locals deprecation.
  • asyncio.iscoroutinefunction deprecation.
  • codecs.open deprecation.
  • os.popen and os.spawn* function deprecations.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@max-muoto max-muoto changed the title Add 3.14 deprecations Add 3.14 Deprecations Jun 17, 2025
@max-muoto max-muoto marked this pull request as ready for review June 17, 2025 01:22
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

def as_posix(self) -> str: ...
def as_uri(self) -> str: ...
if sys.version_info >= (3, 14):
@deprecated("PurePath.as_uri() is deprecated. Use Path.as_uri() instead.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's confusing, it's the same method. Also, we don't have an override for Path.as_uri, so people will see this deprecation even if they call the method on a Path.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed the fact that we didn't have an override: 7eccbac

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the exact snippet from the release notes: pathlib.PurePath.as_uri() is deprecated and will be removed in Python 3.19. Use pathlib.Path.as_uri() instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curindex: int
curframe: FrameType | None
curframe_locals: Mapping[str, Any]
if sys.version_info >= (3, 13):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3.13 due as - The low overhead dynamic frame locals access added in Python 3.13 by PEP 667 means the frame locals cache reference previously stored in this attribute is no longer needed. Derived debuggers should access pdb.Pdb.curframe.f_locals directly in Python 3.13 and later versions.

@github-actions

This comment has been minimized.

@srittau
Copy link
Collaborator

srittau commented Jul 7, 2025

It seems that curframe_locals actually does not exist in 3.13, at least according to stubtest. I'm not totally sure what's going on here.

@github-actions

This comment has been minimized.

@srittau
Copy link
Collaborator

srittau commented Jul 7, 2025

@JelleZijlstra CI fails, at the moment, so we shouldn't merge.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@max-muoto
Copy link
Contributor Author

max-muoto commented Jul 13, 2025

@JelleZijlstra @srittau I had to an ignore for curframe_locals as it doesn't always exist at runtime, but CI is passing now.

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good, a few final small suggestions below.

Comment on lines +20 to +29
@deprecated("Deprecated in Python 3.14; use inspect.iscoroutinefunction() instead")
def iscoroutinefunction(func: Callable[..., Coroutine[Any, Any, Any]]) -> bool: ...
@overload
@deprecated("Deprecated in Python 3.14; use inspect.iscoroutinefunction() instead")
def iscoroutinefunction(func: Callable[_P, Awaitable[_T]]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, _T]]]: ...
@overload
@deprecated("Deprecated in Python 3.14; use inspect.iscoroutinefunction() instead")
def iscoroutinefunction(func: Callable[_P, object]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, Any]]]: ...
@overload
@deprecated("Deprecated in Python 3.14; use inspect.iscoroutinefunction() instead")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consideration, in #14074 I'm also unconditionally marking these as deprecated, but @srittau mentionned that

If I understand it correctly, it's sometimes necessary to use this on Python < 3.11, since it supports @coroutine (removed in 3.11), which the inspect version doesn't support.

@max-muoto
Copy link
Contributor Author

@srittau @Avasam Comments addressed.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2025

Diff from mypy_primer, showing the effect of this PR on open source code:

aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/worker.py:73:44: error: overload def (func: def (*Any, **Any) -> typing.Coroutine[Any, Any, Any]) -> builtins.bool of function asyncio.coroutines.iscoroutinefunction is deprecated: Deprecated in Python 3.14; use inspect.iscoroutinefunction() instead  [deprecated]
+ aiohttp/worker.py:73:44: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-deprecated for more info  [deprecated]

trio (https://github.com/python-trio/trio)
+ src/trio/_path.py:258: error: Argument 1 to "as_uri" of "Path" has incompatible type "trio._path.Path"; expected "pathlib.Path"  [arg-type]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants