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

Skip to content

Commit 79f25d9

Browse files
committed
Quickly renamed the remaining files -- this directory is done.
1 parent 65bf9f2 commit 79f25d9

10 files changed

Lines changed: 1834 additions & 1748 deletions

File tree

Python/bltinmodule.c

Lines changed: 677 additions & 662 deletions
Large diffs are not rendered by default.

Python/compile.c

Lines changed: 331 additions & 312 deletions
Large diffs are not rendered by default.

Python/getargs.c

Lines changed: 96 additions & 95 deletions
Large diffs are not rendered by default.

Python/import.c

Lines changed: 282 additions & 270 deletions
Large diffs are not rendered by default.

Python/importdl.c

Lines changed: 84 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ PERFORMANCE OF THIS SOFTWARE.
3232
/* Support for dynamic loading of extension modules */
3333
/* If no dynamic linking is supported, this file still generates some code! */
3434

35-
#include "allobjects.h"
35+
#include "Python.h"
3636
#include "osdefs.h"
3737
#include "importdl.h"
3838

@@ -167,7 +167,7 @@ typedef void (*dl_funcptr)();
167167
#ifdef USE_MAC_DYNAMIC_LOADING
168168
#include <Aliases.h>
169169
#include <CodeFragments.h>
170-
#ifdef SYMANTEC__CFM68K__ /* Really just an older version of Universal Headers */
170+
#ifdef SYMANTEC__CFM68K__ /* Really an older version of Universal Headers */
171171
#define CFragConnectionID ConnectionID
172172
#define kLoadCFrag 0x01
173173
#endif
@@ -184,7 +184,7 @@ typedef void (*dl_funcptr)();
184184
#endif
185185
#endif /* USE_RLD */
186186

187-
extern char *getprogramname();
187+
extern char *Py_GetProgramName();
188188

189189
#ifndef FUNCNAME_PATTERN
190190
#if defined(__hp9000s300) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__BORLANDC__)
@@ -207,9 +207,9 @@ extern char *getprogramname();
207207
#endif
208208

209209
/* Pass it on to import.c */
210-
int import_maxsuffixsize = MAXSUFFIXSIZE;
210+
int _PyImport_MaxSuffixSize = MAXSUFFIXSIZE;
211211

212-
struct filedescr import_filetab[] = {
212+
struct filedescr _PyImport_Filetab[] = {
213213
#ifdef SHORT_EXT
214214
{SHORT_EXT, "rb", C_EXTENSION},
215215
#endif /* !SHORT_EXT */
@@ -225,17 +225,18 @@ struct filedescr import_filetab[] = {
225225
#undef DYNAMIC_LINK
226226
#endif
227227

228-
object *
229-
load_dynamic_module(name, pathname, fp)
228+
PyObject *
229+
_PyImport_LoadDynamicModule(name, pathname, fp)
230230
char *name;
231231
char *pathname;
232232
FILE *fp;
233233
{
234234
#ifndef DYNAMIC_LINK
235-
err_setstr(ImportError, "dynamically linked modules not supported");
235+
PyErr_SetString(PyExc_ImportError,
236+
"dynamically linked modules not supported");
236237
return NULL;
237238
#else
238-
object *m, *d, *s;
239+
PyObject *m, *d, *s;
239240
char funcname[258];
240241
dl_funcptr p = NULL;
241242
#ifdef USE_SHLIB
@@ -274,11 +275,12 @@ load_dynamic_module(name, pathname, fp)
274275
#endif /* USE_SHLIB */
275276
#ifdef USE_MAC_DYNAMIC_LOADING
276277
/*
277-
** Dynamic loading of CFM shared libraries on the Mac.
278-
** The code has become more convoluted than it was, because we want to be able
279-
** to put multiple modules in a single file. For this reason, we have to determine
280-
** the fragment name, and we cannot use the library entry point but we have to locate
281-
** the correct init routine "by hand".
278+
** Dynamic loading of CFM shared libraries on the Mac. The
279+
** code has become more convoluted than it was, because we
280+
** want to be able to put multiple modules in a single
281+
** file. For this reason, we have to determine the fragment
282+
** name, and we cannot use the library entry point but we have
283+
** to locate the correct init routine "by hand".
282284
*/
283285
{
284286
FSSpec libspec;
@@ -297,30 +299,35 @@ load_dynamic_module(name, pathname, fp)
297299
err = ResolveAliasFile(&libspec, 1, &isfolder, &didsomething);
298300
if ( err ) {
299301
sprintf(buf, "%s: %s", pathname, PyMac_StrError(err));
300-
err_setstr(ImportError, buf);
302+
PyErr_SetString(PyExc_ImportError, buf);
301303
return NULL;
302304
}
303-
/* Next, determine the fragment name, by stripping '.slb' and 'module' */
305+
/* Next, determine the fragment name,
306+
by stripping '.slb' and 'module' */
304307
memcpy(fragname+1, libspec.name+1, libspec.name[0]);
305308
fragname[0] = libspec.name[0];
306-
if( strncmp((char *)(fragname+1+fragname[0]-4), ".slb", 4) == 0 )
309+
if( strncmp((char *)(fragname+1+fragname[0]-4),
310+
".slb", 4) == 0 )
307311
fragname[0] -= 4;
308-
if ( strncmp((char *)(fragname+1+fragname[0]-6), "module", 6) == 0 )
312+
if ( strncmp((char *)(fragname+1+fragname[0]-6),
313+
"module", 6) == 0 )
309314
fragname[0] -= 6;
310-
/* Load the fragment (or return the connID if it is already loaded */
315+
/* Load the fragment
316+
(or return the connID if it is already loaded */
311317
err = GetDiskFragment(&libspec, 0, 0, fragname,
312318
kLoadCFrag, &connID, &mainAddr,
313319
errMessage);
314320
if ( err ) {
315-
sprintf(buf, "%.*s: %s", errMessage[0], errMessage+1, PyMac_StrError(err));
316-
err_setstr(ImportError, buf);
321+
sprintf(buf, "%.*s: %s", errMessage[0], errMessage+1,
322+
PyMac_StrError(err));
323+
PyErr_SetString(PyExc_ImportError, buf);
317324
return NULL;
318325
}
319326
/* Locate the address of the correct init function */
320327
err = FindSymbol(connID, Pstring(funcname), &symAddr, &class);
321328
if ( err ) {
322329
sprintf(buf, "%s: %s", funcname, PyMac_StrError(err));
323-
err_setstr(ImportError, buf);
330+
PyErr_SetString(PyExc_ImportError, buf);
324331
return NULL;
325332
}
326333
p = (dl_funcptr)symAddr;
@@ -334,12 +341,12 @@ load_dynamic_module(name, pathname, fp)
334341
void *handle = dlopen(pathname, RTLD_NOW);
335342
#else
336343
void *handle;
337-
if (verbose)
344+
if (Py_VerboseFlag)
338345
printf("dlopen(\"%s\", %d);\n", pathname, RTLD_LAZY);
339346
handle = dlopen(pathname, RTLD_LAZY);
340347
#endif /* RTLD_NOW */
341348
if (handle == NULL) {
342-
err_setstr(ImportError, dlerror());
349+
PyErr_SetString(PyExc_ImportError, dlerror());
343350
return NULL;
344351
}
345352
if (fp != NULL && nhandles < 128)
@@ -382,35 +389,44 @@ load_dynamic_module(name, pathname, fp)
382389
unsigned int errorCode;
383390

384391
/* Get an error string from Win32 error code */
385-
char theInfo[256]; /* Pointer to error text from system */
386-
int theLength; /* Length of error text */
392+
char theInfo[256]; /* Pointer to error text
393+
from system */
394+
int theLength; /* Length of error text */
387395

388396
errorCode = GetLastError();
389397

390-
theLength = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, /* flags */
391-
NULL, /* message source */
392-
errorCode, /* the message (error) ID */
393-
0, /* default language environment */
394-
(LPTSTR) theInfo, /* the buffer */
395-
sizeof(theInfo), /* the buffer size */
396-
NULL); /* no additional format args. */
397-
398-
/* Problem: could not get the error message. This should not happen if called correctly. */
398+
theLength = FormatMessage(
399+
FORMAT_MESSAGE_FROM_SYSTEM, /* flags */
400+
NULL, /* message source */
401+
errorCode, /* the message (error) ID */
402+
0, /* default language environment */
403+
(LPTSTR) theInfo, /* the buffer */
404+
sizeof(theInfo), /* the buffer size */
405+
NULL); /* no additional format args. */
406+
407+
/* Problem: could not get the error message.
408+
This should not happen if called correctly. */
399409
if (theLength == 0) {
400-
sprintf(errBuf, "DLL load failed with error code %d", errorCode);
410+
sprintf(errBuf,
411+
"DLL load failed with error code %d",
412+
errorCode);
401413
} else {
402414
int len;
403-
/* For some reason a \r\n is appended to the text */
404-
if (theLength >= 2 && theInfo[theLength-2] == '\r' && theInfo[theLength-1] == '\n') {
415+
/* For some reason a \r\n
416+
is appended to the text */
417+
if (theLength >= 2 &&
418+
theInfo[theLength-2] == '\r' &&
419+
theInfo[theLength-1] == '\n') {
405420
theLength -= 2;
406421
theInfo[theLength] = '\0';
407422
}
408423
strcpy(errBuf, "DLL load failed: ");
409424
len = strlen(errBuf);
410-
strncpy(errBuf+len, theInfo, sizeof(errBuf)-len);
425+
strncpy(errBuf+len, theInfo,
426+
sizeof(errBuf)-len);
411427
errBuf[sizeof(errBuf)-1] = '\0';
412428
}
413-
err_setstr(ImportError, errBuf);
429+
PyErr_SetString(PyExc_ImportError, errBuf);
414430
return NULL;
415431
}
416432
p = GetProcAddress(hDLL, funcname);
@@ -422,15 +438,16 @@ load_dynamic_module(name, pathname, fp)
422438
hDLL = LoadLibrary(pathname);
423439
if (hDLL < HINSTANCE_ERROR){
424440
char errBuf[256];
425-
sprintf(errBuf, "DLL load failed with error code %d", hDLL);
426-
err_setstr(ImportError, errBuf);
441+
sprintf(errBuf,
442+
"DLL load failed with error code %d", hDLL);
443+
PyErr_SetString(PyExc_ImportError, errBuf);
427444
return NULL;
428445
}
429446
p = GetProcAddress(hDLL, funcname);
430447
}
431448
#endif /* MS_WIN16 */
432449
#ifdef USE_DL
433-
p = dl_loadmod(getprogramname(), pathname, funcname);
450+
p = dl_loadmod(Py_GetProgramName(), pathname, funcname);
434451
#endif /* USE_DL */
435452
#ifdef USE_RLD
436453
{
@@ -455,7 +472,7 @@ load_dynamic_module(name, pathname, fp)
455472

456473
NXGetMemoryBuffer(errorStream,
457474
&streamBuf, &len, &maxLen);
458-
err_setstr(ImportError, streamBuf);
475+
PyErr_SetString(PyExc_ImportError, streamBuf);
459476
}
460477

461478
if(ret && rld_lookup(errorStream, funcname, &ptr))
@@ -473,57 +490,58 @@ load_dynamic_module(name, pathname, fp)
473490
int flags;
474491

475492
flags = BIND_FIRST | BIND_DEFERRED;
476-
if (verbose)
493+
if (Py_VerboseFlag)
477494
{
478-
flags = DYNAMIC_PATH | BIND_FIRST | BIND_IMMEDIATE | BIND_NONFATAL | BIND_VERBOSE;
495+
flags = DYNAMIC_PATH | BIND_FIRST | BIND_IMMEDIATE |
496+
BIND_NONFATAL | BIND_VERBOSE;
479497
printf("shl_load %s\n",pathname);
480498
}
481499
lib = shl_load(pathname, flags, 0);
482500
if (lib == NULL)
483501
{
484502
char buf[256];
485-
if (verbose)
503+
if (Py_VerboseFlag)
486504
perror(pathname);
487505
sprintf(buf, "Failed to load %.200s", pathname);
488-
err_setstr(ImportError, buf);
506+
PyErr_SetString(PyExc_ImportError, buf);
489507
return NULL;
490508
}
491-
if (verbose)
509+
if (Py_VerboseFlag)
492510
printf("shl_findsym %s\n", funcname);
493511
shl_findsym(&lib, funcname, TYPE_UNDEFINED, (void *) &p);
494-
if (p == NULL && verbose)
512+
if (p == NULL && Py_VerboseFlag)
495513
perror(funcname);
496514
}
497515
#endif /* hpux */
498516
#ifdef USE_SHLIB
499517
got_it:
500518
#endif
501519
if (p == NULL) {
502-
err_setstr(ImportError,
520+
PyErr_SetString(PyExc_ImportError,
503521
"dynamic module does not define init function");
504522
return NULL;
505523
}
506524
(*p)();
507525
/* XXX Need check for err_occurred() here */
508526

509-
m = dictlookup(import_modules, name);
527+
m = PyDict_GetItemString(import_modules, name);
510528
if (m == NULL) {
511-
if (err_occurred() == NULL)
512-
err_setstr(SystemError,
529+
if (PyErr_Occurred() == NULL)
530+
PyErr_SetString(PyExc_SystemError,
513531
"dynamic module not initialized properly");
514532
return NULL;
515533
}
516534
/* Remember the filename as the __file__ attribute */
517-
d = getmoduledict(m);
518-
s = newstringobject(pathname);
519-
if (s == NULL || dictinsert(d, "__file__", s) != 0)
520-
err_clear(); /* Not important enough to report */
521-
XDECREF(s);
522-
if (verbose)
535+
d = PyModule_GetDict(m);
536+
s = PyString_FromString(pathname);
537+
if (s == NULL || PyDict_SetItemString(d, "__file__", s) != 0)
538+
PyErr_Clear(); /* Not important enough to report */
539+
Py_XDECREF(s);
540+
if (Py_VerboseFlag)
523541
fprintf(stderr,
524542
"import %s # dynamically loaded from %s\n",
525543
name, pathname);
526-
INCREF(m);
544+
Py_INCREF(m);
527545
return m;
528546
#endif /* DYNAMIC_LINK */
529547
}
@@ -555,20 +573,20 @@ aix_getoldmodules(modlistptr)
555573
-- Get the list of loaded modules into ld_info structures.
556574
*/
557575
if ((ldibuf = malloc(bufsize)) == NULL) {
558-
err_setstr(ImportError, strerror(errno));
576+
PyErr_SetString(PyExc_ImportError, strerror(errno));
559577
return -1;
560578
}
561579
while ((errflag = loadquery(L_GETINFO, ldibuf, bufsize)) == -1
562580
&& errno == ENOMEM) {
563581
free(ldibuf);
564582
bufsize += 1024;
565583
if ((ldibuf = malloc(bufsize)) == NULL) {
566-
err_setstr(ImportError, strerror(errno));
584+
PyErr_SetString(PyExc_ImportError, strerror(errno));
567585
return -1;
568586
}
569587
}
570588
if (errflag == -1) {
571-
err_setstr(ImportError, strerror(errno));
589+
PyErr_SetString(PyExc_ImportError, strerror(errno));
572590
return -1;
573591
}
574592
/*
@@ -578,7 +596,7 @@ aix_getoldmodules(modlistptr)
578596
prevmodptr = NULL;
579597
do {
580598
if ((modptr = (ModulePtr)malloc(sizeof(Module))) == NULL) {
581-
err_setstr(ImportError, strerror(errno));
599+
PyErr_SetString(PyExc_ImportError, strerror(errno));
582600
while (*modlistptr) {
583601
modptr = (ModulePtr)*modlistptr;
584602
*modlistptr = (void *)modptr->next;
@@ -662,7 +680,7 @@ aix_loaderror(pathname)
662680
ERRBUF_APPEND("\n");
663681
}
664682
errbuf[strlen(errbuf)-1] = '\0'; /* trim off last newline */
665-
err_setstr(ImportError, errbuf);
683+
PyErr_SetString(PyExc_ImportError, errbuf);
666684
return;
667685
}
668686

Python/importdl.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ extern struct filedescr {
4040
char *suffix;
4141
char *mode;
4242
enum filetype type;
43-
} import_filetab[];
43+
} _PyImport_Filetab[];
4444

45-
extern object *import_modules;
45+
extern PyObject *import_modules;
4646

47-
extern object *load_dynamic_module PROTO((char *name, char *pathname, FILE *));
47+
extern PyObject *_PyImport_LoadDynamicModule
48+
Py_PROTO((char *name, char *pathname, FILE *));
4849

49-
extern int import_maxsuffixsize;
50+
extern int _PyImport_MaxSuffixSize;

0 commit comments

Comments
 (0)