Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4a52521

Browse files
authored
Merge pull request #15448 from tacaswell/v22x_py38_compat
V22x py38 compat
2 parents 126e13b + c864b7b commit 4a52521

17 files changed

+80
-72
lines changed

lib/matplotlib/backends/backend_qt5agg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def paintEvent(self, e):
6868
if hasattr(qimage, 'setDevicePixelRatio'):
6969
# Not available on Qt4 or some older Qt5.
7070
qimage.setDevicePixelRatio(self._dpi_ratio)
71-
origin = QtCore.QPoint(l, self.renderer.height - t)
71+
origin = QtCore.QPoint(int(l), int(self.renderer.height - t))
7272
painter.drawImage(origin / self._dpi_ratio, qimage)
7373

7474
self._draw_rect_callback(painter)

lib/matplotlib/backends/qt_editor/figureoptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def apply_callback(data):
222222
rgba = mcolors.to_rgba(color)
223223
line.set_alpha(None)
224224
line.set_color(rgba)
225-
if marker is not 'none':
225+
if marker != 'none':
226226
line.set_marker(marker)
227227
line.set_markersize(markersize)
228228
line.set_markerfacecolor(markerfacecolor)

lib/matplotlib/contour.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ def __init__(self, ax, *args, **kwargs):
870870
self.logscale = True
871871
if norm is None:
872872
norm = colors.LogNorm()
873-
if self.extend is not 'neither':
873+
if self.extend != 'neither':
874874
raise ValueError('extend kwarg does not work yet with log '
875875
' scale')
876876
else:

lib/matplotlib/font_manager.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@
4343
The font directory code is from ttfquery,
4444
see license/LICENSE_TTFQUERY.
4545
"""
46-
47-
from collections import Iterable
46+
try:
47+
from collections.abc import Iterable
48+
except ImportError:
49+
from collections import Iterable
4850
import json
4951
import os
5052
import sys

lib/matplotlib/pyplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2419,7 +2419,7 @@ def matshow(A, fignum=None, **kwargs):
24192419
24202420
"""
24212421
A = np.asanyarray(A)
2422-
if fignum is False or fignum is 0:
2422+
if fignum is False or fignum == 0:
24232423
ax = gca()
24242424
else:
24252425
# Extract actual aspect ratio of array and make appropriately sized figure

src/_macosx.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#define PY_SSIZE_T_CLEAN
12
#include <Cocoa/Cocoa.h>
23
#include <ApplicationServices/ApplicationServices.h>
34
#include <sys/socket.h>

src/_png.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Undefining _POSIX_C_SOURCE and _XOPEN_SOURCE stops a couple
66
of harmless warnings.
77
*/
8-
8+
#define PY_SSIZE_T_CLEAN
99

1010
extern "C" {
1111
# include <png.h>

src/_tkagg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* See LICENSE/LICENSE.PIL for details.
88
*
99
*/
10-
10+
#define PY_SSIZE_T_CLEAN
1111
#include <Python.h>
1212
#include <cstdlib>
1313
#include <cstdio>

src/_ttconv.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
Python wrapper for TrueType conversion library in ../ttconv.
77
*/
8-
8+
#define PY_SSIZE_T_CLEAN
99
#include "mplutils.h"
1010

1111
#include <Python.h>

src/file_compat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#ifndef __FILE_COMPAT_H__
22
#define __FILE_COMPAT_H__
3-
3+
#define PY_SSIZE_T_CLEAN
44
#include <Python.h>
55
#include <stdio.h>
66
#include "numpy/npy_common.h"

src/ft2font.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ extern "C" {
1818
/*
1919
By definition, FT_FIXED as 2 16bit values stored in a single long.
2020
*/
21-
#define FIXED_MAJOR(val) (long)((val & 0xffff000) >> 16)
22-
#define FIXED_MINOR(val) (long)(val & 0xffff)
21+
#define FIXED_MAJOR(val) (signed short)((val & 0xffff0000) >> 16)
22+
#define FIXED_MINOR(val) (unsigned short)(val & 0xffff)
2323

2424
// the FreeType string rendered into a width, height buffer
2525
class FT2Image

src/ft2font_wrapper.cpp

Lines changed: 60 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ static void PyGlyph_dealloc(PyGlyph *self)
276276
static PyObject *PyGlyph_get_bbox(PyGlyph *self, void *closure)
277277
{
278278
return Py_BuildValue(
279-
"iiii", self->bbox.xMin, self->bbox.yMin, self->bbox.xMax, self->bbox.yMax);
279+
"llll", self->bbox.xMin, self->bbox.yMin, self->bbox.xMax, self->bbox.yMax);
280280
}
281281

282282
static PyTypeObject *PyGlyph_init_type(PyObject *m, PyTypeObject *type)
@@ -1026,7 +1026,7 @@ static PyObject *PyFT2Font_get_sfnt(PyFT2Font *self, PyObject *args, PyObject *k
10261026
}
10271027

10281028
PyObject *key = Py_BuildValue(
1029-
"iiii", sfnt.platform_id, sfnt.encoding_id, sfnt.language_id, sfnt.name_id);
1029+
"HHHH", sfnt.platform_id, sfnt.encoding_id, sfnt.language_id, sfnt.name_id);
10301030
if (key == NULL) {
10311031
Py_DECREF(names);
10321032
return NULL;
@@ -1090,7 +1090,7 @@ static PyObject *PyFT2Font_get_ps_font_info(PyFT2Font *self, PyObject *args, PyO
10901090
return NULL;
10911091
}
10921092

1093-
return Py_BuildValue("sssssliii",
1093+
return Py_BuildValue("ssssslbhH",
10941094
fontinfo.version ? fontinfo.version : "",
10951095
fontinfo.notice ? fontinfo.notice : "",
10961096
fontinfo.full_name ? fontinfo.full_name : "",
@@ -1135,8 +1135,8 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
11351135
switch (tag) {
11361136
case 0: {
11371137
char head_dict[] =
1138-
"{s:(h,h), s:(h,h), s:l, s:l, s:i, s:i,"
1139-
"s:(l,l), s:(l,l), s:h, s:h, s:h, s:h, s:i, s:i, s:h, s:h, s:h}";
1138+
"{s:(h,H), s:(h,H), s:l, s:l, s:H, s:H,"
1139+
"s:(l,l), s:(l,l), s:h, s:h, s:h, s:h, s:H, s:H, s:h, s:h, s:h}";
11401140
TT_Header *t = (TT_Header *)table;
11411141
return Py_BuildValue(head_dict,
11421142
"version",
@@ -1150,9 +1150,9 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
11501150
"magicNumber",
11511151
t->Magic_Number,
11521152
"flags",
1153-
(unsigned)t->Flags,
1153+
t->Flags,
11541154
"unitsPerEm",
1155-
(unsigned)t->Units_Per_EM,
1155+
t->Units_Per_EM,
11561156
"created",
11571157
t->Created[0],
11581158
t->Created[1],
@@ -1168,9 +1168,9 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
11681168
"yMax",
11691169
t->yMax,
11701170
"macStyle",
1171-
(unsigned)t->Mac_Style,
1171+
t->Mac_Style,
11721172
"lowestRecPPEM",
1173-
(unsigned)t->Lowest_Rec_PPEM,
1173+
t->Lowest_Rec_PPEM,
11741174
"fontDirectionHint",
11751175
t->Font_Direction,
11761176
"indexToLocFormat",
@@ -1180,64 +1180,64 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
11801180
}
11811181
case 1: {
11821182
char maxp_dict[] =
1183-
"{s:(h,h), s:i, s:i, s:i, s:i, s:i, s:i,"
1184-
"s:i, s:i, s:i, s:i, s:i, s:i, s:i, s:i}";
1183+
"{s:(h,H), s:H, s:H, s:H, s:H, s:H, s:H,"
1184+
"s:H, s:H, s:H, s:H, s:H, s:H, s:H, s:H}";
11851185
TT_MaxProfile *t = (TT_MaxProfile *)table;
11861186
return Py_BuildValue(maxp_dict,
11871187
"version",
11881188
FIXED_MAJOR(t->version),
11891189
FIXED_MINOR(t->version),
11901190
"numGlyphs",
1191-
(unsigned)t->numGlyphs,
1191+
t->numGlyphs,
11921192
"maxPoints",
1193-
(unsigned)t->maxPoints,
1193+
t->maxPoints,
11941194
"maxContours",
1195-
(unsigned)t->maxContours,
1195+
t->maxContours,
11961196
"maxComponentPoints",
1197-
(unsigned)t->maxCompositePoints,
1197+
t->maxCompositePoints,
11981198
"maxComponentContours",
1199-
(unsigned)t->maxCompositeContours,
1199+
t->maxCompositeContours,
12001200
"maxZones",
1201-
(unsigned)t->maxZones,
1201+
t->maxZones,
12021202
"maxTwilightPoints",
1203-
(unsigned)t->maxTwilightPoints,
1203+
t->maxTwilightPoints,
12041204
"maxStorage",
1205-
(unsigned)t->maxStorage,
1205+
t->maxStorage,
12061206
"maxFunctionDefs",
1207-
(unsigned)t->maxFunctionDefs,
1207+
t->maxFunctionDefs,
12081208
"maxInstructionDefs",
1209-
(unsigned)t->maxInstructionDefs,
1209+
t->maxInstructionDefs,
12101210
"maxStackElements",
1211-
(unsigned)t->maxStackElements,
1211+
t->maxStackElements,
12121212
"maxSizeOfInstructions",
1213-
(unsigned)t->maxSizeOfInstructions,
1213+
t->maxSizeOfInstructions,
12141214
"maxComponentElements",
1215-
(unsigned)t->maxComponentElements,
1215+
t->maxComponentElements,
12161216
"maxComponentDepth",
1217-
(unsigned)t->maxComponentDepth);
1217+
t->maxComponentDepth);
12181218
}
12191219
case 2: {
12201220
#if PY3K
12211221
char os_2_dict[] =
1222-
"{s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:h,"
1223-
"s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:y#, s:(llll),"
1224-
"s:y#, s:h, s:h, s:h}";
1222+
"{s:H, s:h, s:H, s:H, s:H, s:h, s:h, s:h,"
1223+
"s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:y#, s:(kkkk),"
1224+
"s:y#, s:H, s:H, s:H}";
12251225
#else
12261226
char os_2_dict[] =
1227-
"{s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:h,"
1228-
"s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:s#, s:(llll),"
1229-
"s:s#, s:h, s:h, s:h}";
1227+
"{s:H, s:h, s:H, s:H, s:H, s:h, s:h, s:h,"
1228+
"s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:s#, s:(kkkk),"
1229+
"s:s#, s:H, s:H, s:H}";
12301230
#endif
12311231
TT_OS2 *t = (TT_OS2 *)table;
12321232
return Py_BuildValue(os_2_dict,
12331233
"version",
1234-
(unsigned)t->version,
1234+
t->version,
12351235
"xAvgCharWidth",
12361236
t->xAvgCharWidth,
12371237
"usWeightClass",
1238-
(unsigned)t->usWeightClass,
1238+
t->usWeightClass,
12391239
"usWidthClass",
1240-
(unsigned)t->usWidthClass,
1240+
t->usWidthClass,
12411241
"fsType",
12421242
t->fsType,
12431243
"ySubscriptXSize",
@@ -1264,26 +1264,26 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
12641264
t->sFamilyClass,
12651265
"panose",
12661266
t->panose,
1267-
10,
1267+
Py_ssize_t(10),
12681268
"ulCharRange",
1269-
(unsigned long)t->ulUnicodeRange1,
1270-
(unsigned long)t->ulUnicodeRange2,
1271-
(unsigned long)t->ulUnicodeRange3,
1272-
(unsigned long)t->ulUnicodeRange4,
1269+
t->ulUnicodeRange1,
1270+
t->ulUnicodeRange2,
1271+
t->ulUnicodeRange3,
1272+
t->ulUnicodeRange4,
12731273
"achVendID",
12741274
t->achVendID,
1275-
4,
1275+
Py_ssize_t(4),
12761276
"fsSelection",
1277-
(unsigned)t->fsSelection,
1277+
t->fsSelection,
12781278
"fsFirstCharIndex",
1279-
(unsigned)t->usFirstCharIndex,
1279+
t->usFirstCharIndex,
12801280
"fsLastCharIndex",
1281-
(unsigned)t->usLastCharIndex);
1281+
t->usLastCharIndex);
12821282
}
12831283
case 3: {
12841284
char hhea_dict[] =
1285-
"{s:(h,h), s:h, s:h, s:h, s:i, s:h, s:h, s:h,"
1286-
"s:h, s:h, s:h, s:h, s:i}";
1285+
"{s:(h,H), s:h, s:h, s:h, s:H, s:h, s:h, s:h,"
1286+
"s:h, s:h, s:h, s:h, s:H}";
12871287
TT_HoriHeader *t = (TT_HoriHeader *)table;
12881288
return Py_BuildValue(hhea_dict,
12891289
"version",
@@ -1296,7 +1296,7 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
12961296
"lineGap",
12971297
t->Line_Gap,
12981298
"advanceWidthMax",
1299-
(unsigned)t->advance_Width_Max,
1299+
t->advance_Width_Max,
13001300
"minLeftBearing",
13011301
t->min_Left_Side_Bearing,
13021302
"minRightBearing",
@@ -1312,12 +1312,12 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
13121312
"metricDataFormat",
13131313
t->metric_Data_Format,
13141314
"numOfLongHorMetrics",
1315-
(unsigned)t->number_Of_HMetrics);
1315+
t->number_Of_HMetrics);
13161316
}
13171317
case 4: {
13181318
char vhea_dict[] =
1319-
"{s:(h,h), s:h, s:h, s:h, s:i, s:h, s:h, s:h,"
1320-
"s:h, s:h, s:h, s:h, s:i}";
1319+
"{s:(h,H), s:h, s:h, s:h, s:H, s:h, s:h, s:h,"
1320+
"s:h, s:h, s:h, s:h, s:H}";
13211321
TT_VertHeader *t = (TT_VertHeader *)table;
13221322
return Py_BuildValue(vhea_dict,
13231323
"version",
@@ -1330,7 +1330,7 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
13301330
"vertTypoLineGap",
13311331
t->Line_Gap,
13321332
"advanceHeightMax",
1333-
(unsigned)t->advance_Height_Max,
1333+
t->advance_Height_Max,
13341334
"minTopSideBearing",
13351335
t->min_Top_Side_Bearing,
13361336
"minBottomSizeBearing",
@@ -1346,10 +1346,10 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
13461346
"metricDataFormat",
13471347
t->metric_Data_Format,
13481348
"numOfLongVerMetrics",
1349-
(unsigned)t->number_Of_VMetrics);
1349+
t->number_Of_VMetrics);
13501350
}
13511351
case 5: {
1352-
char post_dict[] = "{s:(h,h), s:(h,h), s:h, s:h, s:k, s:k, s:k, s:k, s:k}";
1352+
char post_dict[] = "{s:(h,H), s:(h,H), s:h, s:h, s:k, s:k, s:k, s:k, s:k}";
13531353
TT_Postscript *t = (TT_Postscript *)table;
13541354
return Py_BuildValue(post_dict,
13551355
"format",
@@ -1376,12 +1376,12 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
13761376
case 6: {
13771377
#if PY3K
13781378
char pclt_dict[] =
1379-
"{s:(h,h), s:k, s:H, s:H, s:H, s:H, s:H, s:H, s:y, s:y, s:b, s:b, "
1380-
"s:b}";
1379+
"{s:(h,H), s:k, s:H, s:H, s:H, s:H, s:H, s:H, s:y#, s:y#, s:b, "
1380+
"s:b, s:b}";
13811381
#else
13821382
char pclt_dict[] =
1383-
"{s:(h,h), s:k, s:H, s:H, s:H, s:H, s:H, s:H, s:s, s:s, s:b, s:b, "
1384-
"s:b}";
1383+
"{s:(h,H), s:k, s:H, s:H, s:H, s:H, s:H, s:H, s:s#, s:s#, s:b, "
1384+
"s:b, s:b}";
13851385
#endif
13861386
TT_PCLT *t = (TT_PCLT *)table;
13871387
return Py_BuildValue(pclt_dict,
@@ -1404,8 +1404,10 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
14041404
t->SymbolSet,
14051405
"typeFace",
14061406
t->TypeFace,
1407+
Py_ssize_t(16),
14071408
"characterComplement",
14081409
t->CharacterComplement,
1410+
Py_ssize_t(8),
14091411
"strokeWeight",
14101412
t->StrokeWeight,
14111413
"widthType",
@@ -1528,7 +1530,8 @@ static PyObject *PyFT2Font_get_bbox(PyFT2Font *self, void *closure)
15281530
{
15291531
FT_BBox *bbox = &(self->x->get_face()->bbox);
15301532

1531-
return Py_BuildValue("iiii", bbox->xMin, bbox->yMin, bbox->xMax, bbox->yMax);
1533+
return Py_BuildValue("llll",
1534+
bbox->xMin, bbox->yMin, bbox->xMax, bbox->yMax);
15321535
}
15331536

15341537
static PyObject *PyFT2Font_ascender(PyFT2Font *self, void *closure)

src/mplutils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#ifndef _MPLUTILS_H
66
#define _MPLUTILS_H
7+
#define PY_SSIZE_T_CLEAN
78

89
#if defined(_MSC_VER) && _MSC_VER <= 1600
910
typedef unsigned __int8 uint8_t;

src/numpy_cpp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#ifndef _NUMPY_CPP_H_
44
#define _NUMPY_CPP_H_
5-
5+
#define PY_SSIZE_T_CLEAN
66
/***************************************************************************
77
* This file is based on original work by Mark Wiebe, available at:
88
*

0 commit comments

Comments
 (0)