Compare commits

..

6 Commits

Author SHA1 Message Date
Tom Rothamel f49a04468b Merge pull request #2017 from wchill/py3_ints
[Py3] Make Python 3 integer related changes
2019-10-09 19:30:49 -04:00
Tom Rothamel d337e47e1f Fix changelog. 2019-10-07 21:05:29 -04:00
Eric Ahn f452540ad0 Add version check and define the long type if needed 2019-10-02 16:15:02 -07:00
Eric Ahn 2b65a69611 Import the int builtin as long 2019-10-02 15:48:04 -07:00
Eric Ahn 8c37264d84 Remove long constants and use new octal syntax 2019-10-02 15:40:53 -07:00
Eric Ahn 8ab711722c Fix integer division and remove long type 2019-10-02 15:24:42 -07:00
7 changed files with 42 additions and 31 deletions
+15 -12
View File
@@ -28,10 +28,17 @@ init python in distribute:
import struct
import stat
import shutil
import sys
import threading
from renpy import six
from zipfile import crc32
# Since the long type doesn't exist on py3, define it here
if six.PY3:
long = int
zlib.Z_DEFAULT_COMPRESSION = 5
class ZipFile(zipfile.ZipFile):
@@ -156,9 +163,9 @@ init python in distribute:
zi.create_system = 3
if xbit:
zi.external_attr = long(0100755) << 16
zi.external_attr = long(0o100755) << 16
else:
zi.external_attr = long(0100644) << 16
zi.external_attr = long(0o100644) << 16
self.zipfile.write_with_info(zi, path)
@@ -170,7 +177,7 @@ init python in distribute:
zi.date_time = self.get_date_time(path)
zi.compress_type = zipfile.ZIP_STORED
zi.create_system = 3
zi.external_attr = (long(0040755) << 16) | 0x10
zi.external_attr = (long(0o040755) << 16) | 0x10
self.zipfile.write_with_info(zi, path)
@@ -201,9 +208,9 @@ init python in distribute:
info.type = tarfile.DIRTYPE
if xbit:
info.mode = 0755
info.mode = 0o755
else:
info.mode = 0644
info.mode = 0o644
info.uid = 1000
info.gid = 1000
@@ -267,7 +274,7 @@ init python in distribute:
def mkdir(self, path):
if not os.path.isdir(path):
os.makedirs(path, 0755)
os.makedirs(path, 0o755)
def __init__(self, path):
self.path = path
@@ -282,9 +289,9 @@ init python in distribute:
shutil.copy2(path, fn)
if xbit:
os.chmod(fn, 0755)
os.chmod(fn, 0o755)
else:
os.chmod(fn, 0644)
os.chmod(fn, 0o644)
def add_directory(self, name, path):
fn = os.path.join(self.path, name)
@@ -396,7 +403,3 @@ init python in distribute:
for i in parallel_threads:
if i.done:
i.done()
+18 -11
View File
@@ -55,6 +55,13 @@ import math
import exceptions
import string
import array
from renpy import six
# Since the long type doesn't exist on py3, define it here
if six.PY3:
long = int
sha1, sha256, sha512, md5 = None, None, None, None
@@ -85,8 +92,8 @@ IMAGE_OS2_SIGNATURE_LE = 0x454C
IMAGE_VXD_SIGNATURE = 0x454C
IMAGE_NT_SIGNATURE = 0x00004550
IMAGE_NUMBEROF_DIRECTORY_ENTRIES= 16
IMAGE_ORDINAL_FLAG = 0x80000000L
IMAGE_ORDINAL_FLAG64 = 0x8000000000000000L
IMAGE_ORDINAL_FLAG = 0x80000000
IMAGE_ORDINAL_FLAG64 = long(0x8000000000000000)
OPTIONAL_HEADER_MAGIC_PE = 0x10b
OPTIONAL_HEADER_MAGIC_PE_PLUS = 0x20b
@@ -169,7 +176,7 @@ section_characteristics = [
('IMAGE_SCN_MEM_SHARED', 0x10000000),
('IMAGE_SCN_MEM_EXECUTE', 0x20000000),
('IMAGE_SCN_MEM_READ', 0x40000000),
('IMAGE_SCN_MEM_WRITE', 0x80000000L) ]
('IMAGE_SCN_MEM_WRITE', 0x80000000) ]
SECTION_CHARACTERISTICS = dict([(e[1], e[0]) for e in
section_characteristics]+section_characteristics)
@@ -816,7 +823,7 @@ class Structure:
for key in keys:
val = getattr(self, key)
if isinstance(val, int) or isinstance(val, long):
if isinstance(val, six.integer_types):
val_str = '0x%-8X' % (val)
if key == 'TimeDateStamp' or key == 'dwTimeStamp':
try:
@@ -1557,7 +1564,7 @@ class PE:
'Normal values are never larger than 0x10, the value is: 0x%x' %
self.OPTIONAL_HEADER.NumberOfRvaAndSizes )
for i in xrange(int(0x7fffffffL & self.OPTIONAL_HEADER.NumberOfRvaAndSizes)):
for i in xrange(int(0x7fffffff & self.OPTIONAL_HEADER.NumberOfRvaAndSizes)):
if len(self.__data__[offset:]) == 0:
break
@@ -2355,13 +2362,13 @@ class PE:
return None
#resource.NameIsString = (resource.Name & 0x80000000L) >> 31
resource.NameOffset = resource.Name & 0x7FFFFFFFL
resource.NameOffset = resource.Name & 0x7FFFFFFF
resource.__pad = resource.Name & 0xFFFF0000L
resource.Id = resource.Name & 0x0000FFFFL
resource.__pad = resource.Name & 0xFFFF0000
resource.Id = resource.Name & 0x0000FFFF
resource.DataIsDirectory = (resource.OffsetToData & 0x80000000L) >> 31
resource.OffsetToDirectory = resource.OffsetToData & 0x7FFFFFFFL
resource.DataIsDirectory = (resource.OffsetToData & 0x80000000) >> 31
resource.OffsetToDirectory = resource.OffsetToData & 0x7FFFFFFF
return resource
@@ -2683,7 +2690,7 @@ class PE:
raw_data[varword_offset+2:varword_offset+4], 0)
varword_offset += 4
if isinstance(word1, (int, long)) and isinstance(word1, (int, long)):
if isinstance(word1, six.integer_types):
var_struct.entry = {var_string: '0x%04x 0x%04x' % (word1, word2)}
var_offset = self.dword_align(
+3 -3
View File
@@ -835,9 +835,9 @@ init -1500 python in updater:
info.gname = "renpy"
if xbit or directory:
info.mode = 0777
info.mode = 0o777
else:
info.mode = 0666
info.mode = 0o666
if info.isreg():
with open(path, "rb") as f:
@@ -1090,7 +1090,7 @@ init -1500 python in updater:
umask = os.umask(0)
os.umask(umask)
os.chmod(new_path, 0777 & (~umask))
os.chmod(new_path, 0o777 & (~umask))
except:
pass
+1 -1
View File
@@ -229,7 +229,7 @@ def get_ordered_image_attributes(tag, attributes=(), sort=None):
for attr in attrcount:
if attr not in rv:
l.append((attrtotalpos[attr] / attrcount[attr], sort(attr), attr))
l.append((attrtotalpos[attr] // attrcount[attr], sort(attr), attr))
l.sort()
for i in l:
+2 -2
View File
@@ -310,11 +310,11 @@ def draw_special(what, dest, x, y):
ramp = "\x00" * 256
for i in xrange(0, ramplen):
ramp += chr(255 * i / ramplen)
ramp += chr(255 * i // ramplen)
ramp += "\xff" * 256
step = int( what.operation_complete * (256 + ramplen) )
step = int(what.operation_complete * (256 + ramplen))
ramp = ramp[step:step+256]
renpy.display.module.imageblend(
+1 -1
View File
@@ -116,7 +116,7 @@ def save_dump(roots, log):
size = 1
elif isinstance(o, (str, unicode)):
size = len(o) / 40 + 1
size = len(o) // 40 + 1
elif isinstance(o, (tuple, list)):
size = 1
+2 -1
View File
@@ -25,7 +25,8 @@ Dynamic images can now include "[prefix_]" everywhere, and especially when
``add`` has been used to add a dynamic image to buttons, drags, and similar
focusable objects.
Creator-defined statements may now take if statements as children.
Creator-defined screen language statements may now take ``if``
statements as children.
The drag and drop system has been improved to better interact with updated
screens.