From 31dd47c0d90c7b131ad58ae87328f0c8eef89812 Mon Sep 17 00:00:00 2001 From: Ryan May Date: Tue, 5 May 2020 00:13:05 -0600 Subject: [PATCH 1/2] Merge pull request #17084 from cbrnr/fix-macosx-segfault Fix macosx segfault --- src/_macosx.m | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/src/_macosx.m b/src/_macosx.m index d3e3995ed308..7edca31a3dfa 100644 --- a/src/_macosx.m +++ b/src/_macosx.m @@ -138,7 +138,6 @@ static int wait_for_stdin(void) } NSEvent* event; - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; while (true) { while (true) { event = [NSApp nextEventMatchingMask: NSAnyEventMask @@ -151,7 +150,6 @@ static int wait_for_stdin(void) CFRunLoopRun(); if (interrupted || CFReadStreamHasBytesAvailable(stream)) break; } - [pool release]; if (py_sigint_handler) PyOS_setsig(SIGINT, py_sigint_handler); CFReadStreamUnscheduleFromRunLoop(stream, @@ -280,7 +278,6 @@ static void lazy_init(void) { PyOS_InputHook = wait_for_stdin; #endif - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; WindowServerConnectionManager* connectionManager = [WindowServerConnectionManager sharedManager]; NSWorkspace* workspace = [NSWorkspace sharedWorkspace]; NSNotificationCenter* notificationCenter = [workspace notificationCenter]; @@ -288,7 +285,6 @@ static void lazy_init(void) { selector: @selector(launch:) name: NSWorkspaceDidLaunchApplicationNotification object: nil]; - [pool release]; } static PyObject* @@ -366,11 +362,7 @@ static CGFloat _get_device_scale(CGContextRef cr) if(view) /* The figure may have been closed already */ { - /* Whereas drawRect creates its own autorelease pool, apparently - * [view display] also needs one. Create and release it here. */ - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; [view display]; - [pool release]; } Py_RETURN_NONE; @@ -546,7 +538,6 @@ static CGFloat _get_device_scale(CGContextRef cr) close(channel[0]); } - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSDate* date = (timeout > 0.0) ? [NSDate dateWithTimeIntervalSinceNow: timeout] : [NSDate distantFuture]; @@ -558,7 +549,6 @@ static CGFloat _get_device_scale(CGContextRef cr) if (!event || [event type]==NSApplicationDefined) break; [NSApp sendEvent: event]; } - [pool release]; if (py_sigint_handler) PyOS_setsig(SIGINT, py_sigint_handler); @@ -731,7 +721,6 @@ static CGFloat _get_device_scale(CGContextRef cr) rect.size.height = height; rect.size.width = width; - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; self->window = [self->window initWithContentRect: rect styleMask: NSTitledWindowMask | NSClosableWindowMask @@ -749,7 +738,6 @@ static CGFloat _get_device_scale(CGContextRef cr) [window makeFirstResponder: view]; [[window contentView] addSubview: view]; - [pool release]; return 0; } @@ -766,9 +754,7 @@ static CGFloat _get_device_scale(CGContextRef cr) Window* window = self->window; if(window) { - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; [window close]; - [pool release]; } Py_TYPE(self)->tp_free((PyObject*)self); } @@ -779,10 +765,8 @@ static CGFloat _get_device_scale(CGContextRef cr) Window* window = self->window; if(window) { - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; [window makeKeyAndOrderFront: nil]; [window orderFrontRegardless]; - [pool release]; } Py_RETURN_NONE; } @@ -793,9 +777,7 @@ static CGFloat _get_device_scale(CGContextRef cr) Window* window = self->window; if(window) { - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; [window close]; - [pool release]; self->window = NULL; } Py_RETURN_NONE; @@ -812,12 +794,10 @@ static CGFloat _get_device_scale(CGContextRef cr) Window* window = self->window; if(window) { - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSString* ns_title = [[[NSString alloc] initWithCString: title encoding: NSUTF8StringEncoding] autorelease]; [window setTitle: ns_title]; - [pool release]; } Py_RETURN_NONE; } @@ -829,13 +809,11 @@ static CGFloat _get_device_scale(CGContextRef cr) PyObject* result = NULL; if(window) { - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSString* title = [window title]; if (title) { const char* cTitle = [title UTF8String]; result = PyUnicode_FromString(cTitle); } - [pool release]; } if (result) { return result; @@ -1164,7 +1142,6 @@ -(void)save_figure:(id)sender if(!PyArg_ParseTuple(args, "s", &basedir)) return -1; - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSRect bounds = [view bounds]; NSWindow* window = [view window]; @@ -1265,8 +1242,6 @@ -(void)save_figure:(id)sender [messagebox release]; [[window contentView] display]; - [pool release]; - self->messagebox = messagebox; return 0; } @@ -1297,10 +1272,9 @@ -(void)save_figure:(id)sender NSText* messagebox = self->messagebox; if (messagebox) - { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + { NSString* text = [NSString stringWithUTF8String: message]; [messagebox setString: text]; - [pool release]; } Py_RETURN_NONE; @@ -2349,14 +2323,12 @@ - (int)index show(PyObject* self) { [NSApp activateIgnoringOtherApps: YES]; - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSArray *windowsArray = [NSApp windows]; NSEnumerator *enumerator = [windowsArray objectEnumerator]; NSWindow *window; while ((window = [enumerator nextObject])) { [window orderFront:nil]; } - [pool release]; Py_BEGIN_ALLOW_THREADS [NSApp run]; Py_END_ALLOW_THREADS From ca714c1fdebfd5876ede84010a2964fed9a134ea Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Wed, 22 Apr 2020 17:04:55 -0400 Subject: [PATCH 2/2] Merge pull request #17210 from anntzer/svgconv Fix missing attribute in _SVGConverter. --- lib/matplotlib/testing/compare.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/testing/compare.py b/lib/matplotlib/testing/compare.py index 022923d67ad0..4159cada94ab 100644 --- a/lib/matplotlib/testing/compare.py +++ b/lib/matplotlib/testing/compare.py @@ -211,9 +211,9 @@ def __call__(self, orig, dest): # Inkscape's output is not localized but gtk's is, so the output # stream probably has a mixed encoding. Using the filesystem # encoding should at least get the filenames right... - self._stderr.seek(0) + self._proc.stderr.seek(0) raise ImageComparisonFailure( - self._stderr.read().decode( + self._proc.stderr.read().decode( sys.getfilesystemencoding(), "replace"))