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

Fix matplotlib backend computation #1811

Merged
merged 2 commits into from
Jan 15, 2025

Conversation

rchiodo
Copy link
Contributor

@rchiodo rchiodo commented Jan 15, 2025

Addresses #1633

Matplotlib in 3.9 changed how they identify their backend to not be case sensitive anymore. They were always returning a lower case backend name.

Our internal code relies on the casing to find the appropriate gui. I modified the code to turn the non cased version into the cased version so the rest of our code works again.

Tested with Matplotlib 3.10 and 3.8

While running pydevd tests also noticed a problem with the fix I made for just my code. Fixed that fix as well so that all the pydevd tests pass again and the just my code fix still applies.

@rchiodo rchiodo requested a review from a team as a code owner January 15, 2025 00:05
@rchiodo
Copy link
Contributor Author

rchiodo commented Jan 15, 2025

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -624,10 +624,10 @@ def _get_func_code_info(code_obj, frame_or_depth) -> FuncCodeInfo:
frame = frame_or_depth
assert frame.f_code is code_obj

func_code_info.filtered_out_force_checked = py_db.apply_files_filter(frame, func_code_info.abs_path_filename, py_db.get_use_libraries_filter())
func_code_info.filtered_out_force_checked = py_db.apply_files_filter(frame, func_code_info.abs_path_filename, True)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This needs to be True as this flag is used elsewhere. However always_filtered_out should be determined by whether or not the file is filtered (which it isn't when justMyCode = false)

@@ -1163,7 +1163,7 @@ def _return_event(code, instruction, retval):
or (
info.pydev_step_cmd == CMD_STEP_INTO_MY_CODE
and frame.f_back is not None
and not py_db.apply_files_filter(frame.f_back, frame.f_back.f_code.co_filename, py_db.get_use_libraries_filter())
and not py_db.apply_files_filter(frame.f_back, frame.f_back.f_code.co_filename, True)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This needed to go back to true. My original change was incorrect.


if py_db.is_files_filter_enabled:
func_code_info.always_filtered_out = func_code_info.filtered_out_force_checked
func_code_info.always_filtered_out = py_db.apply_files_filter(frame, func_code_info.abs_path_filename, False)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

always_filtered_out needs to recheck that the file is actually always filtered out. justMyCode would have to be true or it would have to match the exclusion filters if it's not in the user's project.


# Translate to the real case as in 3.9 the case was forced to lowercase
# but our internal mapping is in the original case.
realcase_backend = lowercase_convert.get(backend, backend)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is what fixes the problem with matplotlib 3.9 and above.

@rchiodo rchiodo merged commit 40a471e into microsoft:main Jan 15, 2025
22 of 24 checks passed
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.

2 participants