Skip to content

Commit

Permalink
devel/py-paver: Fix build with setuptools 58.0.0+
Browse files Browse the repository at this point in the history
With  hat:	python
  • Loading branch information
sunpoet committed Mar 7, 2022
1 parent 3147872 commit 013e70f
Showing 1 changed file with 201 additions and 0 deletions.
201 changes: 201 additions & 0 deletions devel/py-paver/files/patch-2to3
@@ -0,0 +1,201 @@
--- paver/deps/path2.py.orig 2014-07-16 12:48:36 UTC
+++ paver/deps/path2.py
@@ -39,10 +39,10 @@ for f in d.files('*.py'):
This module requires Python 2.3 or later.
"""

-from __future__ import generators

-import __builtin__

+import builtins
+
import sys
import warnings
import os
@@ -75,16 +75,16 @@ _base = str
_getcwd = os.getcwd
try:
if os.path.supports_unicode_filenames:
- _base = unicode
- _getcwd = os.getcwdu
+ _base = str
+ _getcwd = os.getcwd
except AttributeError:
pass

# Pre-2.3 workaround for basestring.
try:
- basestring
+ str
except NameError:
- basestring = (str, unicode)
+ str = (str, str)

# Universal newline support
_textmode = 'U'
@@ -116,7 +116,7 @@ class path(_base):
# On python 2, unicode result breaks os.path.join
# if we are inheriting from str
# see https://github.com/paver/paver/issues/78
- if isinstance(resultStr, unicode) and not os.path.supports_unicode_filenames:
+ if isinstance(resultStr, str) and not os.path.supports_unicode_filenames:
resultStr = resultStr.encode('utf-8')

if resultStr is NotImplemented:
@@ -124,7 +124,7 @@ class path(_base):
return self.__class__(resultStr)

def __radd__(self, other):
- if isinstance(other, basestring):
+ if isinstance(other, str):
return self.__class__(other.__add__(self))
else:
return NotImplemented
@@ -604,11 +604,11 @@ class path(_base):
t = f.read()
finally:
f.close()
- return (t.replace(u'\r\n', u'\n')
- .replace(u'\r\x85', u'\n')
- .replace(u'\r', u'\n')
- .replace(u'\x85', u'\n')
- .replace(u'\u2028', u'\n'))
+ return (t.replace('\r\n', '\n')
+ .replace('\r\x85', '\n')
+ .replace('\r', '\n')
+ .replace('\x85', '\n')
+ .replace('\u2028', '\n'))

def write_text(self, text, encoding=None, errors='strict', linesep=os.linesep, append=False):
r""" Write the given text to this file.
@@ -674,16 +674,16 @@ class path(_base):
conversion.

"""
- if isinstance(text, unicode):
+ if isinstance(text, str):
if linesep is not None:
# Convert all standard end-of-line sequences to
# ordinary newline characters.
- text = (text.replace(u'\r\n', u'\n')
- .replace(u'\r\x85', u'\n')
- .replace(u'\r', u'\n')
- .replace(u'\x85', u'\n')
- .replace(u'\u2028', u'\n'))
- text = text.replace(u'\n', linesep)
+ text = (text.replace('\r\n', '\n')
+ .replace('\r\x85', '\n')
+ .replace('\r', '\n')
+ .replace('\x85', '\n')
+ .replace('\u2028', '\n'))
+ text = text.replace('\n', linesep)
if encoding is None:
encoding = sys.getdefaultencoding()
bytes = text.encode(encoding, errors)
@@ -766,15 +766,15 @@ class path(_base):
f = self.open(mode)
try:
for line in lines:
- isUnicode = isinstance(line, unicode)
+ isUnicode = isinstance(line, str)
if linesep is not None:
# Strip off any existing line-end and add the
# specified linesep string.
if isUnicode:
- if line[-2:] in (u'\r\n', u'\x0d\x85'):
+ if line[-2:] in ('\r\n', '\x0d\x85'):
line = line[:-2]
- elif line[-1:] in (u'\r', u'\n',
- u'\x85', u'\u2028'):
+ elif line[-1:] in ('\r', '\n',
+ '\x85', '\u2028'):
line = line[:-1]
else:
if line[-2:] == '\r\n':
@@ -893,7 +893,7 @@ class path(_base):
self, win32security.OWNER_SECURITY_INFORMATION)
sid = desc.GetSecurityDescriptorOwner()
account, domain, typecode = win32security.LookupAccountSid(None, sid)
- return domain + u'\\' + account
+ return domain + '\\' + account
else:
if pwd is None:
raise NotImplementedError("path.owner is not implemented on this platform.")
@@ -936,25 +936,25 @@ class path(_base):
#
# --- Create/delete operations on directories

- def mkdir(self, mode=0777):
+ def mkdir(self, mode=0o777):
if not self.exists():
os.mkdir(self, mode)

- def mkdir_p(self, mode=0777):
+ def mkdir_p(self, mode=0o777):
try:
self.mkdir(mode)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.EEXIST:
raise

- def makedirs(self, mode=0777):
+ def makedirs(self, mode=0o777):
if not self.exists():
os.makedirs(self, mode)

- def makedirs_p(self, mode=0777):
+ def makedirs_p(self, mode=0o777):
try:
self.makedirs(mode)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.EEXIST:
raise

@@ -965,7 +965,7 @@ class path(_base):
def rmdir_p(self):
try:
self.rmdir()
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOTEMPTY and e.errno != errno.EEXIST:
raise

@@ -976,7 +976,7 @@ class path(_base):
def removedirs_p(self):
try:
self.removedirs()
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOTEMPTY and e.errno != errno.EEXIST:
raise

@@ -986,7 +986,7 @@ class path(_base):
""" Set the access/modified times of this file to the current time.
Create the file if it does not exist.
"""
- fd = os.open(self, os.O_WRONLY | os.O_CREAT, 0666)
+ fd = os.open(self, os.O_WRONLY | os.O_CREAT, 0o666)
os.close(fd)
os.utime(self, None)

@@ -997,7 +997,7 @@ class path(_base):
def remove_p(self):
try:
self.unlink()
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOENT:
raise

@@ -1058,7 +1058,7 @@ class path(_base):
def rmtree_p(self):
try:
self.rmtree()
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOENT:
raise

0 comments on commit 013e70f

Please sign in to comment.