Ticket #5411: 5411-5.diff

File 5411-5.diff, 3.0 KB (added by adiroiban, 17 months ago)
  • twisted/protocols/ftp.py

    diff --git a/twisted/protocols/ftp.py b/twisted/protocols/ftp.py
    index 9f034c0..cbb1621 100644
    a b from zope.interface import Interface, implements 
    2525 
    2626# Twisted Imports 
    2727from twisted import copyright 
    28 from twisted.python.deprecate import warnAboutFunction 
    2928from twisted.internet import reactor, interfaces, protocol, error, defer 
    3029from twisted.protocols import basic, policies 
    3130 
    class FTP(object, basic.LineReceiver, policies.TimeoutMixin): 
    933932        """ 
    934933        Inspect an element from the list returned by an L{IFTPShell.list} 
    935934        implementation to make sure the content is formated to be 
    936         send on the wire.  
     935        send on the wire. 
    937936 
    938937        @param name: The name of a file, as returned by L{IFTPShell.list}. 
    939938        @type name: L{bytes} or L{unicode} 
    class IFTPShell(Interface): 
    15811580        child of the directory. 
    15821581 
    15831582        @param path: The path, as a list of segments, to list 
    1584         @type path: C{list} of C{unicode} 
     1583        @type path: C{list} of C{unicode} or C{bytes} 
    15851584 
    15861585        @param keys: A tuple of keys desired in the resulting 
    15871586        dictionaries. 
    15881587 
    15891588        @return: A Deferred which fires with a list of (name, list), 
    1590         where the name is the name of the entry as a unicode string 
    1591         and each list contains values corresponding to the requested 
     1589        where the name is the name of the entry as a unicode string or 
     1590        bytes and each list contains values corresponding to the requested 
    15921591        keys.  The following are possible elements of keys, and the 
    15931592        values which should be returned for them: 
    15941593 
  • twisted/test/test_ftp.py

    diff --git a/twisted/test/test_ftp.py b/twisted/test/test_ftp.py
    index 6fb7064..1bea121 100644
    a b class FTPServerPasvDataConnectionTestCase(FTPServerTestCase): 
    734734            '0 Jan 01  1970 my resum\xc3\xa9\r\n') 
    735735 
    736736 
     737    def test_LISTNonASCIIBytes(self): 
     738        """ 
     739        Support for returning byte strings from L{IFTPShell.list} is deprecated 
     740        and doing so results in a warning, but in the filename being sent as-is. 
     741        """ 
     742        return self._listTestHelper( 
     743            "LIST", 
     744            ('my resum\xc3\xa9', (0, 1, 0777, 0, 0, 'user', 'group')), 
     745            'drwxrwxrwx   0 user      group                   ' 
     746            '0 Jan 01  1970 my resum\xc3\xa9\r\n') 
     747 
     748 
    737749    def testManyLargeDownloads(self): 
    738750        # Login 
    739751        d = self._anonymousLogin() 
    class FTPServerPasvDataConnectionTestCase(FTPServerTestCase): 
    829841            'my resum\xc3\xa9\r\n') 
    830842 
    831843 
     844    def test_NLSTNonASCIIBytes(self): 
     845        """ 
     846        NLST will just pass the non-Unicode data to lower level. 
     847        """ 
     848        return self._listTestHelper( 
     849            "NLST", 
     850            ('my resum\xc3\xa9', (0, 1, 0777, 0, 0, 'user', 'group')), 
     851            'my resum\xc3\xa9\r\n') 
     852 
     853 
     854 
    832855    def test_NLSTOnPathToFile(self): 
    833856        """ 
    834857        NLST on an existent file returns only the path to that file.