From 0b5c21f9c96e6a0734dd7bcbdeec05500a7baf70 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola' Date: Sat, 7 May 2011 19:03:47 +0200 Subject: #12002 - ftplib's abort() method raises TypeError --- Lib/ftplib.py | 3 ++- Lib/test/test_ftplib.py | 8 ++++++++ Misc/NEWS | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Lib/ftplib.py b/Lib/ftplib.py index ea91c17..af213f3 100644 --- a/Lib/ftplib.py +++ b/Lib/ftplib.py @@ -232,12 +232,13 @@ class FTP: This does not follow the procedure from the RFC to send Telnet IP and Synch; that doesn't seem to work with the servers I've tried. Instead, just send the ABOR command as OOB data.''' - line = 'ABOR' + CRLF + line = b'ABOR' + B_CRLF if self.debugging > 1: print('*put urgent*', self.sanitize(line)) self.sock.sendall(line, MSG_OOB) resp = self.getmultiline() if resp[:3] not in ('426', '225', '226'): raise error_proto(resp) + return resp def sendcmd(self, cmd): '''Send a command and return the response.''' diff --git a/Lib/test/test_ftplib.py b/Lib/test/test_ftplib.py index fa1079f..2b2c4cf 100644 --- a/Lib/test/test_ftplib.py +++ b/Lib/test/test_ftplib.py @@ -42,6 +42,8 @@ class DummyFTPHandler(asynchat.async_chat): def __init__(self, conn): asynchat.async_chat.__init__(self, conn) + # tells the socket to handle urgent data inline (ABOR command) + self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_OOBINLINE, 1) self.set_terminator(b"\r\n") self.in_buffer = [] self.dtp = None @@ -158,6 +160,9 @@ class DummyFTPHandler(asynchat.async_chat): self.push('221 quit ok') self.close() + def cmd_abor(self, arg): + self.push('226 abor ok') + def cmd_stor(self, arg): self.push('125 stor ok') @@ -312,6 +317,9 @@ class TestFTPClass(TestCase): # Ensure the connection gets closed; sock attribute should be None self.assertEqual(self.client.sock, None) + def test_abort(self): + self.client.abort() + def test_retrbinary(self): def callback(data): received.append(data.decode('ascii')) diff --git a/Misc/NEWS b/Misc/NEWS index 5a445ee..751900d 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -37,6 +37,8 @@ Core and Builtins Library ------- +- Issue #12002: ftplib's abort() method raises TypeError. + - Issue #11391: Writing to a mmap object created with ``mmap.PROT_READ|mmap.PROT_EXEC`` would segfault instead of raising a TypeError. Patch by Charles-François Natali. -- cgit v0.12 /table>
path: root/src/tsd.c
blob: 281a2e9be70ebd0c672d9d17c7e4c655630188cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#define	JEMALLOC_TSD_C_
#include "jemalloc/internal/jemalloc_internal.h"

/******************************************************************************/
/* Data. */

static unsigned ncleanups;
static malloc_tsd_cleanup_t cleanups[MALLOC_TSD_CLEANUPS_MAX];

/******************************************************************************/

void *
malloc_tsd_malloc(size_t size)
{

	/* Avoid choose_arena() in order to dodge bootstrapping issues. */
	return arena_malloc(arenas[0], size, false, false);
}

void
malloc_tsd_dalloc(void *wrapper)
{

	idalloc(wrapper);
}

void
malloc_tsd_no_cleanup(void *arg)
{

	not_reached();
}

#ifdef JEMALLOC_MALLOC_THREAD_CLEANUP
JEMALLOC_ATTR(visibility("default"))
void
_malloc_thread_cleanup(void)
{
	bool pending[ncleanups], again;
	unsigned i;

	for (i = 0; i < ncleanups; i++)
		pending[i] = true;

	do {
		again = false;
		for (i = 0; i < ncleanups; i++) {
			if (pending[i]) {
				pending[i] = cleanups[i]();
				if (pending[i])
					again = true;
			}
		}
	} while (again);
}
#endif

void
malloc_tsd_cleanup_register(bool (*f)(void))
{

	assert(ncleanups < MALLOC_TSD_CLEANUPS_MAX);
	cleanups[ncleanups] = f;
	ncleanups++;
}

void
malloc_tsd_boot(void)
{

	ncleanups = 0;
}