Spend all of my time in the mountains prospecting and nugget-shooting. See bears often, very often and some are exceptionally beautiful, some are timid and shy, some are lost in the ecstasy of mountain splendour, some are cranky and hostile, some are angry and protective, most are very much like people--you never know what you're going to get. But just like with the majority of people, there are some general rules that work most of the time.
I have met bad black bears, and the advice given on when one locks on to you with a predatory stare and approach is fight for your life with anything and everything you've got as black bears that aren't afraid of people are bad, bad news. Bear spray, bear spray, bear spray . . . Too many people wound bears and have a far bigger issue. (I packed heat for many, many years, and sometimes, it is necessary, but now my go-to is bear spray as the research shows [watch some videos] it's a very effective deterrent, so you don't have to worry about an angry, wounded bear that now feels it's fighting for its life . . .) I too have a super-powerful handgun that's rated for large game, and I too have a defender shotgun with buck for the first round, followed by rifled slugs to finish the job, but I now pack spray for most outings. (There are definitely exceptions, depending on the area as I'm not incautious enough not to be prepared!)
Having said what I've said, and having experienced enough bear encounters to know how they act and react, and having had encounters with bad bears and lots of scared running-away bears, as well as curious, mellow bears, I'd like to say something else: bears come around for a reason (find the reason if you can, and eliminate the reason if you're part of the problem); all bears are attracted to a location for a reason, sometimes its curiosity (had two BIG grizzlies wander over to see what we were doing one day while we were mining, and we were making a lot of noise, but once they had a look-see, and that look-see was only from about 20 to 30 feet of distance when they stood up (if you think a grizzly is big on the ground, wait until they (X2!) stand up!!), but they turned and ambled (that's right, ambled=they were in no hurry whatsoever as they knew they were the top of the food chain in their environment) easily away to their next sight-seeing opportunity.
I've always been taught that if a black attacks fight back with everything you've got! It sees you as food or you've come between it and a cub, or you've surprised it in dense brush; regardless, if it's a black, fight back. Grizzlies, you're supposed to roll-up and protect your vitals as it asserts its dominance, but if that dominance begins to be life-threatening (if they don't snort their defiance as they assert their dominance by having subdued you to then leave you), you have to fight back.
Here's the stickler in all of this: if you can't get your bear spray or your firearm out or swing it around (in dense brush) in time to get a squirt or a shot off, you're in serious trouble, and sad to say, people have been found exactly like that. (Two years ago in my area a prospector was mugged [dead] in the brush by a black and his spray was still in his holster; prior to that, a hunter was found with firearm unfired, death by angry bear (in dense timber). So, this may be the crux of part of this matter: avoid heavy timber/brush/bush as it swallows up any warning sounds you may be trying to make, and not even I like to be surprised. Can you imagine how an animal 3-5X your weight might react? I guess with what I've related, there's no need . . .
So, I'd find out why it's coming around, and others have offered excellent suggestions to facilitate that, as well as excellent suggestions about not being alone, etc.
However, sometimes it doesn't matter how careful you are, you'll have an encounter if you're in a bear area, and that's when your decision, your ultimate response, will make all the difference, or it won't . . .
Bear poop is non-lethal, the poop-producer may or may not be, depending . . .
All the best,
Lanny