File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed
Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -1165,7 +1165,7 @@ def test_flush_parameters(self):
11651165 m .flush (PAGESIZE )
11661166 m .flush (PAGESIZE , PAGESIZE )
11671167
1168- @unittest .skipUnless (hasattr (mmap , 'MAP_ANONYMOUS' ), 'requires MAP_ANONYMOUS' )
1168+ @unittest .skipUnless (hasattr (mmap , 'MAP_ANONYMOUS' ) and sys . platform == "linux" , 'requires MAP_ANONYMOUS and should be linux ' )
11691169 def test_set_name (self ):
11701170 # Test setting name on anonymous mmap
11711171 m = mmap .mmap (- 1 , PAGESIZE )
Original file line number Diff line number Diff line change @@ -1131,14 +1131,14 @@ static PyObject *
11311131mmap_mmap_set_name_impl (mmap_object * self , const char * name )
11321132/*[clinic end generated code: output=1edaf4fd51277760 input=6c7dd91cad205f07]*/
11331133{
1134- const char * prefix = "cpython:mmap:" ;
1134+ #if defined(MAP_ANONYMOUS ) && defined(__linux__ )
1135+ const char * prefix = "cpython:mmap:" ;
11351136 if (strlen (name ) + strlen (prefix ) > 80 ) {
11361137 PyErr_SetString (PyExc_ValueError , "name is too long" );
11371138 return NULL ;
11381139 }
1139- #ifdef MAP_ANONYMOUS
11401140 if (self -> flags & MAP_ANONYMOUS ) {
1141- char buf [80 ] = {0 , };
1141+ char buf [81 ] = {0 , };
11421142 sprintf (buf , "%s%s" , prefix , name );
11431143 _PyAnnotateMemoryMap (self -> data , self -> size , buf );
11441144 }
@@ -1150,7 +1150,7 @@ mmap_mmap_set_name_impl(mmap_object *self, const char *name)
11501150 }
11511151#else
11521152 /* naming not supported on this platform */
1153- PyErr_SetString (PyExc_ValueError ,
1153+ PyErr_SetString (NotImplementedError ,
11541154 "Annotation of mmap is not supported on this platform" );
11551155 return NULL ;
11561156#endif
You can’t perform that action at this time.
0 commit comments